code
stringlengths
66
870k
docstring
stringlengths
19
26.7k
func_name
stringlengths
1
138
language
stringclasses
1 value
repo
stringlengths
7
68
path
stringlengths
5
324
url
stringlengths
46
389
license
stringclasses
7 values
def _gen_md5_for_arraylike_obj(md5_gen, data): """ Helper method to generate MD5 hash array-like object, the MD5 will calculate over: - array length - first NUM_SAMPLE_ROWS_FOR_HASH rows content - last NUM_SAMPLE_ROWS_FOR_HASH rows content """ len_bytes = _hash_uint64_ndarray_as_bytes(np....
Helper method to generate MD5 hash array-like object, the MD5 will calculate over: - array length - first NUM_SAMPLE_ROWS_FOR_HASH rows content - last NUM_SAMPLE_ROWS_FOR_HASH rows content
_gen_md5_for_arraylike_obj
python
mlflow/mlflow
mlflow/data/evaluation_dataset.py
https://github.com/mlflow/mlflow/blob/master/mlflow/data/evaluation_dataset.py
Apache-2.0
def convert_data_to_mlflow_dataset(data, targets=None, predictions=None): """Convert input data to mlflow dataset.""" supported_dataframe_types = [pd.DataFrame] if "pyspark" in sys.modules: from mlflow.utils.spark_utils import get_spark_dataframe_type spark_df_type = get_spark_dataframe_typ...
Convert input data to mlflow dataset.
convert_data_to_mlflow_dataset
python
mlflow/mlflow
mlflow/data/evaluation_dataset.py
https://github.com/mlflow/mlflow/blob/master/mlflow/data/evaluation_dataset.py
Apache-2.0
def _validate_dataset_type_supports_predictions(data, supported_predictions_dataset_types): """ Validate that the dataset type supports a user-specified "predictions" column. """ if not any(isinstance(data, sdt) for sdt in supported_predictions_dataset_types): raise MlflowException( ...
Validate that the dataset type supports a user-specified "predictions" column.
_validate_dataset_type_supports_predictions
python
mlflow/mlflow
mlflow/data/evaluation_dataset.py
https://github.com/mlflow/mlflow/blob/master/mlflow/data/evaluation_dataset.py
Apache-2.0
def __init__( self, data, *, targets=None, name=None, path=None, feature_names=None, predictions=None, digest=None, ): """ The values of the constructor arguments comes from the `evaluate` call. """ if name is no...
The values of the constructor arguments comes from the `evaluate` call.
__init__
python
mlflow/mlflow
mlflow/data/evaluation_dataset.py
https://github.com/mlflow/mlflow/blob/master/mlflow/data/evaluation_dataset.py
Apache-2.0
def _metadata(self): """ Return dataset metadata containing name, hash, and optional path. """ metadata = { "name": self.name, "hash": self.hash, } if self.path is not None: metadata["path"] = self.path return metadata
Return dataset metadata containing name, hash, and optional path.
_metadata
python
mlflow/mlflow
mlflow/data/evaluation_dataset.py
https://github.com/mlflow/mlflow/blob/master/mlflow/data/evaluation_dataset.py
Apache-2.0
def _log_dataset_tag(self, client, run_id, model_uuid): """ Log dataset metadata as a tag "mlflow.datasets", if the tag already exists, it will append current dataset metadata into existing tag content. """ existing_dataset_metadata_str = client.get_run(run_id).data.tags.get( ...
Log dataset metadata as a tag "mlflow.datasets", if the tag already exists, it will append current dataset metadata into existing tag content.
_log_dataset_tag
python
mlflow/mlflow
mlflow/data/evaluation_dataset.py
https://github.com/mlflow/mlflow/blob/master/mlflow/data/evaluation_dataset.py
Apache-2.0
def uri(self): """The URI referring to the dataset source filesystem location. Returns: The URI referring to the dataset source filesystem location, e.g "s3://mybucket/path/to/mydataset", "/tmp/path/to/my/dataset" etc. """
The URI referring to the dataset source filesystem location. Returns: The URI referring to the dataset source filesystem location, e.g "s3://mybucket/path/to/mydataset", "/tmp/path/to/my/dataset" etc.
uri
python
mlflow/mlflow
mlflow/data/filesystem_dataset_source.py
https://github.com/mlflow/mlflow/blob/master/mlflow/data/filesystem_dataset_source.py
Apache-2.0
def _get_source_type() -> str: """ Returns: A string describing the filesystem containing the dataset, e.g. "local", "s3", ... """
Returns: A string describing the filesystem containing the dataset, e.g. "local", "s3", ...
_get_source_type
python
mlflow/mlflow
mlflow/data/filesystem_dataset_source.py
https://github.com/mlflow/mlflow/blob/master/mlflow/data/filesystem_dataset_source.py
Apache-2.0
def load(self, dst_path=None) -> str: """Downloads the dataset source to the local filesystem. Args: dst_path: Path of the local filesystem destination directory to which to download the dataset source. If the directory does not exist, it is created. If unspe...
Downloads the dataset source to the local filesystem. Args: dst_path: Path of the local filesystem destination directory to which to download the dataset source. If the directory does not exist, it is created. If unspecified, the dataset source is downloaded to a new...
load
python
mlflow/mlflow
mlflow/data/filesystem_dataset_source.py
https://github.com/mlflow/mlflow/blob/master/mlflow/data/filesystem_dataset_source.py
Apache-2.0
def _can_resolve(raw_source: Any) -> bool: """ Args: raw_source: The raw source, e.g. a string like "s3://mybucket/path/to/iris/data". Returns: True if this DatasetSource can resolve the raw source, False otherwise. """
Args: raw_source: The raw source, e.g. a string like "s3://mybucket/path/to/iris/data". Returns: True if this DatasetSource can resolve the raw source, False otherwise.
_can_resolve
python
mlflow/mlflow
mlflow/data/filesystem_dataset_source.py
https://github.com/mlflow/mlflow/blob/master/mlflow/data/filesystem_dataset_source.py
Apache-2.0
def _resolve(cls, raw_source: Any) -> "FileSystemDatasetSource": """ Args: raw_source: The raw source, e.g. a string like "s3://mybucket/path/to/iris/data". """
Args: raw_source: The raw source, e.g. a string like "s3://mybucket/path/to/iris/data".
_resolve
python
mlflow/mlflow
mlflow/data/filesystem_dataset_source.py
https://github.com/mlflow/mlflow/blob/master/mlflow/data/filesystem_dataset_source.py
Apache-2.0
def to_dict(self) -> dict[Any, Any]: """ Returns: A JSON-compatible dictionary representation of the FileSystemDatasetSource. """
Returns: A JSON-compatible dictionary representation of the FileSystemDatasetSource.
to_dict
python
mlflow/mlflow
mlflow/data/filesystem_dataset_source.py
https://github.com/mlflow/mlflow/blob/master/mlflow/data/filesystem_dataset_source.py
Apache-2.0
def from_dict(cls, source_dict: dict[Any, Any]) -> "FileSystemDatasetSource": """ Args: source_dict: A dictionary representation of the FileSystemDatasetSource. """
Args: source_dict: A dictionary representation of the FileSystemDatasetSource.
from_dict
python
mlflow/mlflow
mlflow/data/filesystem_dataset_source.py
https://github.com/mlflow/mlflow/blob/master/mlflow/data/filesystem_dataset_source.py
Apache-2.0
def _extract_filename(self, response) -> str: """ Extracts a filename from the Content-Disposition header or the URL's path. """ if content_disposition := response.headers.get("Content-Disposition"): for match in re.finditer(r"filename=(.+)", content_disposition): ...
Extracts a filename from the Content-Disposition header or the URL's path.
_extract_filename
python
mlflow/mlflow
mlflow/data/http_dataset_source.py
https://github.com/mlflow/mlflow/blob/master/mlflow/data/http_dataset_source.py
Apache-2.0
def load(self, dst_path=None) -> str: """Downloads the dataset source to the local filesystem. Args: dst_path: Path of the local filesystem destination directory to which to download the dataset source. If the directory does not exist, it is created. If unspe...
Downloads the dataset source to the local filesystem. Args: dst_path: Path of the local filesystem destination directory to which to download the dataset source. If the directory does not exist, it is created. If unspecified, the dataset source is downloaded to a new...
load
python
mlflow/mlflow
mlflow/data/http_dataset_source.py
https://github.com/mlflow/mlflow/blob/master/mlflow/data/http_dataset_source.py
Apache-2.0
def _can_resolve(raw_source: Any) -> bool: """ Args: raw_source: The raw source, e.g. a string like "http://mysite/mydata.tar.gz". Returns: True if this DatasetSource can resolve the raw source, False otherwise. """ if not isinstance(raw_source, str): ...
Args: raw_source: The raw source, e.g. a string like "http://mysite/mydata.tar.gz". Returns: True if this DatasetSource can resolve the raw source, False otherwise.
_can_resolve
python
mlflow/mlflow
mlflow/data/http_dataset_source.py
https://github.com/mlflow/mlflow/blob/master/mlflow/data/http_dataset_source.py
Apache-2.0
def to_dict(self) -> dict[Any, Any]: """ Returns: A JSON-compatible dictionary representation of the HTTPDatasetSource. """ return { "url": self.url, }
Returns: A JSON-compatible dictionary representation of the HTTPDatasetSource.
to_dict
python
mlflow/mlflow
mlflow/data/http_dataset_source.py
https://github.com/mlflow/mlflow/blob/master/mlflow/data/http_dataset_source.py
Apache-2.0
def from_dict(cls, source_dict: dict[Any, Any]) -> "HTTPDatasetSource": """ Args: source_dict: A dictionary representation of the HTTPDatasetSource. """ url = source_dict.get("url") if url is None: raise MlflowException( 'Failed to parse HT...
Args: source_dict: A dictionary representation of the HTTPDatasetSource.
from_dict
python
mlflow/mlflow
mlflow/data/http_dataset_source.py
https://github.com/mlflow/mlflow/blob/master/mlflow/data/http_dataset_source.py
Apache-2.0
def __init__( # noqa: D417 self, ds: "datasets.Dataset", source: HuggingFaceDatasetSource, targets: Optional[str] = None, name: Optional[str] = None, digest: Optional[str] = None, ): """ Args: ds: A Hugging Face dataset. Must be an instanc...
Args: ds: A Hugging Face dataset. Must be an instance of `datasets.Dataset`. Other types, such as :py:class:`datasets.DatasetDict`, are not supported. source: The source of the Hugging Face dataset. name: The name of the dataset. E.g. "wiki_train". If unspeci...
__init__
python
mlflow/mlflow
mlflow/data/huggingface_dataset.py
https://github.com/mlflow/mlflow/blob/master/mlflow/data/huggingface_dataset.py
Apache-2.0
def _compute_digest(self) -> str: """ Computes a digest for the dataset. Called if the user doesn't supply a digest when constructing the dataset. """ df = next( self._ds.to_pandas( batch_size=_MAX_ROWS_FOR_DIGEST_COMPUTATION_AND_SCHEMA_INFERENCE, batc...
Computes a digest for the dataset. Called if the user doesn't supply a digest when constructing the dataset.
_compute_digest
python
mlflow/mlflow
mlflow/data/huggingface_dataset.py
https://github.com/mlflow/mlflow/blob/master/mlflow/data/huggingface_dataset.py
Apache-2.0
def to_dict(self) -> dict[str, str]: """Create config dictionary for the dataset. Returns a string dictionary containing the following fields: name, digest, source, source type, schema, and profile. """ schema = json.dumps({"mlflow_colspec": self.schema.to_dict()}) if self.schem...
Create config dictionary for the dataset. Returns a string dictionary containing the following fields: name, digest, source, source type, schema, and profile.
to_dict
python
mlflow/mlflow
mlflow/data/huggingface_dataset.py
https://github.com/mlflow/mlflow/blob/master/mlflow/data/huggingface_dataset.py
Apache-2.0
def profile(self) -> Optional[Any]: """ Summary statistics for the Hugging Face dataset, including the number of rows, size, and size in bytes. """ return { "num_rows": self._ds.num_rows, "dataset_size": self._ds.dataset_size, "size_in_bytes": ...
Summary statistics for the Hugging Face dataset, including the number of rows, size, and size in bytes.
profile
python
mlflow/mlflow
mlflow/data/huggingface_dataset.py
https://github.com/mlflow/mlflow/blob/master/mlflow/data/huggingface_dataset.py
Apache-2.0
def schema(self) -> Optional[Schema]: """ The MLflow ColSpec schema of the Hugging Face dataset. """ try: df = next( self._ds.to_pandas( batch_size=_MAX_ROWS_FOR_DIGEST_COMPUTATION_AND_SCHEMA_INFERENCE, batched=True ) ...
The MLflow ColSpec schema of the Hugging Face dataset.
schema
python
mlflow/mlflow
mlflow/data/huggingface_dataset.py
https://github.com/mlflow/mlflow/blob/master/mlflow/data/huggingface_dataset.py
Apache-2.0
def to_evaluation_dataset(self, path=None, feature_names=None) -> EvaluationDataset: """ Converts the dataset to an EvaluationDataset for model evaluation. Required for use with mlflow.evaluate(). """ return EvaluationDataset( data=self._ds.to_pandas(), ta...
Converts the dataset to an EvaluationDataset for model evaluation. Required for use with mlflow.evaluate().
to_evaluation_dataset
python
mlflow/mlflow
mlflow/data/huggingface_dataset.py
https://github.com/mlflow/mlflow/blob/master/mlflow/data/huggingface_dataset.py
Apache-2.0
def from_huggingface( ds, path: Optional[str] = None, targets: Optional[str] = None, data_dir: Optional[str] = None, data_files: Optional[Union[str, Sequence[str], Mapping[str, Union[str, Sequence[str]]]]] = None, revision=None, name: Optional[str] = None, digest: Optional[str] = None, ...
Create a `mlflow.data.huggingface_dataset.HuggingFaceDataset` from a Hugging Face dataset. Args: ds: A Hugging Face dataset. Must be an instance of `datasets.Dataset`. Other types, such as `datasets.DatasetDict`, are not supported. path: The path of the Hugging Face dat...
from_huggingface
python
mlflow/mlflow
mlflow/data/huggingface_dataset.py
https://github.com/mlflow/mlflow/blob/master/mlflow/data/huggingface_dataset.py
Apache-2.0
def __init__( self, path: str, config_name: Optional[str] = None, data_dir: Optional[str] = None, data_files: Optional[ Union[str, Sequence[str], Mapping[str, Union[str, Sequence[str]]]] ] = None, split: Optional[Union[str, "datasets.Split"]] = None, ...
Create a `HuggingFaceDatasetSource` instance. Arguments in `__init__` match arguments of the same name in `datasets.load_dataset() <https://huggingface.co/docs/datasets/v2.14.5/en/package_reference/loading_methods#datasets.load_dataset>`_. The only exception is `config_name` matches `name` in `...
__init__
python
mlflow/mlflow
mlflow/data/huggingface_dataset_source.py
https://github.com/mlflow/mlflow/blob/master/mlflow/data/huggingface_dataset_source.py
Apache-2.0
def load(self, **kwargs): """Load the Hugging Face dataset based on `HuggingFaceDatasetSource`. Args: kwargs: Additional keyword arguments used for loading the dataset with the Hugging Face `datasets.load_dataset()` method. Returns: An instance of `datas...
Load the Hugging Face dataset based on `HuggingFaceDatasetSource`. Args: kwargs: Additional keyword arguments used for loading the dataset with the Hugging Face `datasets.load_dataset()` method. Returns: An instance of `datasets.Dataset`.
load
python
mlflow/mlflow
mlflow/data/huggingface_dataset_source.py
https://github.com/mlflow/mlflow/blob/master/mlflow/data/huggingface_dataset_source.py
Apache-2.0
def _compute_digest(self) -> str: """Computes a digest for the dataset. The digest computation of `MetaDataset` is based on the dataset's name, source, source type, and schema instead of the actual data. Basically we compute the sha256 hash of the config dict. """ config...
Computes a digest for the dataset. The digest computation of `MetaDataset` is based on the dataset's name, source, source type, and schema instead of the actual data. Basically we compute the sha256 hash of the config dict.
_compute_digest
python
mlflow/mlflow
mlflow/data/meta_dataset.py
https://github.com/mlflow/mlflow/blob/master/mlflow/data/meta_dataset.py
Apache-2.0
def to_dict(self) -> dict[str, str]: """Create config dictionary for the MetaDataset. Returns a string dictionary containing the following fields: name, digest, source, source type, schema, and profile. """ config = super().to_dict() if self.schema: schema = ...
Create config dictionary for the MetaDataset. Returns a string dictionary containing the following fields: name, digest, source, source type, schema, and profile.
to_dict
python
mlflow/mlflow
mlflow/data/meta_dataset.py
https://github.com/mlflow/mlflow/blob/master/mlflow/data/meta_dataset.py
Apache-2.0
def __init__( self, features: Union[np.ndarray, dict[str, np.ndarray]], source: DatasetSource, targets: Union[np.ndarray, dict[str, np.ndarray]] = None, name: Optional[str] = None, digest: Optional[str] = None, ): """ Args: features: A nump...
Args: features: A numpy array or dictionary of numpy arrays containing dataset features. source: The source of the numpy dataset. targets: A numpy array or dictionary of numpy arrays containing dataset targets. Optional. name: The name of the data...
__init__
python
mlflow/mlflow
mlflow/data/numpy_dataset.py
https://github.com/mlflow/mlflow/blob/master/mlflow/data/numpy_dataset.py
Apache-2.0
def profile(self) -> Optional[Any]: """ A profile of the dataset. May be ``None`` if a profile cannot be computed. """ def get_profile_attribute(numpy_data, attr_name): if isinstance(numpy_data, dict): return {key: getattr(array, attr_name) for key, array in ...
A profile of the dataset. May be ``None`` if a profile cannot be computed.
profile
python
mlflow/mlflow
mlflow/data/numpy_dataset.py
https://github.com/mlflow/mlflow/blob/master/mlflow/data/numpy_dataset.py
Apache-2.0
def schema(self) -> Optional[TensorDatasetSchema]: """ MLflow TensorSpec schema representing the dataset features and targets (optional). """ try: features_schema = _infer_schema(self._features) targets_schema = None if self._targets is not None: ...
MLflow TensorSpec schema representing the dataset features and targets (optional).
schema
python
mlflow/mlflow
mlflow/data/numpy_dataset.py
https://github.com/mlflow/mlflow/blob/master/mlflow/data/numpy_dataset.py
Apache-2.0
def to_evaluation_dataset(self, path=None, feature_names=None) -> EvaluationDataset: """ Converts the dataset to an EvaluationDataset for model evaluation. Required for use with mlflow.sklearn.evaluate(). """ return EvaluationDataset( data=self._features, ...
Converts the dataset to an EvaluationDataset for model evaluation. Required for use with mlflow.sklearn.evaluate().
to_evaluation_dataset
python
mlflow/mlflow
mlflow/data/numpy_dataset.py
https://github.com/mlflow/mlflow/blob/master/mlflow/data/numpy_dataset.py
Apache-2.0
def from_numpy( features: Union[np.ndarray, dict[str, np.ndarray]], source: Union[str, DatasetSource] = None, targets: Union[np.ndarray, dict[str, np.ndarray]] = None, name: Optional[str] = None, digest: Optional[str] = None, ) -> NumpyDataset: """ Constructs a :py:class:`NumpyDataset <mlflo...
Constructs a :py:class:`NumpyDataset <mlflow.data.numpy_dataset.NumpyDataset>` object from NumPy features, optional targets, and source. If the source is path like, then this will construct a DatasetSource object from the source path. Otherwise, the source is assumed to be a DatasetSource object. ...
from_numpy
python
mlflow/mlflow
mlflow/data/numpy_dataset.py
https://github.com/mlflow/mlflow/blob/master/mlflow/data/numpy_dataset.py
Apache-2.0
def __init__( self, df: pd.DataFrame, source: DatasetSource, targets: Optional[str] = None, name: Optional[str] = None, digest: Optional[str] = None, predictions: Optional[str] = None, ): """ Args: df: A pandas DataFrame. ...
Args: df: A pandas DataFrame. source: The source of the pandas DataFrame. targets: The name of the target column. Optional. name: The name of the dataset. E.g. "wiki_train". If unspecified, a name is automatically generated. digest: Th...
__init__
python
mlflow/mlflow
mlflow/data/pandas_dataset.py
https://github.com/mlflow/mlflow/blob/master/mlflow/data/pandas_dataset.py
Apache-2.0
def schema(self) -> Optional[Schema]: """ An instance of :py:class:`mlflow.types.Schema` representing the tabular dataset. May be ``None`` if the schema cannot be inferred from the dataset. """ try: return _infer_schema(self._df) except Exception as e: ...
An instance of :py:class:`mlflow.types.Schema` representing the tabular dataset. May be ``None`` if the schema cannot be inferred from the dataset.
schema
python
mlflow/mlflow
mlflow/data/pandas_dataset.py
https://github.com/mlflow/mlflow/blob/master/mlflow/data/pandas_dataset.py
Apache-2.0
def to_pyfunc(self) -> PyFuncInputsOutputs: """ Converts the dataset to a collection of pyfunc inputs and outputs for model evaluation. Required for use with mlflow.evaluate(). """ if self._targets: inputs = self._df.drop(columns=[self._targets]) outputs =...
Converts the dataset to a collection of pyfunc inputs and outputs for model evaluation. Required for use with mlflow.evaluate().
to_pyfunc
python
mlflow/mlflow
mlflow/data/pandas_dataset.py
https://github.com/mlflow/mlflow/blob/master/mlflow/data/pandas_dataset.py
Apache-2.0
def from_pandas( df: pd.DataFrame, source: Union[str, DatasetSource] = None, targets: Optional[str] = None, name: Optional[str] = None, digest: Optional[str] = None, predictions: Optional[str] = None, ) -> PandasDataset: """ Constructs a :py:class:`PandasDataset <mlflow.data.pandas_datas...
Constructs a :py:class:`PandasDataset <mlflow.data.pandas_dataset.PandasDataset>` instance from a Pandas DataFrame, optional targets, optional predictions, and source. Args: df: A Pandas DataFrame. source: The source from which the DataFrame was derived, e.g. a filesystem path,...
from_pandas
python
mlflow/mlflow
mlflow/data/pandas_dataset.py
https://github.com/mlflow/mlflow/blob/master/mlflow/data/pandas_dataset.py
Apache-2.0
def to_pyfunc(self) -> PyFuncInputsOutputs: """ Converts the dataset to a collection of pyfunc inputs and outputs for model evaluation. Required for use with mlflow.evaluate(). May not be implemented by all datasets. """
Converts the dataset to a collection of pyfunc inputs and outputs for model evaluation. Required for use with mlflow.evaluate(). May not be implemented by all datasets.
to_pyfunc
python
mlflow/mlflow
mlflow/data/pyfunc_dataset_mixin.py
https://github.com/mlflow/mlflow/blob/master/mlflow/data/pyfunc_dataset_mixin.py
Apache-2.0
def to_evaluation_dataset(self, path=None, feature_names=None) -> EvaluationDataset: """ Converts the dataset to an EvaluationDataset for model evaluation. May not be implemented by all datasets. """
Converts the dataset to an EvaluationDataset for model evaluation. May not be implemented by all datasets.
to_evaluation_dataset
python
mlflow/mlflow
mlflow/data/pyfunc_dataset_mixin.py
https://github.com/mlflow/mlflow/blob/master/mlflow/data/pyfunc_dataset_mixin.py
Apache-2.0
def to_dict(self) -> dict[str, Any]: """Serialize into a 'jsonable' dictionary. Returns: dictionary representation of the schema's features and targets (if defined). """ return { "mlflow_tensorspec": { "features": self.features.to_json(), ...
Serialize into a 'jsonable' dictionary. Returns: dictionary representation of the schema's features and targets (if defined).
to_dict
python
mlflow/mlflow
mlflow/data/schema.py
https://github.com/mlflow/mlflow/blob/master/mlflow/data/schema.py
Apache-2.0
def from_dict(cls, schema_dict: dict[str, Any]): """Deserialize from dictionary representation. Args: schema_dict: Dictionary representation of model signature. Expected dictionary format: `{'features': <json string>, 'targets': <json string>" }` Returns: ...
Deserialize from dictionary representation. Args: schema_dict: Dictionary representation of model signature. Expected dictionary format: `{'features': <json string>, 'targets': <json string>" }` Returns: TensorDatasetSchema populated with the data from the dicti...
from_dict
python
mlflow/mlflow
mlflow/data/schema.py
https://github.com/mlflow/mlflow/blob/master/mlflow/data/schema.py
Apache-2.0
def profile(self) -> Optional[Any]: """ A profile of the dataset. May be None if no profile is available. """ try: from pyspark.rdd import BoundedFloat # Use Spark RDD countApprox to get approximate count since count() may be expensive. # Note that we...
A profile of the dataset. May be None if no profile is available.
profile
python
mlflow/mlflow
mlflow/data/spark_dataset.py
https://github.com/mlflow/mlflow/blob/master/mlflow/data/spark_dataset.py
Apache-2.0
def schema(self) -> Optional[Schema]: """ The MLflow ColSpec schema of the Spark dataset. """ try: return _infer_schema(self._df) except Exception as e: _logger.warning("Failed to infer schema for Spark dataset. Exception: %s", e) return None
The MLflow ColSpec schema of the Spark dataset.
schema
python
mlflow/mlflow
mlflow/data/spark_dataset.py
https://github.com/mlflow/mlflow/blob/master/mlflow/data/spark_dataset.py
Apache-2.0
def to_pyfunc(self) -> PyFuncInputsOutputs: """ Converts the Spark DataFrame to pandas and splits the resulting :py:class:`pandas.DataFrame` into: 1. a :py:class:`pandas.DataFrame` of features and 2. a :py:class:`pandas.Series` of targets. To avoid overuse of driver memory, only...
Converts the Spark DataFrame to pandas and splits the resulting :py:class:`pandas.DataFrame` into: 1. a :py:class:`pandas.DataFrame` of features and 2. a :py:class:`pandas.Series` of targets. To avoid overuse of driver memory, only the first 10,000 DataFrame rows are selected.
to_pyfunc
python
mlflow/mlflow
mlflow/data/spark_dataset.py
https://github.com/mlflow/mlflow/blob/master/mlflow/data/spark_dataset.py
Apache-2.0
def load_delta( path: Optional[str] = None, table_name: Optional[str] = None, version: Optional[str] = None, targets: Optional[str] = None, name: Optional[str] = None, digest: Optional[str] = None, ) -> SparkDataset: """ Loads a :py:class:`SparkDataset <mlflow.data.spark_dataset.SparkDat...
Loads a :py:class:`SparkDataset <mlflow.data.spark_dataset.SparkDataset>` from a Delta table for use with MLflow Tracking. Args: path: The path to the Delta table. Either ``path`` or ``table_name`` must be specified. table_name: The name of the Delta table. Either ``path`` or ``table_name`...
load_delta
python
mlflow/mlflow
mlflow/data/spark_dataset.py
https://github.com/mlflow/mlflow/blob/master/mlflow/data/spark_dataset.py
Apache-2.0
def from_spark( df: "pyspark.sql.DataFrame", path: Optional[str] = None, table_name: Optional[str] = None, version: Optional[str] = None, sql: Optional[str] = None, targets: Optional[str] = None, name: Optional[str] = None, digest: Optional[str] = None, predictions: Optional[str] = N...
Given a Spark DataFrame, constructs a :py:class:`SparkDataset <mlflow.data.spark_dataset.SparkDataset>` object for use with MLflow Tracking. Args: df: The Spark DataFrame from which to construct a SparkDataset. path: The path of the Spark or Delta source that the DataFrame originally c...
from_spark
python
mlflow/mlflow
mlflow/data/spark_dataset.py
https://github.com/mlflow/mlflow/blob/master/mlflow/data/spark_dataset.py
Apache-2.0
def load(self, **kwargs): """Loads the dataset source as a Spark Dataset Source. Returns: An instance of ``pyspark.sql.DataFrame``. """ from pyspark.sql import SparkSession spark = SparkSession.builder.getOrCreate() if self._path: return spark....
Loads the dataset source as a Spark Dataset Source. Returns: An instance of ``pyspark.sql.DataFrame``.
load
python
mlflow/mlflow
mlflow/data/spark_dataset_source.py
https://github.com/mlflow/mlflow/blob/master/mlflow/data/spark_dataset_source.py
Apache-2.0
def _is_delta_table(table_name: str) -> bool: """Checks if a Delta table exists with the specified table name. Returns: True if a Delta table exists with the specified table name. False otherwise. """ from pyspark.sql import SparkSession from pyspark.sql.utils import AnalysisException ...
Checks if a Delta table exists with the specified table name. Returns: True if a Delta table exists with the specified table name. False otherwise.
_is_delta_table
python
mlflow/mlflow
mlflow/data/spark_delta_utils.py
https://github.com/mlflow/mlflow/blob/master/mlflow/data/spark_delta_utils.py
Apache-2.0
def _is_delta_table_path(path: str) -> bool: """Checks if the specified filesystem path is a Delta table. Returns: True if the specified path is a Delta table. False otherwise. """ if os.path.exists(path) and os.path.isdir(path) and "_delta_log" in os.listdir(path): return True from...
Checks if the specified filesystem path is a Delta table. Returns: True if the specified path is a Delta table. False otherwise.
_is_delta_table_path
python
mlflow/mlflow
mlflow/data/spark_delta_utils.py
https://github.com/mlflow/mlflow/blob/master/mlflow/data/spark_delta_utils.py
Apache-2.0
def _try_get_delta_table_latest_version_from_path(path: str) -> Optional[int]: """Gets the latest version of the Delta table located at the specified path. Args: path: The path to the Delta table. Returns: The version of the Delta table, or None if it cannot be resolved (e.g. because the ...
Gets the latest version of the Delta table located at the specified path. Args: path: The path to the Delta table. Returns: The version of the Delta table, or None if it cannot be resolved (e.g. because the Delta core library is not installed or the specified path does not refer to a D...
_try_get_delta_table_latest_version_from_path
python
mlflow/mlflow
mlflow/data/spark_delta_utils.py
https://github.com/mlflow/mlflow/blob/master/mlflow/data/spark_delta_utils.py
Apache-2.0
def _try_get_delta_table_latest_version_from_table_name(table_name: str) -> Optional[int]: """Gets the latest version of the Delta table with the specified name. Args: table_name: The name of the Delta table. Returns: The version of the Delta table, or None if it cannot be resolved (e.g. b...
Gets the latest version of the Delta table with the specified name. Args: table_name: The name of the Delta table. Returns: The version of the Delta table, or None if it cannot be resolved (e.g. because the Delta core library is not installed or no such table exists).
_try_get_delta_table_latest_version_from_table_name
python
mlflow/mlflow
mlflow/data/spark_delta_utils.py
https://github.com/mlflow/mlflow/blob/master/mlflow/data/spark_delta_utils.py
Apache-2.0
def _get_delta_table_latest_version(j_delta_table) -> int: """Obtains the latest version of the specified Delta table Java class. Args: j_delta_table: A Java DeltaTable class instance. Returns: The version of the Delta table. """ latest_commit_jdf = j_delta_table.history(1) la...
Obtains the latest version of the specified Delta table Java class. Args: j_delta_table: A Java DeltaTable class instance. Returns: The version of the Delta table.
_get_delta_table_latest_version
python
mlflow/mlflow
mlflow/data/spark_delta_utils.py
https://github.com/mlflow/mlflow/blob/master/mlflow/data/spark_delta_utils.py
Apache-2.0
def __init__( self, features, source: DatasetSource, targets=None, name: Optional[str] = None, digest: Optional[str] = None, ): """ Args: features: A TensorFlow dataset or tensor of features. source: The source of the TensorFlow...
Args: features: A TensorFlow dataset or tensor of features. source: The source of the TensorFlow dataset. targets: A TensorFlow dataset or tensor of targets. Optional. name: The name of the dataset. E.g. "wiki_train". If unspecified, a name is aut...
__init__
python
mlflow/mlflow
mlflow/data/tensorflow_dataset.py
https://github.com/mlflow/mlflow/blob/master/mlflow/data/tensorflow_dataset.py
Apache-2.0
def _compute_tensorflow_dataset_digest( # noqa: D417 self, dataset, targets=None, ) -> str: """Computes a digest for the given Tensorflow dataset. Args: dataset: A Tensorflow dataset. Returns: A string digest. """ import pand...
Computes a digest for the given Tensorflow dataset. Args: dataset: A Tensorflow dataset. Returns: A string digest.
_compute_tensorflow_dataset_digest
python
mlflow/mlflow
mlflow/data/tensorflow_dataset.py
https://github.com/mlflow/mlflow/blob/master/mlflow/data/tensorflow_dataset.py
Apache-2.0
def _compute_tensor_digest( self, tensor_data, tensor_targets, ) -> str: """Computes a digest for the given Tensorflow tensor. Args: tensor_data: A Tensorflow tensor, representing the features. tensor_targets: A Tensorflow tensor, representing the tar...
Computes a digest for the given Tensorflow tensor. Args: tensor_data: A Tensorflow tensor, representing the features. tensor_targets: A Tensorflow tensor, representing the targets. Optional. Returns: A string digest.
_compute_tensor_digest
python
mlflow/mlflow
mlflow/data/tensorflow_dataset.py
https://github.com/mlflow/mlflow/blob/master/mlflow/data/tensorflow_dataset.py
Apache-2.0
def schema(self) -> Optional[TensorDatasetSchema]: """ An MLflow TensorSpec schema representing the tensor dataset """ try: features_schema = TensorFlowDataset._get_tf_object_schema(self._features) targets_schema = None if self._targets is not None: ...
An MLflow TensorSpec schema representing the tensor dataset
schema
python
mlflow/mlflow
mlflow/data/tensorflow_dataset.py
https://github.com/mlflow/mlflow/blob/master/mlflow/data/tensorflow_dataset.py
Apache-2.0
def to_evaluation_dataset(self, path=None, feature_names=None) -> EvaluationDataset: """ Converts the dataset to an EvaluationDataset for model evaluation. Only supported if the dataset is a Tensor. Required for use with mlflow.evaluate(). """ import tensorflow as tf # c...
Converts the dataset to an EvaluationDataset for model evaluation. Only supported if the dataset is a Tensor. Required for use with mlflow.evaluate().
to_evaluation_dataset
python
mlflow/mlflow
mlflow/data/tensorflow_dataset.py
https://github.com/mlflow/mlflow/blob/master/mlflow/data/tensorflow_dataset.py
Apache-2.0
def from_tensorflow( features, source: Optional[Union[str, DatasetSource]] = None, targets=None, name: Optional[str] = None, digest: Optional[str] = None, ) -> TensorFlowDataset: """Constructs a TensorFlowDataset object from TensorFlow data, optional targets, and source. If the source is pa...
Constructs a TensorFlowDataset object from TensorFlow data, optional targets, and source. If the source is path like, then this will construct a DatasetSource object from the source path. Otherwise, the source is assumed to be a DatasetSource object. Args: features: A TensorFlow dataset or tensor ...
from_tensorflow
python
mlflow/mlflow
mlflow/data/tensorflow_dataset.py
https://github.com/mlflow/mlflow/blob/master/mlflow/data/tensorflow_dataset.py
Apache-2.0
def _verify_uc_path_is_valid(self): """Verify if the path exists in Databricks Unified Catalog.""" try: from databricks.sdk import WorkspaceClient w = WorkspaceClient() except ImportError: _logger.warning( "Cannot verify the path of `UCVolumeD...
Verify if the path exists in Databricks Unified Catalog.
_verify_uc_path_is_valid
python
mlflow/mlflow
mlflow/data/uc_volume_dataset_source.py
https://github.com/mlflow/mlflow/blob/master/mlflow/data/uc_volume_dataset_source.py
Apache-2.0
def get_source(dataset: Union[DatasetEntity, DatasetInput, Dataset]) -> DatasetSource: """Obtains the source of the specified dataset or dataset input. Args: dataset: An instance of :py:class:`mlflow.data.dataset.Dataset <mlflow.data.dataset.Dataset>`, :py:class:`mlflow.entities...
Obtains the source of the specified dataset or dataset input. Args: dataset: An instance of :py:class:`mlflow.data.dataset.Dataset <mlflow.data.dataset.Dataset>`, :py:class:`mlflow.entities.Dataset`, or :py:class:`mlflow.entities.DatasetInput`. Returns: An instance of :...
get_source
python
mlflow/mlflow
mlflow/data/__init__.py
https://github.com/mlflow/mlflow/blob/master/mlflow/data/__init__.py
Apache-2.0
def run_local(target, name, model_uri, flavor=None, config=None): """Deploys the specified model locally, for testing. This function should be defined within the plugin module. Also note that this function has a signature which is very similar to :py:meth:`BaseDeploymentClient.create_deployment` since both ...
Deploys the specified model locally, for testing. This function should be defined within the plugin module. Also note that this function has a signature which is very similar to :py:meth:`BaseDeploymentClient.create_deployment` since both does logically similar operation. .. Note:: This functio...
run_local
python
mlflow/mlflow
mlflow/deployments/base.py
https://github.com/mlflow/mlflow/blob/master/mlflow/deployments/base.py
Apache-2.0
def target_help(): """ .. Note:: This function is kept here only for documentation purpose and not implementing the actual feature. It should be implemented in the plugin's top level namescope and should be callable with ``plugin_module.target_help`` Return a string containing detai...
.. Note:: This function is kept here only for documentation purpose and not implementing the actual feature. It should be implemented in the plugin's top level namescope and should be callable with ``plugin_module.target_help`` Return a string containing detailed documentation on the c...
target_help
python
mlflow/mlflow
mlflow/deployments/base.py
https://github.com/mlflow/mlflow/blob/master/mlflow/deployments/base.py
Apache-2.0
def create_deployment(self, name, model_uri, flavor=None, config=None, endpoint=None): """ Deploy a model to the specified target. By default, this method should block until deployment completes (i.e. until it's possible to perform inference with the deployment). In the case of conflicts...
Deploy a model to the specified target. By default, this method should block until deployment completes (i.e. until it's possible to perform inference with the deployment). In the case of conflicts (e.g. if it's not possible to create the specified deployment without due to conflict wit...
create_deployment
python
mlflow/mlflow
mlflow/deployments/base.py
https://github.com/mlflow/mlflow/blob/master/mlflow/deployments/base.py
Apache-2.0
def update_deployment(self, name, model_uri=None, flavor=None, config=None, endpoint=None): """ Update the deployment with the specified name. You can update the URI of the model, the flavor of the deployed model (in which case the model URI must also be specified), and/or any target-spe...
Update the deployment with the specified name. You can update the URI of the model, the flavor of the deployed model (in which case the model URI must also be specified), and/or any target-specific attributes of the deployment (via `config`). By default, this method should block until d...
update_deployment
python
mlflow/mlflow
mlflow/deployments/base.py
https://github.com/mlflow/mlflow/blob/master/mlflow/deployments/base.py
Apache-2.0
def delete_deployment(self, name, config=None, endpoint=None): """Delete the deployment with name ``name`` from the specified target. Deletion should be idempotent (i.e. deletion should not fail if retried on a non-existent deployment). Args: name: Name of deployment to del...
Delete the deployment with name ``name`` from the specified target. Deletion should be idempotent (i.e. deletion should not fail if retried on a non-existent deployment). Args: name: Name of deployment to delete config: (optional) dict containing updated target-specific...
delete_deployment
python
mlflow/mlflow
mlflow/deployments/base.py
https://github.com/mlflow/mlflow/blob/master/mlflow/deployments/base.py
Apache-2.0
def list_deployments(self, endpoint=None): """List deployments. This method is expected to return an unpaginated list of all deployments (an alternative would be to return a dict with a 'deployments' field containing the actual deployments, with plugins able to specify other fields, e.g...
List deployments. This method is expected to return an unpaginated list of all deployments (an alternative would be to return a dict with a 'deployments' field containing the actual deployments, with plugins able to specify other fields, e.g. a next_page_token field, in the returned dic...
list_deployments
python
mlflow/mlflow
mlflow/deployments/base.py
https://github.com/mlflow/mlflow/blob/master/mlflow/deployments/base.py
Apache-2.0
def get_deployment(self, name, endpoint=None): """ Returns a dictionary describing the specified deployment, throwing either a :py:class:`mlflow.exceptions.MlflowException` or an `HTTPError` for remote deployments if no deployment exists with the provided ID. The dict is guarante...
Returns a dictionary describing the specified deployment, throwing either a :py:class:`mlflow.exceptions.MlflowException` or an `HTTPError` for remote deployments if no deployment exists with the provided ID. The dict is guaranteed to contain an 'name' key containing the deployment name...
get_deployment
python
mlflow/mlflow
mlflow/deployments/base.py
https://github.com/mlflow/mlflow/blob/master/mlflow/deployments/base.py
Apache-2.0
def predict(self, deployment_name=None, inputs=None, endpoint=None): """Compute predictions on inputs using the specified deployment or model endpoint. Note that the input/output types of this method match those of `mlflow pyfunc predict`. Args: deployment_name: Name of deployment ...
Compute predictions on inputs using the specified deployment or model endpoint. Note that the input/output types of this method match those of `mlflow pyfunc predict`. Args: deployment_name: Name of deployment to predict against. inputs: Input data (or arguments) to pass to the...
predict
python
mlflow/mlflow
mlflow/deployments/base.py
https://github.com/mlflow/mlflow/blob/master/mlflow/deployments/base.py
Apache-2.0
def explain(self, deployment_name=None, df=None, endpoint=None): """ Generate explanations of model predictions on the specified input pandas Dataframe ``df`` for the deployed model. Explanation output formats vary by deployment target, and can include details like feature importance for...
Generate explanations of model predictions on the specified input pandas Dataframe ``df`` for the deployed model. Explanation output formats vary by deployment target, and can include details like feature importance for understanding/debugging predictions. Args: deployment_...
explain
python
mlflow/mlflow
mlflow/deployments/base.py
https://github.com/mlflow/mlflow/blob/master/mlflow/deployments/base.py
Apache-2.0
def create_endpoint(self, name, config=None): """ Create an endpoint with the specified target. By default, this method should block until creation completes (i.e. until it's possible to create a deployment within the endpoint). In the case of conflicts (e.g. if it's not possible to crea...
Create an endpoint with the specified target. By default, this method should block until creation completes (i.e. until it's possible to create a deployment within the endpoint). In the case of conflicts (e.g. if it's not possible to create the specified endpoint due to conflict with an...
create_endpoint
python
mlflow/mlflow
mlflow/deployments/base.py
https://github.com/mlflow/mlflow/blob/master/mlflow/deployments/base.py
Apache-2.0
def update_endpoint(self, endpoint, config=None): """ Update the endpoint with the specified name. You can update any target-specific attributes of the endpoint (via `config`). By default, this method should block until the update completes (i.e. until it's possible to create a deploymen...
Update the endpoint with the specified name. You can update any target-specific attributes of the endpoint (via `config`). By default, this method should block until the update completes (i.e. until it's possible to create a deployment within the endpoint). See target-specific plugin do...
update_endpoint
python
mlflow/mlflow
mlflow/deployments/base.py
https://github.com/mlflow/mlflow/blob/master/mlflow/deployments/base.py
Apache-2.0
def delete_endpoint(self, endpoint): """ Delete the endpoint from the specified target. Deletion should be idempotent (i.e. deletion should not fail if retried on a non-existent deployment). Args: endpoint: Name of endpoint to delete Returns: None ...
Delete the endpoint from the specified target. Deletion should be idempotent (i.e. deletion should not fail if retried on a non-existent deployment). Args: endpoint: Name of endpoint to delete Returns: None
delete_endpoint
python
mlflow/mlflow
mlflow/deployments/base.py
https://github.com/mlflow/mlflow/blob/master/mlflow/deployments/base.py
Apache-2.0
def list_endpoints(self): """ List endpoints in the specified target. This method is expected to return an unpaginated list of all endpoints (an alternative would be to return a dict with an 'endpoints' field containing the actual endpoints, with plugins able to specify other fie...
List endpoints in the specified target. This method is expected to return an unpaginated list of all endpoints (an alternative would be to return a dict with an 'endpoints' field containing the actual endpoints, with plugins able to specify other fields, e.g. a next_page_token field, in...
list_endpoints
python
mlflow/mlflow
mlflow/deployments/base.py
https://github.com/mlflow/mlflow/blob/master/mlflow/deployments/base.py
Apache-2.0
def get_endpoint(self, endpoint): """ Returns a dictionary describing the specified endpoint, throwing a py:class:`mlflow.exception.MlflowException` or an `HTTPError` for remote deployments if no endpoint exists with the provided name. The dict is guaranteed to contain an...
Returns a dictionary describing the specified endpoint, throwing a py:class:`mlflow.exception.MlflowException` or an `HTTPError` for remote deployments if no endpoint exists with the provided name. The dict is guaranteed to contain an 'name' key containing the endpoint name. ...
get_endpoint
python
mlflow/mlflow
mlflow/deployments/base.py
https://github.com/mlflow/mlflow/blob/master/mlflow/deployments/base.py
Apache-2.0
def commands(): """ Deploy MLflow models to custom targets. Support is currently installed for the following targets: {targets}. Run `mlflow deployments help --target-name <target-name>` for more details on the supported URI format and config options for a given target. To deploy to other targets, ...
Deploy MLflow models to custom targets. Support is currently installed for the following targets: {targets}. Run `mlflow deployments help --target-name <target-name>` for more details on the supported URI format and config options for a given target. To deploy to other targets, you must first install ...
commands
python
mlflow/mlflow
mlflow/deployments/cli.py
https://github.com/mlflow/mlflow/blob/master/mlflow/deployments/cli.py
Apache-2.0
def create_deployment(flavor, model_uri, target, name, config, endpoint): """ Deploy the model at ``model_uri`` to the specified target. Additional plugin-specific arguments may also be passed to this command, via `-C key=value` """ config_dict = _user_args_to_dict(config) client = interface.ge...
Deploy the model at ``model_uri`` to the specified target. Additional plugin-specific arguments may also be passed to this command, via `-C key=value`
create_deployment
python
mlflow/mlflow
mlflow/deployments/cli.py
https://github.com/mlflow/mlflow/blob/master/mlflow/deployments/cli.py
Apache-2.0
def update_deployment(flavor, model_uri, target, name, config, endpoint): """ Update the deployment with ID `deployment_id` in the specified target. You can update the URI of the model and/or the flavor of the deployed model (in which case the model URI must also be specified). Additional plugin-sp...
Update the deployment with ID `deployment_id` in the specified target. You can update the URI of the model and/or the flavor of the deployed model (in which case the model URI must also be specified). Additional plugin-specific arguments may also be passed to this command, via `-C key=value`.
update_deployment
python
mlflow/mlflow
mlflow/deployments/cli.py
https://github.com/mlflow/mlflow/blob/master/mlflow/deployments/cli.py
Apache-2.0
def delete_deployment(target, name, config, endpoint): """ Delete the deployment with name given at `--name` from the specified target. """ client = interface.get_deploy_client(target) sig = signature(client.delete_deployment) if "config" in sig.parameters: config_dict = _user_args_to_d...
Delete the deployment with name given at `--name` from the specified target.
delete_deployment
python
mlflow/mlflow
mlflow/deployments/cli.py
https://github.com/mlflow/mlflow/blob/master/mlflow/deployments/cli.py
Apache-2.0
def list_deployment(target, endpoint): """ List the names of all model deployments in the specified target. These names can be used with the `delete`, `update`, and `get` commands. """ client = interface.get_deploy_client(target) sig = signature(client.list_deployments) if "endpoint" in sig...
List the names of all model deployments in the specified target. These names can be used with the `delete`, `update`, and `get` commands.
list_deployment
python
mlflow/mlflow
mlflow/deployments/cli.py
https://github.com/mlflow/mlflow/blob/master/mlflow/deployments/cli.py
Apache-2.0
def get_deployment(target, name, endpoint): """ Print a detailed description of the deployment with name given at ``--name`` in the specified target. """ client = interface.get_deploy_client(target) sig = signature(client.get_deployment) if "endpoint" in sig.parameters: desc = clien...
Print a detailed description of the deployment with name given at ``--name`` in the specified target.
get_deployment
python
mlflow/mlflow
mlflow/deployments/cli.py
https://github.com/mlflow/mlflow/blob/master/mlflow/deployments/cli.py
Apache-2.0
def run_local(flavor, model_uri, target, name, config): """ Deploy the model locally. This has very similar signature to ``create`` API """ config_dict = _user_args_to_dict(config) interface.run_local(target, name, model_uri, flavor, config_dict)
Deploy the model locally. This has very similar signature to ``create`` API
run_local
python
mlflow/mlflow
mlflow/deployments/cli.py
https://github.com/mlflow/mlflow/blob/master/mlflow/deployments/cli.py
Apache-2.0
def predict(target, name, input_path, output_path, endpoint): """ Predict the results for the deployed model for the given input(s) """ import pandas as pd if (name, endpoint).count(None) != 1: raise click.UsageError("Must specify exactly one of --name or --endpoint.") df = pd.read_jso...
Predict the results for the deployed model for the given input(s)
predict
python
mlflow/mlflow
mlflow/deployments/cli.py
https://github.com/mlflow/mlflow/blob/master/mlflow/deployments/cli.py
Apache-2.0
def explain(target, name, input_path, output_path, endpoint): """ Generate explanations of model predictions on the specified input for the deployed model for the given input(s). Explanation output formats vary by deployment target, and can include details like feature importance for understanding/d...
Generate explanations of model predictions on the specified input for the deployed model for the given input(s). Explanation output formats vary by deployment target, and can include details like feature importance for understanding/debugging predictions. Run `mlflow deployments help` or consult th...
explain
python
mlflow/mlflow
mlflow/deployments/cli.py
https://github.com/mlflow/mlflow/blob/master/mlflow/deployments/cli.py
Apache-2.0
def create_endpoint(target, name, config): """ Create an endpoint with the specified name at the specified target. Additional plugin-specific arguments may also be passed to this command, via `-C key=value` """ config_dict = _user_args_to_dict(config) client = interface.get_deploy_client(target...
Create an endpoint with the specified name at the specified target. Additional plugin-specific arguments may also be passed to this command, via `-C key=value`
create_endpoint
python
mlflow/mlflow
mlflow/deployments/cli.py
https://github.com/mlflow/mlflow/blob/master/mlflow/deployments/cli.py
Apache-2.0
def update_endpoint(target, endpoint, config): """ Update the specified endpoint at the specified target. Additional plugin-specific arguments may also be passed to this command, via `-C key=value` """ config_dict = _user_args_to_dict(config) client = interface.get_deploy_client(target) cli...
Update the specified endpoint at the specified target. Additional plugin-specific arguments may also be passed to this command, via `-C key=value`
update_endpoint
python
mlflow/mlflow
mlflow/deployments/cli.py
https://github.com/mlflow/mlflow/blob/master/mlflow/deployments/cli.py
Apache-2.0
def delete_endpoint(target, endpoint): """ Delete the specified endpoint at the specified target """ client = interface.get_deploy_client(target) client.delete_endpoint(endpoint) click.echo(f"\nEndpoint {endpoint} is deleted")
Delete the specified endpoint at the specified target
delete_endpoint
python
mlflow/mlflow
mlflow/deployments/cli.py
https://github.com/mlflow/mlflow/blob/master/mlflow/deployments/cli.py
Apache-2.0
def list_endpoints(target): """ List all endpoints at the specified target """ client = interface.get_deploy_client(target) ids = client.list_endpoints() click.echo(f"List of all endpoints:\n{ids}")
List all endpoints at the specified target
list_endpoints
python
mlflow/mlflow
mlflow/deployments/cli.py
https://github.com/mlflow/mlflow/blob/master/mlflow/deployments/cli.py
Apache-2.0
def get_endpoint(target, endpoint): """ Get details for the specified endpoint at the specified target """ client = interface.get_deploy_client(target) desc = client.get_endpoint(endpoint) for key, val in desc.items(): click.echo(f"{key}: {val}") click.echo("\n")
Get details for the specified endpoint at the specified target
get_endpoint
python
mlflow/mlflow
mlflow/deployments/cli.py
https://github.com/mlflow/mlflow/blob/master/mlflow/deployments/cli.py
Apache-2.0
def get_deploy_client(target_uri=None): """Returns a subclass of :py:class:`mlflow.deployments.BaseDeploymentClient` exposing standard APIs for deploying models to the specified target. See available deployment APIs by calling ``help()`` on the returned object or viewing docs for :py:class:`mlflow.deplo...
Returns a subclass of :py:class:`mlflow.deployments.BaseDeploymentClient` exposing standard APIs for deploying models to the specified target. See available deployment APIs by calling ``help()`` on the returned object or viewing docs for :py:class:`mlflow.deployments.BaseDeploymentClient`. You can also run ...
get_deploy_client
python
mlflow/mlflow
mlflow/deployments/interface.py
https://github.com/mlflow/mlflow/blob/master/mlflow/deployments/interface.py
Apache-2.0
def register(self, target_name, plugin_module): """Register a deployment client given its target name and module Args: target_name: The name of the deployment target. This name will be used by `get_deploy_client()` to retrieve a deployment client from the plug...
Register a deployment client given its target name and module Args: target_name: The name of the deployment target. This name will be used by `get_deploy_client()` to retrieve a deployment client from the plugin store. plugin_module: The module that implem...
register
python
mlflow/mlflow
mlflow/deployments/plugin_manager.py
https://github.com/mlflow/mlflow/blob/master/mlflow/deployments/plugin_manager.py
Apache-2.0
def register_entrypoints(self): """ Runs through all the packages that has the `group_name` defined as the entrypoint and register that into the registry """ for entrypoint in get_entry_points(self.group_name): self.registry[entrypoint.name] = entrypoint self....
Runs through all the packages that has the `group_name` defined as the entrypoint and register that into the registry
register_entrypoints
python
mlflow/mlflow
mlflow/deployments/plugin_manager.py
https://github.com/mlflow/mlflow/blob/master/mlflow/deployments/plugin_manager.py
Apache-2.0
def __getitem__(self, item): """Override __getitem__ so that we can directly look up plugins via dict-like syntax""" try: target_name = parse_target_uri(item) plugin_like = self.registry[target_name] except KeyError: msg = ( f'No plugin found f...
Override __getitem__ so that we can directly look up plugins via dict-like syntax
__getitem__
python
mlflow/mlflow
mlflow/deployments/plugin_manager.py
https://github.com/mlflow/mlflow/blob/master/mlflow/deployments/plugin_manager.py
Apache-2.0
def parse_target_uri(target_uri): """Parse out the deployment target from the provided target uri""" parsed = urllib.parse.urlparse(target_uri) if not parsed.scheme: if parsed.path: # uri = 'target_name' (without :/<path>) return parsed.path raise MlflowException( ...
Parse out the deployment target from the provided target uri
parse_target_uri
python
mlflow/mlflow
mlflow/deployments/utils.py
https://github.com/mlflow/mlflow/blob/master/mlflow/deployments/utils.py
Apache-2.0
def _is_valid_uri(uri: str) -> bool: """ Evaluates the basic structure of a provided uri to determine if the scheme and netloc are provided """ try: parsed = urlparse(uri) return bool(parsed.scheme and parsed.netloc) except ValueError: return False
Evaluates the basic structure of a provided uri to determine if the scheme and netloc are provided
_is_valid_uri
python
mlflow/mlflow
mlflow/deployments/utils.py
https://github.com/mlflow/mlflow/blob/master/mlflow/deployments/utils.py
Apache-2.0
def set_deployments_target(target: str): """Sets the target deployment client for MLflow deployments Args: target: The full uri of a running MLflow AI Gateway or, if running on Databricks, "databricks". """ if not _is_valid_target(target): raise MlflowException.invalid_param...
Sets the target deployment client for MLflow deployments Args: target: The full uri of a running MLflow AI Gateway or, if running on Databricks, "databricks".
set_deployments_target
python
mlflow/mlflow
mlflow/deployments/utils.py
https://github.com/mlflow/mlflow/blob/master/mlflow/deployments/utils.py
Apache-2.0
def get_deployments_target() -> str: """ Returns the currently set MLflow deployments target iff set. If the deployments target has not been set by using ``set_deployments_target``, an ``MlflowException`` is raised. """ if _deployments_target is not None: return _deployments_target e...
Returns the currently set MLflow deployments target iff set. If the deployments target has not been set by using ``set_deployments_target``, an ``MlflowException`` is raised.
get_deployments_target
python
mlflow/mlflow
mlflow/deployments/utils.py
https://github.com/mlflow/mlflow/blob/master/mlflow/deployments/utils.py
Apache-2.0
def _is_valid_target(target: str): """ Evaluates the basic structure of a provided target to determine if the scheme and netloc are provided """ if target == "databricks": return True return _is_valid_uri(target)
Evaluates the basic structure of a provided target to determine if the scheme and netloc are provided
_is_valid_target
python
mlflow/mlflow
mlflow/deployments/utils.py
https://github.com/mlflow/mlflow/blob/master/mlflow/deployments/utils.py
Apache-2.0
def get_predictions(self, predictions_format="dataframe", dtype=None): """Get the predictions returned from the MLflow Model Server in the specified format. Args: predictions_format: The format in which to return the predictions. Either ``"dataframe"`` or ``"ndarray"``. ...
Get the predictions returned from the MLflow Model Server in the specified format. Args: predictions_format: The format in which to return the predictions. Either ``"dataframe"`` or ``"ndarray"``. dtype: The NumPy datatype to which to coerce the predictions. Only used wh...
get_predictions
python
mlflow/mlflow
mlflow/deployments/__init__.py
https://github.com/mlflow/mlflow/blob/master/mlflow/deployments/__init__.py
Apache-2.0
def to_json(self, path=None): """Get the JSON representation of the MLflow Predictions Response. Args: path: If specified, the JSON representation is written to this file path. Returns: If ``path`` is unspecified, the JSON representation of the MLflow Predictions ...
Get the JSON representation of the MLflow Predictions Response. Args: path: If specified, the JSON representation is written to this file path. Returns: If ``path`` is unspecified, the JSON representation of the MLflow Predictions Response. Else, None.
to_json
python
mlflow/mlflow
mlflow/deployments/__init__.py
https://github.com/mlflow/mlflow/blob/master/mlflow/deployments/__init__.py
Apache-2.0