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 get_experiment_by_name(self, experiment_name):
"""
Specialized implementation for SQL backed store.
"""
with self.ManagedSessionMaker() as session:
stages = LifecycleStage.view_type_to_stages(ViewType.ALL)
experiment = (
session.query(SqlExperi... |
Specialized implementation for SQL backed store.
| get_experiment_by_name | python | mlflow/mlflow | mlflow/store/tracking/sqlalchemy_store.py | https://github.com/mlflow/mlflow/blob/master/mlflow/store/tracking/sqlalchemy_store.py | Apache-2.0 |
def _hard_delete_experiment(self, experiment_id):
"""
Permanently delete a experiment (metadata and metrics, tags, parameters).
This is used by the ``mlflow gc`` command line and is not intended to be used elsewhere.
"""
with self.ManagedSessionMaker() as session:
exp... |
Permanently delete a experiment (metadata and metrics, tags, parameters).
This is used by the ``mlflow gc`` command line and is not intended to be used elsewhere.
| _hard_delete_experiment | python | mlflow/mlflow | mlflow/store/tracking/sqlalchemy_store.py | https://github.com/mlflow/mlflow/blob/master/mlflow/store/tracking/sqlalchemy_store.py | Apache-2.0 |
def _get_run(self, session, run_uuid, eager=False): # noqa: D417
"""
Args:
eager: If ``True``, eagerly loads the run's summary metrics (``latest_metrics``),
params, and tags when fetching the run. If ``False``, these attributes
are not eagerly loaded and will... |
Args:
eager: If ``True``, eagerly loads the run's summary metrics (``latest_metrics``),
params, and tags when fetching the run. If ``False``, these attributes
are not eagerly loaded and will be loaded when their corresponding
object properties are acc... | _get_run | python | mlflow/mlflow | mlflow/store/tracking/sqlalchemy_store.py | https://github.com/mlflow/mlflow/blob/master/mlflow/store/tracking/sqlalchemy_store.py | Apache-2.0 |
def _get_eager_run_query_options():
"""
A list of SQLAlchemy query options that can be used to eagerly load the following
run attributes when fetching a run: ``latest_metrics``, ``params``, and ``tags``.
"""
return [
# Use a select in load rather than a joined load in... |
A list of SQLAlchemy query options that can be used to eagerly load the following
run attributes when fetching a run: ``latest_metrics``, ``params``, and ``tags``.
| _get_eager_run_query_options | python | mlflow/mlflow | mlflow/store/tracking/sqlalchemy_store.py | https://github.com/mlflow/mlflow/blob/master/mlflow/store/tracking/sqlalchemy_store.py | Apache-2.0 |
def _hard_delete_run(self, run_id):
"""
Permanently delete a run (metadata and metrics, tags, parameters).
This is used by the ``mlflow gc`` command line and is not intended to be used elsewhere.
"""
with self.ManagedSessionMaker() as session:
run = self._get_run(run_... |
Permanently delete a run (metadata and metrics, tags, parameters).
This is used by the ``mlflow gc`` command line and is not intended to be used elsewhere.
| _hard_delete_run | python | mlflow/mlflow | mlflow/store/tracking/sqlalchemy_store.py | https://github.com/mlflow/mlflow/blob/master/mlflow/store/tracking/sqlalchemy_store.py | Apache-2.0 |
def sanitize_metric_value(self, metric_value: float) -> tuple[bool, float]:
"""
Returns a tuple of two values:
- A boolean indicating whether the metric is NaN.
- The metric value, which is set to 0 if the metric is NaN.
"""
is_nan = math.isnan(metric_value)
... |
Returns a tuple of two values:
- A boolean indicating whether the metric is NaN.
- The metric value, which is set to 0 if the metric is NaN.
| sanitize_metric_value | python | mlflow/mlflow | mlflow/store/tracking/sqlalchemy_store.py | https://github.com/mlflow/mlflow/blob/master/mlflow/store/tracking/sqlalchemy_store.py | Apache-2.0 |
def _compare_metrics(metric_a, metric_b):
"""
Returns:
True if ``metric_a`` is strictly more recent than ``metric_b``, as determined
by ``step``, ``timestamp``, and ``value``. False otherwise.
"""
return (metric_a.step, metric_a.timestamp, ... |
Returns:
True if ``metric_a`` is strictly more recent than ``metric_b``, as determined
by ``step``, ``timestamp``, and ``value``. False otherwise.
| _compare_metrics | python | mlflow/mlflow | mlflow/store/tracking/sqlalchemy_store.py | https://github.com/mlflow/mlflow/blob/master/mlflow/store/tracking/sqlalchemy_store.py | Apache-2.0 |
def _overwrite_metric(new_metric, old_metric):
"""
Writes content of new_metric over old_metric. The content are `value`, `step`,
`timestamp`, and `is_nan`.
Returns:
old_metric with its content updated.
"""
old_metric.value = new_m... |
Writes content of new_metric over old_metric. The content are `value`, `step`,
`timestamp`, and `is_nan`.
Returns:
old_metric with its content updated.
| _overwrite_metric | python | mlflow/mlflow | mlflow/store/tracking/sqlalchemy_store.py | https://github.com/mlflow/mlflow/blob/master/mlflow/store/tracking/sqlalchemy_store.py | Apache-2.0 |
def get_metric_history(self, run_id, metric_key, max_results=None, page_token=None):
"""
Return all logged values for a given metric.
Args:
run_id: Unique identifier for run.
metric_key: Metric name within the run.
max_results: An indicator for paginated resu... |
Return all logged values for a given metric.
Args:
run_id: Unique identifier for run.
metric_key: Metric name within the run.
max_results: An indicator for paginated results. This functionality is not
implemented for SQLAlchemyStore and is unused in ... | get_metric_history | python | mlflow/mlflow | mlflow/store/tracking/sqlalchemy_store.py | https://github.com/mlflow/mlflow/blob/master/mlflow/store/tracking/sqlalchemy_store.py | Apache-2.0 |
def get_metric_history_bulk(self, run_ids, metric_key, max_results):
"""
Return all logged values for a given metric.
Args:
run_ids: Unique identifiers of the runs from which to fetch the metric histories for
the specified key.
metric_key: Metric name wit... |
Return all logged values for a given metric.
Args:
run_ids: Unique identifiers of the runs from which to fetch the metric histories for
the specified key.
metric_key: Metric name within the runs.
max_results: The maximum number of results to return.
... | get_metric_history_bulk | python | mlflow/mlflow | mlflow/store/tracking/sqlalchemy_store.py | https://github.com/mlflow/mlflow/blob/master/mlflow/store/tracking/sqlalchemy_store.py | Apache-2.0 |
def _search_datasets(self, experiment_ids):
"""
Return all dataset summaries associated to the given experiments.
Args:
experiment_ids: List of experiment ids to scope the search
Returns:
A List of :py:class:`SqlAlchemyStore.DatasetSummary` entities.
"""... |
Return all dataset summaries associated to the given experiments.
Args:
experiment_ids: List of experiment ids to scope the search
Returns:
A List of :py:class:`SqlAlchemyStore.DatasetSummary` entities.
| _search_datasets | python | mlflow/mlflow | mlflow/store/tracking/sqlalchemy_store.py | https://github.com/mlflow/mlflow/blob/master/mlflow/store/tracking/sqlalchemy_store.py | Apache-2.0 |
def set_tag(self, run_id, tag):
"""
Set a tag on a run.
Args:
run_id: String ID of the run.
tag: RunTag instance to log.
"""
with self.ManagedSessionMaker() as session:
tag = _validate_tag(tag.key, tag.value)
run = self._get_run(ru... |
Set a tag on a run.
Args:
run_id: String ID of the run.
tag: RunTag instance to log.
| set_tag | python | mlflow/mlflow | mlflow/store/tracking/sqlalchemy_store.py | https://github.com/mlflow/mlflow/blob/master/mlflow/store/tracking/sqlalchemy_store.py | Apache-2.0 |
def _set_tags(self, run_id, tags):
"""
Set multiple tags on a run
Args:
run_id: String ID of the run
tags: List of RunTag instances to log
path: current json path for error messages
"""
if not tags:
return
tags = [_validat... |
Set multiple tags on a run
Args:
run_id: String ID of the run
tags: List of RunTag instances to log
path: current json path for error messages
| _set_tags | python | mlflow/mlflow | mlflow/store/tracking/sqlalchemy_store.py | https://github.com/mlflow/mlflow/blob/master/mlflow/store/tracking/sqlalchemy_store.py | Apache-2.0 |
def delete_tag(self, run_id, key):
"""
Delete a tag from a run. This is irreversible.
Args:
run_id: String ID of the run
key: Name of the tag
"""
with self.ManagedSessionMaker() as session:
run = self._get_run(run_uuid=run_id, session=session)... |
Delete a tag from a run. This is irreversible.
Args:
run_id: String ID of the run
key: Name of the tag
| delete_tag | python | mlflow/mlflow | mlflow/store/tracking/sqlalchemy_store.py | https://github.com/mlflow/mlflow/blob/master/mlflow/store/tracking/sqlalchemy_store.py | Apache-2.0 |
def start_trace(
self,
experiment_id: str,
timestamp_ms: int,
request_metadata: dict[str, str],
tags: dict[str, str],
) -> TraceInfoV2:
"""
Create an initial TraceInfo object in the database.
Args:
experiment_id: String id of the experimen... |
Create an initial TraceInfo object in the database.
Args:
experiment_id: String id of the experiment for this run.
timestamp_ms: Start time of the trace, in milliseconds since the UNIX epoch.
request_metadata: Metadata of the trace.
tags: Tags of the tra... | start_trace | python | mlflow/mlflow | mlflow/store/tracking/sqlalchemy_store.py | https://github.com/mlflow/mlflow/blob/master/mlflow/store/tracking/sqlalchemy_store.py | Apache-2.0 |
def end_trace(
self,
request_id: str,
timestamp_ms: int,
status: TraceStatus,
request_metadata: dict[str, str],
tags: dict[str, str],
) -> TraceInfoV2:
"""
Update the TraceInfo object in the database with the completed trace info.
Args:
... |
Update the TraceInfo object in the database with the completed trace info.
Args:
request_id: Unique string identifier of the trace.
timestamp_ms: End time of the trace, in milliseconds. The execution time field
in the TraceInfo will be calculated by subtracting ... | end_trace | python | mlflow/mlflow | mlflow/store/tracking/sqlalchemy_store.py | https://github.com/mlflow/mlflow/blob/master/mlflow/store/tracking/sqlalchemy_store.py | Apache-2.0 |
def get_trace_info(self, request_id, should_query_v3: bool = False) -> TraceInfoV2:
"""
Fetch the trace info for the given request id.
Args:
request_id: Unique string identifier of the trace.
should_query_v3: If True, the backend store will query the V3 API for the trace... |
Fetch the trace info for the given request id.
Args:
request_id: Unique string identifier of the trace.
should_query_v3: If True, the backend store will query the V3 API for the trace info.
TODO: Remove this flag once the V3 API is the default in OSS.
R... | get_trace_info | python | mlflow/mlflow | mlflow/store/tracking/sqlalchemy_store.py | https://github.com/mlflow/mlflow/blob/master/mlflow/store/tracking/sqlalchemy_store.py | Apache-2.0 |
def search_traces(
self,
experiment_ids: list[str],
filter_string: Optional[str] = None,
max_results: int = SEARCH_TRACES_DEFAULT_MAX_RESULTS,
order_by: Optional[list[str]] = None,
page_token: Optional[str] = None,
model_id: Optional[str] = None,
sql_wareh... |
Return traces that match the given list of search expressions within the experiments.
Args:
experiment_ids: List of experiment ids to scope the search.
filter_string: A search filter string.
max_results: Maximum number of traces desired.
order_by: List o... | search_traces | python | mlflow/mlflow | mlflow/store/tracking/sqlalchemy_store.py | https://github.com/mlflow/mlflow/blob/master/mlflow/store/tracking/sqlalchemy_store.py | Apache-2.0 |
def _delete_traces(
self,
experiment_id: str,
max_timestamp_millis: Optional[int] = None,
max_traces: Optional[int] = None,
request_ids: Optional[list[str]] = None,
) -> int:
"""
Delete traces based on the specified criteria.
Args:
experim... |
Delete traces based on the specified criteria.
Args:
experiment_id: ID of the associated experiment.
max_timestamp_millis: The maximum timestamp in milliseconds since the UNIX epoch for
deleting traces. Traces older than or equal to this timestamp will be delete... | _delete_traces | python | mlflow/mlflow | mlflow/store/tracking/sqlalchemy_store.py | https://github.com/mlflow/mlflow/blob/master/mlflow/store/tracking/sqlalchemy_store.py | Apache-2.0 |
def _get_sqlalchemy_filter_clauses(parsed, session, dialect):
"""
Creates run attribute filters and subqueries that will be inner-joined to SqlRun to act as
multi-clause filters and return them as a tuple.
"""
attribute_filters = []
non_attribute_filters = []
dataset_filters = []
for sq... |
Creates run attribute filters and subqueries that will be inner-joined to SqlRun to act as
multi-clause filters and return them as a tuple.
| _get_sqlalchemy_filter_clauses | python | mlflow/mlflow | mlflow/store/tracking/sqlalchemy_store.py | https://github.com/mlflow/mlflow/blob/master/mlflow/store/tracking/sqlalchemy_store.py | Apache-2.0 |
def _get_orderby_clauses(order_by_list, session):
"""Sorts a set of runs based on their natural ordering and an overriding set of order_bys.
Runs are naturally ordered first by start time descending, then by run id for tie-breaking.
"""
clauses = []
ordering_joins = []
clause_id = 0
observe... | Sorts a set of runs based on their natural ordering and an overriding set of order_bys.
Runs are naturally ordered first by start time descending, then by run id for tie-breaking.
| _get_orderby_clauses | python | mlflow/mlflow | mlflow/store/tracking/sqlalchemy_store.py | https://github.com/mlflow/mlflow/blob/master/mlflow/store/tracking/sqlalchemy_store.py | Apache-2.0 |
def _get_orderby_clauses_for_search_traces(order_by_list: list[str], session):
"""Sorts a set of traces based on their natural ordering and an overriding set of order_bys.
Traces are ordered first by timestamp_ms descending, then by request_id for tie-breaking.
"""
clauses = []
ordering_joins = []
... | Sorts a set of traces based on their natural ordering and an overriding set of order_bys.
Traces are ordered first by timestamp_ms descending, then by request_id for tie-breaking.
| _get_orderby_clauses_for_search_traces | python | mlflow/mlflow | mlflow/store/tracking/sqlalchemy_store.py | https://github.com/mlflow/mlflow/blob/master/mlflow/store/tracking/sqlalchemy_store.py | Apache-2.0 |
def _get_filter_clauses_for_search_traces(filter_string, session, dialect):
"""
Creates trace attribute filters and subqueries that will be inner-joined
to SqlTraceInfo to act as multi-clause filters and return them as a tuple.
"""
attribute_filters = []
non_attribute_filters = []
parsed_fi... |
Creates trace attribute filters and subqueries that will be inner-joined
to SqlTraceInfo to act as multi-clause filters and return them as a tuple.
| _get_filter_clauses_for_search_traces | python | mlflow/mlflow | mlflow/store/tracking/sqlalchemy_store.py | https://github.com/mlflow/mlflow/blob/master/mlflow/store/tracking/sqlalchemy_store.py | Apache-2.0 |
def to_mlflow_entity(self):
"""
Convert DB model to corresponding MLflow entity.
Returns:
:py:class:`mlflow.entities.Experiment`.
"""
return Experiment(
experiment_id=str(self.experiment_id),
name=self.name,
artifact_location=self.... |
Convert DB model to corresponding MLflow entity.
Returns:
:py:class:`mlflow.entities.Experiment`.
| to_mlflow_entity | python | mlflow/mlflow | mlflow/store/tracking/dbmodels/models.py | https://github.com/mlflow/mlflow/blob/master/mlflow/store/tracking/dbmodels/models.py | Apache-2.0 |
def get_attribute_name(mlflow_attribute_name):
"""
Resolves an MLflow attribute name to a `SqlRun` attribute name.
"""
# Currently, MLflow Search attributes defined in `SearchUtils.VALID_SEARCH_ATTRIBUTE_KEYS`
# share the same names as their corresponding `SqlRun` attributes. The... |
Resolves an MLflow attribute name to a `SqlRun` attribute name.
| get_attribute_name | python | mlflow/mlflow | mlflow/store/tracking/dbmodels/models.py | https://github.com/mlflow/mlflow/blob/master/mlflow/store/tracking/dbmodels/models.py | Apache-2.0 |
def to_mlflow_entity(self):
"""
Convert DB model to corresponding MLflow entity.
Returns:
mlflow.entities.Run: Description of the return value.
"""
run_info = RunInfo(
run_id=self.run_uuid,
run_name=self.name,
experiment_id=str(sel... |
Convert DB model to corresponding MLflow entity.
Returns:
mlflow.entities.Run: Description of the return value.
| to_mlflow_entity | python | mlflow/mlflow | mlflow/store/tracking/dbmodels/models.py | https://github.com/mlflow/mlflow/blob/master/mlflow/store/tracking/dbmodels/models.py | Apache-2.0 |
def to_mlflow_entity(self):
"""
Convert DB model to corresponding MLflow entity.
Returns:
mlflow.entities.Metric: Description of the return value.
"""
return Metric(
key=self.key,
value=self.value if not self.is_nan else float("nan"),
... |
Convert DB model to corresponding MLflow entity.
Returns:
mlflow.entities.Metric: Description of the return value.
| to_mlflow_entity | python | mlflow/mlflow | mlflow/store/tracking/dbmodels/models.py | https://github.com/mlflow/mlflow/blob/master/mlflow/store/tracking/dbmodels/models.py | Apache-2.0 |
def to_mlflow_entity(self):
"""
Convert DB model to corresponding MLflow entity.
Returns:
mlflow.entities.Dataset.
"""
return Dataset(
name=self.name,
digest=self.digest,
source_type=self.dataset_source_type,
source=sel... |
Convert DB model to corresponding MLflow entity.
Returns:
mlflow.entities.Dataset.
| to_mlflow_entity | python | mlflow/mlflow | mlflow/store/tracking/dbmodels/models.py | https://github.com/mlflow/mlflow/blob/master/mlflow/store/tracking/dbmodels/models.py | Apache-2.0 |
def to_mlflow_entity(self):
"""
Convert DB model to corresponding MLflow entity.
Returns:
:py:class:`mlflow.entities.TraceInfo` object.
"""
return TraceInfoV2(
request_id=self.request_id,
experiment_id=str(self.experiment_id),
time... |
Convert DB model to corresponding MLflow entity.
Returns:
:py:class:`mlflow.entities.TraceInfo` object.
| to_mlflow_entity | python | mlflow/mlflow | mlflow/store/tracking/dbmodels/models.py | https://github.com/mlflow/mlflow/blob/master/mlflow/store/tracking/dbmodels/models.py | Apache-2.0 |
def __init__(
self,
name: str,
description: Optional[str] = None,
creation_timestamp: Optional[int] = None,
tags: Optional[dict[str, str]] = None,
):
"""
Construct a PromptInfo entity.
Args:
name: Name of the prompt.
descriptio... |
Construct a PromptInfo entity.
Args:
name: Name of the prompt.
description: Description of the prompt.
creation_timestamp: Timestamp when the prompt was created.
tags: Prompt-level metadata as key-value pairs.
| __init__ | python | mlflow/mlflow | mlflow/store/_unity_catalog/registry/prompt_info.py | https://github.com/mlflow/mlflow/blob/master/mlflow/store/_unity_catalog/registry/prompt_info.py | Apache-2.0 |
def get_feature_dependencies(model_dir):
"""
Gets the features which a model depends on. This functionality is only implemented on
Databricks. In OSS mlflow, the dependencies are always empty ("").
"""
model = _load_model(model_dir)
model_info = model.get_model_info()
if (
model_info... |
Gets the features which a model depends on. This functionality is only implemented on
Databricks. In OSS mlflow, the dependencies are always empty ("").
| get_feature_dependencies | python | mlflow/mlflow | mlflow/store/_unity_catalog/registry/rest_store.py | https://github.com/mlflow/mlflow/blob/master/mlflow/store/_unity_catalog/registry/rest_store.py | Apache-2.0 |
def get_model_version_dependencies(model_dir):
"""
Gets the specified dependencies for a particular model version and formats them
to be passed into CreateModelVersion.
"""
from mlflow.models.resources import ResourceType
model = _load_model(model_dir)
model_info = model.get_model_info()
... |
Gets the specified dependencies for a particular model version and formats them
to be passed into CreateModelVersion.
| get_model_version_dependencies | python | mlflow/mlflow | mlflow/store/_unity_catalog/registry/rest_store.py | https://github.com/mlflow/mlflow/blob/master/mlflow/store/_unity_catalog/registry/rest_store.py | Apache-2.0 |
def create_registered_model(self, name, tags=None, description=None, deployment_job_id=None):
"""
Create a new registered model in backend store.
Args:
name: Name of the new model. This is expected to be unique in the backend store.
tags: A list of :py:class:`mlflow.enti... |
Create a new registered model in backend store.
Args:
name: Name of the new model. This is expected to be unique in the backend store.
tags: A list of :py:class:`mlflow.entities.model_registry.RegisteredModelTag`
instances associated with this registered model.
... | create_registered_model | python | mlflow/mlflow | mlflow/store/_unity_catalog/registry/rest_store.py | https://github.com/mlflow/mlflow/blob/master/mlflow/store/_unity_catalog/registry/rest_store.py | Apache-2.0 |
def update_registered_model(self, name, description=None, deployment_job_id=None):
"""
Update description of the registered model.
Args:
name: Registered model name.
description: New description.
deployment_job_id: Optional deployment job id.
Returns... |
Update description of the registered model.
Args:
name: Registered model name.
description: New description.
deployment_job_id: Optional deployment job id.
Returns:
A single updated :py:class:`mlflow.entities.model_registry.RegisteredModel` obje... | update_registered_model | python | mlflow/mlflow | mlflow/store/_unity_catalog/registry/rest_store.py | https://github.com/mlflow/mlflow/blob/master/mlflow/store/_unity_catalog/registry/rest_store.py | Apache-2.0 |
def _finalize_model_version(self, name, version):
"""
Finalize a UC model version after its files have been written to managed storage,
updating its status from PENDING_REGISTRATION to READY
Args:
name: Registered model name
version: Model version number
... |
Finalize a UC model version after its files have been written to managed storage,
updating its status from PENDING_REGISTRATION to READY
Args:
name: Registered model name
version: Model version number
Returns:
Protobuf ModelVersion describing the fi... | _finalize_model_version | python | mlflow/mlflow | mlflow/store/_unity_catalog/registry/rest_store.py | https://github.com/mlflow/mlflow/blob/master/mlflow/store/_unity_catalog/registry/rest_store.py | Apache-2.0 |
def _get_temporary_model_version_write_credentials(self, name, version) -> TemporaryCredentials:
"""
Get temporary credentials for uploading model version files
Args:
name: Registered model name.
version: Model version number.
Returns:
mlflow.protos.... |
Get temporary credentials for uploading model version files
Args:
name: Registered model name.
version: Model version number.
Returns:
mlflow.protos.databricks_uc_registry_messages_pb2.TemporaryCredentials containing
temporary model version cred... | _get_temporary_model_version_write_credentials | python | mlflow/mlflow | mlflow/store/_unity_catalog/registry/rest_store.py | https://github.com/mlflow/mlflow/blob/master/mlflow/store/_unity_catalog/registry/rest_store.py | Apache-2.0 |
def _download_model_weights_if_not_saved(self, local_model_path):
"""
Transformers models can be saved without the base model weights by setting
`save_pretrained=False` when saving or logging the model. Such 'weight-less'
model cannot be directly deployed to model serving, so here we dow... |
Transformers models can be saved without the base model weights by setting
`save_pretrained=False` when saving or logging the model. Such 'weight-less'
model cannot be directly deployed to model serving, so here we download the
weights proactively from the HuggingFace hub and save them ... | _download_model_weights_if_not_saved | python | mlflow/mlflow | mlflow/store/_unity_catalog/registry/rest_store.py | https://github.com/mlflow/mlflow/blob/master/mlflow/store/_unity_catalog/registry/rest_store.py | Apache-2.0 |
def create_model_version(
self,
name,
source,
run_id=None,
tags=None,
run_link=None,
description=None,
local_model_path=None,
model_id: Optional[str] = None,
):
"""
Create a new model version from given source and run ID.
... |
Create a new model version from given source and run ID.
Args:
name: Registered model name.
source: URI indicating the location of the model artifacts.
run_id: Run ID from MLflow tracking server that generated the model.
tags: A list of :py:class:`mlflow... | create_model_version | python | mlflow/mlflow | mlflow/store/_unity_catalog/registry/rest_store.py | https://github.com/mlflow/mlflow/blob/master/mlflow/store/_unity_catalog/registry/rest_store.py | Apache-2.0 |
def transition_model_version_stage(self, name, version, stage, archive_existing_versions):
"""
Update model version stage.
Args:
name: Registered model name.
version: Registered model version.
stage: New desired stage for this model version.
archi... |
Update model version stage.
Args:
name: Registered model name.
version: Registered model version.
stage: New desired stage for this model version.
archive_existing_versions: If this flag is set to ``True``, all existing model
versions in ... | transition_model_version_stage | python | mlflow/mlflow | mlflow/store/_unity_catalog/registry/rest_store.py | https://github.com/mlflow/mlflow/blob/master/mlflow/store/_unity_catalog/registry/rest_store.py | Apache-2.0 |
def set_model_version_tag(self, name, version, tag):
"""
Set a tag for the model version.
Args:
name: Registered model name.
version: Registered model version.
tag: :py:class:`mlflow.entities.model_registry.ModelVersionTag` instance to log.
"""
... |
Set a tag for the model version.
Args:
name: Registered model name.
version: Registered model version.
tag: :py:class:`mlflow.entities.model_registry.ModelVersionTag` instance to log.
| set_model_version_tag | python | mlflow/mlflow | mlflow/store/_unity_catalog/registry/rest_store.py | https://github.com/mlflow/mlflow/blob/master/mlflow/store/_unity_catalog/registry/rest_store.py | Apache-2.0 |
def delete_model_version_tag(self, name, version, key):
"""
Delete a tag associated with the model version.
Args:
name: Registered model name.
version: Registered model version.
key: Tag key.
"""
full_name = get_full_name_from_sc(name, self.sp... |
Delete a tag associated with the model version.
Args:
name: Registered model name.
version: Registered model version.
key: Tag key.
| delete_model_version_tag | python | mlflow/mlflow | mlflow/store/_unity_catalog/registry/rest_store.py | https://github.com/mlflow/mlflow/blob/master/mlflow/store/_unity_catalog/registry/rest_store.py | Apache-2.0 |
def create_prompt(
self,
name: str,
description: Optional[str] = None,
tags: Optional[dict[str, str]] = None,
) -> Prompt:
"""
Create a new prompt in Unity Catalog (metadata only, no initial version).
"""
# Create a Prompt object with the provided fiel... |
Create a new prompt in Unity Catalog (metadata only, no initial version).
| create_prompt | python | mlflow/mlflow | mlflow/store/_unity_catalog/registry/rest_store.py | https://github.com/mlflow/mlflow/blob/master/mlflow/store/_unity_catalog/registry/rest_store.py | Apache-2.0 |
def search_prompts(
self,
filter_string: Optional[str] = None,
max_results: Optional[int] = None,
order_by: Optional[list[str]] = None,
page_token: Optional[str] = None,
) -> PagedList[Prompt]:
"""
Search for prompts in Unity Catalog.
Args:
... |
Search for prompts in Unity Catalog.
Args:
filter_string: Filter string that must include catalog and schema in the format:
"catalog = 'catalog_name' AND schema = 'schema_name'"
max_results: Maximum number of results to return
order_by: List of field... | search_prompts | python | mlflow/mlflow | mlflow/store/_unity_catalog/registry/rest_store.py | https://github.com/mlflow/mlflow/blob/master/mlflow/store/_unity_catalog/registry/rest_store.py | Apache-2.0 |
def _parse_catalog_schema_from_filter(
self, filter_string: Optional[str]
) -> _CatalogSchemaFilter:
"""
Parse catalog and schema from filter string for Unity Catalog using regex.
Expects filter format: "catalog = 'catalog_name' AND schema = 'schema_name'"
Args:
... |
Parse catalog and schema from filter string for Unity Catalog using regex.
Expects filter format: "catalog = 'catalog_name' AND schema = 'schema_name'"
Args:
filter_string: Filter string containing catalog and schema
Returns:
_CatalogSchemaFilter object with c... | _parse_catalog_schema_from_filter | python | mlflow/mlflow | mlflow/store/_unity_catalog/registry/rest_store.py | https://github.com/mlflow/mlflow/blob/master/mlflow/store/_unity_catalog/registry/rest_store.py | Apache-2.0 |
def set_prompt_tag(self, name: str, key: str, value: str) -> None:
"""
Set a tag on a prompt in Unity Catalog.
"""
req_body = message_to_json(SetPromptTagRequest(name=name, key=key, value=value))
endpoint, method = self._get_endpoint_from_method(SetPromptTagRequest)
self.... |
Set a tag on a prompt in Unity Catalog.
| set_prompt_tag | python | mlflow/mlflow | mlflow/store/_unity_catalog/registry/rest_store.py | https://github.com/mlflow/mlflow/blob/master/mlflow/store/_unity_catalog/registry/rest_store.py | Apache-2.0 |
def delete_prompt_tag(self, name: str, key: str) -> None:
"""
Delete a tag from a prompt in Unity Catalog.
"""
req_body = message_to_json(DeletePromptTagRequest(name=name, key=key))
endpoint, method = self._get_endpoint_from_method(DeletePromptTagRequest)
self._edit_endpo... |
Delete a tag from a prompt in Unity Catalog.
| delete_prompt_tag | python | mlflow/mlflow | mlflow/store/_unity_catalog/registry/rest_store.py | https://github.com/mlflow/mlflow/blob/master/mlflow/store/_unity_catalog/registry/rest_store.py | Apache-2.0 |
def get_prompt(self, name: str) -> Optional[Prompt]:
"""
Get prompt by name from Unity Catalog.
"""
try:
req_body = message_to_json(GetPromptRequest(name=name))
endpoint, method = self._get_endpoint_from_method(GetPromptRequest)
response_proto = self._... |
Get prompt by name from Unity Catalog.
| get_prompt | python | mlflow/mlflow | mlflow/store/_unity_catalog/registry/rest_store.py | https://github.com/mlflow/mlflow/blob/master/mlflow/store/_unity_catalog/registry/rest_store.py | Apache-2.0 |
def create_prompt_version(
self,
name: str,
template: str,
description: Optional[str] = None,
tags: Optional[dict[str, str]] = None,
) -> PromptVersion:
"""
Create a new prompt version in Unity Catalog.
"""
# Create a PromptVersion object with ... |
Create a new prompt version in Unity Catalog.
| create_prompt_version | python | mlflow/mlflow | mlflow/store/_unity_catalog/registry/rest_store.py | https://github.com/mlflow/mlflow/blob/master/mlflow/store/_unity_catalog/registry/rest_store.py | Apache-2.0 |
def get_prompt_version(self, name: str, version: Union[str, int]) -> Optional[PromptVersion]:
"""
Get a specific prompt version from Unity Catalog.
"""
try:
req_body = message_to_json(GetPromptVersionRequest(name=name, version=str(version)))
endpoint, method = sel... |
Get a specific prompt version from Unity Catalog.
| get_prompt_version | python | mlflow/mlflow | mlflow/store/_unity_catalog/registry/rest_store.py | https://github.com/mlflow/mlflow/blob/master/mlflow/store/_unity_catalog/registry/rest_store.py | Apache-2.0 |
def delete_prompt_version(self, name: str, version: Union[str, int]) -> None:
"""
Delete a prompt version from Unity Catalog.
"""
# Delete the specific version only
req_body = message_to_json(DeletePromptVersionRequest(name=name, version=str(version)))
endpoint, method = ... |
Delete a prompt version from Unity Catalog.
| delete_prompt_version | python | mlflow/mlflow | mlflow/store/_unity_catalog/registry/rest_store.py | https://github.com/mlflow/mlflow/blob/master/mlflow/store/_unity_catalog/registry/rest_store.py | Apache-2.0 |
def search_prompt_versions(
self, name: str, max_results: Optional[int] = None, page_token: Optional[str] = None
) -> SearchPromptVersionsResponse:
"""
Search prompt versions for a given prompt name in Unity Catalog.
Note: Unity Catalog server uses a non-standard endpoint pattern fo... |
Search prompt versions for a given prompt name in Unity Catalog.
Note: Unity Catalog server uses a non-standard endpoint pattern for this operation.
Args:
name: Name of the prompt to search versions for
max_results: Maximum number of versions to return
page... | search_prompt_versions | python | mlflow/mlflow | mlflow/store/_unity_catalog/registry/rest_store.py | https://github.com/mlflow/mlflow/blob/master/mlflow/store/_unity_catalog/registry/rest_store.py | Apache-2.0 |
def set_prompt_version_tag(
self, name: str, version: Union[str, int], key: str, value: str
) -> None:
"""
Set a tag on a prompt version in Unity Catalog.
"""
req_body = message_to_json(
SetPromptVersionTagRequest(name=name, version=str(version), key=key, value=va... |
Set a tag on a prompt version in Unity Catalog.
| set_prompt_version_tag | python | mlflow/mlflow | mlflow/store/_unity_catalog/registry/rest_store.py | https://github.com/mlflow/mlflow/blob/master/mlflow/store/_unity_catalog/registry/rest_store.py | Apache-2.0 |
def delete_prompt_version_tag(self, name: str, version: Union[str, int], key: str) -> None:
"""
Delete a tag from a prompt version in Unity Catalog.
"""
req_body = message_to_json(
DeletePromptVersionTagRequest(name=name, version=str(version), key=key)
)
endpo... |
Delete a tag from a prompt version in Unity Catalog.
| delete_prompt_version_tag | python | mlflow/mlflow | mlflow/store/_unity_catalog/registry/rest_store.py | https://github.com/mlflow/mlflow/blob/master/mlflow/store/_unity_catalog/registry/rest_store.py | Apache-2.0 |
def get_prompt_version_by_alias(self, name: str, alias: str) -> Optional[PromptVersion]:
"""
Get a prompt version by alias from Unity Catalog.
"""
try:
req_body = message_to_json(GetPromptVersionByAliasRequest(name=name, alias=alias))
endpoint, method = self._get_... |
Get a prompt version by alias from Unity Catalog.
| get_prompt_version_by_alias | python | mlflow/mlflow | mlflow/store/_unity_catalog/registry/rest_store.py | https://github.com/mlflow/mlflow/blob/master/mlflow/store/_unity_catalog/registry/rest_store.py | Apache-2.0 |
def set_prompt_alias(self, name: str, alias: str, version: Union[str, int]) -> None:
"""
Set an alias for a prompt version in Unity Catalog.
"""
req_body = message_to_json(
SetPromptAliasRequest(name=name, alias=alias, version=str(version))
)
endpoint, method ... |
Set an alias for a prompt version in Unity Catalog.
| set_prompt_alias | python | mlflow/mlflow | mlflow/store/_unity_catalog/registry/rest_store.py | https://github.com/mlflow/mlflow/blob/master/mlflow/store/_unity_catalog/registry/rest_store.py | Apache-2.0 |
def delete_prompt_alias(self, name: str, alias: str) -> None:
"""
Delete an alias from a prompt in Unity Catalog.
"""
req_body = message_to_json(DeletePromptAliasRequest(name=name, alias=alias))
endpoint, method = self._get_endpoint_from_method(DeletePromptAliasRequest)
s... |
Delete an alias from a prompt in Unity Catalog.
| delete_prompt_alias | python | mlflow/mlflow | mlflow/store/_unity_catalog/registry/rest_store.py | https://github.com/mlflow/mlflow/blob/master/mlflow/store/_unity_catalog/registry/rest_store.py | Apache-2.0 |
def link_prompt_version_to_model(self, name: str, version: str, model_id: str) -> None:
"""
Link a prompt version to a model in Unity Catalog.
Args:
name: Name of the prompt.
version: Version of the prompt to link.
model_id: ID of the model to link to.
... |
Link a prompt version to a model in Unity Catalog.
Args:
name: Name of the prompt.
version: Version of the prompt to link.
model_id: ID of the model to link to.
| link_prompt_version_to_model | python | mlflow/mlflow | mlflow/store/_unity_catalog/registry/rest_store.py | https://github.com/mlflow/mlflow/blob/master/mlflow/store/_unity_catalog/registry/rest_store.py | Apache-2.0 |
def link_prompts_to_trace(self, prompt_versions: list[PromptVersion], trace_id: str) -> None:
"""
Link multiple prompt versions to a trace in Unity Catalog.
Args:
prompt_versions: List of PromptVersion objects to link.
trace_id: Trace ID to link to each prompt version.
... |
Link multiple prompt versions to a trace in Unity Catalog.
Args:
prompt_versions: List of PromptVersion objects to link.
trace_id: Trace ID to link to each prompt version.
| link_prompts_to_trace | python | mlflow/mlflow | mlflow/store/_unity_catalog/registry/rest_store.py | https://github.com/mlflow/mlflow/blob/master/mlflow/store/_unity_catalog/registry/rest_store.py | Apache-2.0 |
def link_prompt_version_to_run(self, name: str, version: str, run_id: str) -> None:
"""
Link a prompt version to a run in Unity Catalog.
Args:
name: Name of the prompt.
version: Version of the prompt to link.
run_id: ID of the run to link to.
"""
... |
Link a prompt version to a run in Unity Catalog.
Args:
name: Name of the prompt.
version: Version of the prompt to link.
run_id: ID of the run to link to.
| link_prompt_version_to_run | python | mlflow/mlflow | mlflow/store/_unity_catalog/registry/rest_store.py | https://github.com/mlflow/mlflow/blob/master/mlflow/store/_unity_catalog/registry/rest_store.py | Apache-2.0 |
def _edit_endpoint_and_call(self, endpoint, method, req_body, proto_name, **kwargs):
"""
Edit endpoint URL with parameters and make the call.
Args:
endpoint: URL template with placeholders like {name}, {key}
method: HTTP method
req_body: Request body
... |
Edit endpoint URL with parameters and make the call.
Args:
endpoint: URL template with placeholders like {name}, {key}
method: HTTP method
req_body: Request body
proto_name: Protobuf message class for response
**kwargs: Parameters to substitu... | _edit_endpoint_and_call | python | mlflow/mlflow | mlflow/store/_unity_catalog/registry/rest_store.py | https://github.com/mlflow/mlflow/blob/master/mlflow/store/_unity_catalog/registry/rest_store.py | Apache-2.0 |
def create_registered_model(self, name, tags=None, description=None, deployment_job_id=None):
"""
Create a new registered model in backend store.
Args:
name: Name of the new model. This is expected to be unique in the backend store.
tags: Not supported for Unity Catalog ... |
Create a new registered model in backend store.
Args:
name: Name of the new model. This is expected to be unique in the backend store.
tags: Not supported for Unity Catalog OSS yet.
description: Description of the model.
deployment_job_id: Optional deplo... | create_registered_model | python | mlflow/mlflow | mlflow/store/_unity_catalog/registry/uc_oss_rest_store.py | https://github.com/mlflow/mlflow/blob/master/mlflow/store/_unity_catalog/registry/uc_oss_rest_store.py | Apache-2.0 |
def search_model_versions(
self, filter_string=None, max_results=None, order_by=None, page_token=None
):
"""
Search for model versions in backend that satisfy the filter criteria.
Args:
filter_string: A filter string expression. Currently supports a single filter
... |
Search for model versions in backend that satisfy the filter criteria.
Args:
filter_string: A filter string expression. Currently supports a single filter
condition either name of model like ``name = 'model_name'``
max_results: Maximum number of model versions d... | search_model_versions | python | mlflow/mlflow | mlflow/store/_unity_catalog/registry/uc_oss_rest_store.py | https://github.com/mlflow/mlflow/blob/master/mlflow/store/_unity_catalog/registry/uc_oss_rest_store.py | Apache-2.0 |
def _get_temporary_model_version_write_credentials_oss( # noqa: D417
self, model_name, catalog_name, schema_name, version
):
"""
Get temporary credentials for uploading model version files
Args:
name: Registered model name.
version: Model version number.
... |
Get temporary credentials for uploading model version files
Args:
name: Registered model name.
version: Model version number.
Returns:
mlflow.protos.unity_catalog_oss_messages_pb2.TemporaryCredentials containing
temporary model version credentia... | _get_temporary_model_version_write_credentials_oss | python | mlflow/mlflow | mlflow/store/_unity_catalog/registry/uc_oss_rest_store.py | https://github.com/mlflow/mlflow/blob/master/mlflow/store/_unity_catalog/registry/uc_oss_rest_store.py | Apache-2.0 |
def proto_version_tags_to_mlflow_tags(
proto_tags: list[ProtoPromptVersionTag],
) -> dict[str, str]:
"""Convert proto prompt version tags to MLflow tags dictionary."""
return {tag.key: tag.value for tag in proto_tags} if proto_tags else {} | Convert proto prompt version tags to MLflow tags dictionary. | proto_version_tags_to_mlflow_tags | python | mlflow/mlflow | mlflow/store/_unity_catalog/registry/utils.py | https://github.com/mlflow/mlflow/blob/master/mlflow/store/_unity_catalog/registry/utils.py | Apache-2.0 |
def proto_info_to_mlflow_prompt_info(
proto_info, # Prompt type from protobuf
prompt_tags: Optional[dict[str, str]] = None,
) -> Prompt:
"""Convert proto Prompt to MLflow PromptInfo entity.
Prompt doesn't have template or version fields.
This is used for create_prompt and search_prompts responses.... | Convert proto Prompt to MLflow PromptInfo entity.
Prompt doesn't have template or version fields.
This is used for create_prompt and search_prompts responses.
| proto_info_to_mlflow_prompt_info | python | mlflow/mlflow | mlflow/store/_unity_catalog/registry/utils.py | https://github.com/mlflow/mlflow/blob/master/mlflow/store/_unity_catalog/registry/utils.py | Apache-2.0 |
def proto_to_mlflow_prompt(
proto_version, # PromptVersion type from protobuf
) -> PromptVersion:
"""Convert proto PromptVersion to MLflow prompt entity.
PromptVersion has template and version fields.
This is used for get_prompt_version responses.
"""
# Extract version tags
version_tags = ... | Convert proto PromptVersion to MLflow prompt entity.
PromptVersion has template and version fields.
This is used for get_prompt_version responses.
| proto_to_mlflow_prompt | python | mlflow/mlflow | mlflow/store/_unity_catalog/registry/utils.py | https://github.com/mlflow/mlflow/blob/master/mlflow/store/_unity_catalog/registry/utils.py | Apache-2.0 |
def mlflow_prompt_to_proto(prompt: PromptVersion) -> ProtoPromptVersion:
"""Convert MLflow prompt entity to proto prompt version."""
proto_version = ProtoPromptVersion()
proto_version.name = prompt.name
proto_version.version = str(prompt.version)
proto_version.template = prompt.template
if promp... | Convert MLflow prompt entity to proto prompt version. | mlflow_prompt_to_proto | python | mlflow/mlflow | mlflow/store/_unity_catalog/registry/utils.py | https://github.com/mlflow/mlflow/blob/master/mlflow/store/_unity_catalog/registry/utils.py | Apache-2.0 |
def monitor(self):
"""Main monitoring loop, which consistently collect and log system metrics."""
from mlflow.tracking.fluent import get_run
while not self._shutdown_event.is_set():
for _ in range(self.samples_before_logging):
self.collect_metrics()
s... | Main monitoring loop, which consistently collect and log system metrics. | monitor | python | mlflow/mlflow | mlflow/system_metrics/system_metrics_monitor.py | https://github.com/mlflow/mlflow/blob/master/mlflow/system_metrics/system_metrics_monitor.py | Apache-2.0 |
def set_system_metrics_sampling_interval(interval):
"""Set the system metrics sampling interval.
Every `interval` seconds, the system metrics will be collected. By default `interval=10`.
"""
if interval is None:
MLFLOW_SYSTEM_METRICS_SAMPLING_INTERVAL.unset()
else:
MLFLOW_SYSTEM_MET... | Set the system metrics sampling interval.
Every `interval` seconds, the system metrics will be collected. By default `interval=10`.
| set_system_metrics_sampling_interval | python | mlflow/mlflow | mlflow/system_metrics/__init__.py | https://github.com/mlflow/mlflow/blob/master/mlflow/system_metrics/__init__.py | Apache-2.0 |
def set_system_metrics_samples_before_logging(samples):
"""Set the number of samples before logging system metrics.
Every time `samples` samples have been collected, the system metrics will be logged to mlflow.
By default `samples=1`.
"""
if samples is None:
MLFLOW_SYSTEM_METRICS_SAMPLES_BE... | Set the number of samples before logging system metrics.
Every time `samples` samples have been collected, the system metrics will be logged to mlflow.
By default `samples=1`.
| set_system_metrics_samples_before_logging | python | mlflow/mlflow | mlflow/system_metrics/__init__.py | https://github.com/mlflow/mlflow/blob/master/mlflow/system_metrics/__init__.py | Apache-2.0 |
def set_system_metrics_node_id(node_id):
"""Set the system metrics node id.
node_id is the identifier of the machine where the metrics are collected. This is useful in
multi-node (distributed training) setup.
"""
if node_id is None:
MLFLOW_SYSTEM_METRICS_NODE_ID.unset()
else:
ML... | Set the system metrics node id.
node_id is the identifier of the machine where the metrics are collected. This is useful in
multi-node (distributed training) setup.
| set_system_metrics_node_id | python | mlflow/mlflow | mlflow/system_metrics/__init__.py | https://github.com/mlflow/mlflow/blob/master/mlflow/system_metrics/__init__.py | Apache-2.0 |
def collect_metrics(self):
"""Method to collect metrics.
Subclass should implement this method to collect metrics and store in `self._metrics`.
""" | Method to collect metrics.
Subclass should implement this method to collect metrics and store in `self._metrics`.
| collect_metrics | python | mlflow/mlflow | mlflow/system_metrics/metrics/base_metrics_monitor.py | https://github.com/mlflow/mlflow/blob/master/mlflow/system_metrics/metrics/base_metrics_monitor.py | Apache-2.0 |
def aggregate_metrics(self):
"""Method to aggregate metrics.
Subclass should implement this method to aggregate the metrics and return it in a dict.
""" | Method to aggregate metrics.
Subclass should implement this method to aggregate the metrics and return it in a dict.
| aggregate_metrics | python | mlflow/mlflow | mlflow/system_metrics/metrics/base_metrics_monitor.py | https://github.com/mlflow/mlflow/blob/master/mlflow/system_metrics/metrics/base_metrics_monitor.py | Apache-2.0 |
def raise_error(func, *args, **kwargs):
"""Raise error if message containing 'error' is printed out to stdout or stderr."""
stdout = io.StringIO()
stderr = io.StringIO()
with contextlib.redirect_stdout(stdout), contextlib.redirect_stderr(stderr):
func(*args, **kwargs)
... | Raise error if message containing 'error' is printed out to stdout or stderr. | raise_error | python | mlflow/mlflow | mlflow/system_metrics/metrics/rocm_monitor.py | https://github.com/mlflow/mlflow/blob/master/mlflow/system_metrics/metrics/rocm_monitor.py | Apache-2.0 |
def _extract_input_example_from_batched_tf_dataset(
dataset: tensorflow.data.Dataset,
) -> Union[np.ndarray, dict[str, np.ndarray]]:
"""
Extracts sample feature tensors from the input dataset as numpy array.
Input Dataset's tensors must contain tuple of (features, labels) that are
used for tensorflo... |
Extracts sample feature tensors from the input dataset as numpy array.
Input Dataset's tensors must contain tuple of (features, labels) that are
used for tensorflow/keras train or fit methods
Args:
dataset: a tensorflow batched/unbatched dataset representing tuple of (features, labels)
R... | _extract_input_example_from_batched_tf_dataset | python | mlflow/mlflow | mlflow/tensorflow/autologging.py | https://github.com/mlflow/mlflow/blob/master/mlflow/tensorflow/autologging.py | Apache-2.0 |
def get_default_pip_requirements(include_cloudpickle=False):
"""
Returns
A list of default pip requirements for MLflow Models produced by this flavor.
Calls to :func:`save_model()` and :func:`log_model()` produce a pip environment
that, at minimum, contains these requirements.
"""
... |
Returns
A list of default pip requirements for MLflow Models produced by this flavor.
Calls to :func:`save_model()` and :func:`log_model()` produce a pip environment
that, at minimum, contains these requirements.
| get_default_pip_requirements | python | mlflow/mlflow | mlflow/tensorflow/__init__.py | https://github.com/mlflow/mlflow/blob/master/mlflow/tensorflow/__init__.py | Apache-2.0 |
def get_global_custom_objects():
"""
Returns:
A live reference to the global dictionary of custom objects.
"""
try:
from tensorflow.keras.saving import get_custom_objects
return get_custom_objects()
except Exception:
pass |
Returns:
A live reference to the global dictionary of custom objects.
| get_global_custom_objects | python | mlflow/mlflow | mlflow/tensorflow/__init__.py | https://github.com/mlflow/mlflow/blob/master/mlflow/tensorflow/__init__.py | Apache-2.0 |
def log_model(
model,
artifact_path: Optional[str] = None,
custom_objects=None,
conda_env=None,
code_paths=None,
signature: ModelSignature = None,
input_example: ModelInputExample = None,
registered_model_name=None,
await_registration_for=DEFAULT_AWAIT_MAX_SLEEP_SECONDS,
pip_requ... |
Log a TF2 core model (inheriting tf.Module) or a Keras model in MLflow Model format.
.. note::
If you log a Keras or TensorFlow model without a signature, inference with
:py:func:`mlflow.pyfunc.spark_udf()` will not work unless the model's pyfunc
representation accepts pandas DataFram... | log_model | python | mlflow/mlflow | mlflow/tensorflow/__init__.py | https://github.com/mlflow/mlflow/blob/master/mlflow/tensorflow/__init__.py | Apache-2.0 |
def _save_keras_custom_objects(path, custom_objects, file_name):
"""
Save custom objects dictionary to a cloudpickle file so a model can be easily loaded later.
Args:
path: An absolute path that points to the data directory within /path/to/model.
custom_objects: Keras ``custom_objects`` is ... |
Save custom objects dictionary to a cloudpickle file so a model can be easily loaded later.
Args:
path: An absolute path that points to the data directory within /path/to/model.
custom_objects: Keras ``custom_objects`` is a dictionary mapping
names (strings) to custom classes or fu... | _save_keras_custom_objects | python | mlflow/mlflow | mlflow/tensorflow/__init__.py | https://github.com/mlflow/mlflow/blob/master/mlflow/tensorflow/__init__.py | Apache-2.0 |
def save_model(
model,
path,
conda_env=None,
code_paths=None,
mlflow_model=None,
custom_objects=None,
signature: ModelSignature = None,
input_example: ModelInputExample = None,
pip_requirements=None,
extra_pip_requirements=None,
saved_model_kwargs=None,
keras_model_kwargs... |
Save a TF2 core model (inheriting tf.Module) or Keras model in MLflow Model format to a path on
the local file system.
.. note::
If you save a Keras or TensorFlow model without a signature, inference with
:py:func:`mlflow.pyfunc.spark_udf()` will not work unless the model's pyfunc
... | save_model | python | mlflow/mlflow | mlflow/tensorflow/__init__.py | https://github.com/mlflow/mlflow/blob/master/mlflow/tensorflow/__init__.py | Apache-2.0 |
def load_model(model_uri, dst_path=None, saved_model_kwargs=None, keras_model_kwargs=None):
"""
Load an MLflow model that contains the TensorFlow flavor from the specified path.
Args:
model_uri: The location, in URI format, of the MLflow model. For example:
- ``/Users/me/path/to/local/... |
Load an MLflow model that contains the TensorFlow flavor from the specified path.
Args:
model_uri: The location, in URI format, of the MLflow model. For example:
- ``/Users/me/path/to/local/model``
- ``relative/path/to/local/model``
- ``s3://my_bucket/path/to/model... | load_model | python | mlflow/mlflow | mlflow/tensorflow/__init__.py | https://github.com/mlflow/mlflow/blob/master/mlflow/tensorflow/__init__.py | Apache-2.0 |
def _load_tf1_estimator_saved_model(tf_saved_model_dir, tf_meta_graph_tags, tf_signature_def_key):
"""
Load a specified TensorFlow model consisting of a TensorFlow metagraph and signature definition
from a serialized TensorFlow ``SavedModel`` collection.
Args:
tf_saved_model_dir: The local file... |
Load a specified TensorFlow model consisting of a TensorFlow metagraph and signature definition
from a serialized TensorFlow ``SavedModel`` collection.
Args:
tf_saved_model_dir: The local filesystem path or run-relative artifact path to the model.
tf_meta_graph_tags: A list of tags identif... | _load_tf1_estimator_saved_model | python | mlflow/mlflow | mlflow/tensorflow/__init__.py | https://github.com/mlflow/mlflow/blob/master/mlflow/tensorflow/__init__.py | Apache-2.0 |
def _load_pyfunc(path):
"""
Load PyFunc implementation. Called by ``pyfunc.load_model``. This function loads an MLflow
model with the TensorFlow flavor into a new TensorFlow graph and exposes it behind the
``pyfunc.predict`` interface.
Args:
path: Local filesystem path to the MLflow Model w... |
Load PyFunc implementation. Called by ``pyfunc.load_model``. This function loads an MLflow
model with the TensorFlow flavor into a new TensorFlow graph and exposes it behind the
``pyfunc.predict`` interface.
Args:
path: Local filesystem path to the MLflow Model with the ``tensorflow`` flavor.
... | _load_pyfunc | python | mlflow/mlflow | mlflow/tensorflow/__init__.py | https://github.com/mlflow/mlflow/blob/master/mlflow/tensorflow/__init__.py | Apache-2.0 |
def __init__(self, model, infer):
"""
Args:
model: A Tensorflow SavedModel.
infer: Tensorflow function returned by a saved model that is used for inference.
"""
# Note: we need to retain the model reference in TF2Wrapper object, because the infer
# functi... |
Args:
model: A Tensorflow SavedModel.
infer: Tensorflow function returned by a saved model that is used for inference.
| __init__ | python | mlflow/mlflow | mlflow/tensorflow/__init__.py | https://github.com/mlflow/mlflow/blob/master/mlflow/tensorflow/__init__.py | Apache-2.0 |
def predict(
self,
data,
params: Optional[dict[str, Any]] = None,
):
"""
Args:
data: Model input data.
params: Additional parameters to pass to the model for inference.
Returns
Model predictions.
"""
if isinstance(d... |
Args:
data: Model input data.
params: Additional parameters to pass to the model for inference.
Returns
Model predictions.
| predict | python | mlflow/mlflow | mlflow/tensorflow/__init__.py | https://github.com/mlflow/mlflow/blob/master/mlflow/tensorflow/__init__.py | Apache-2.0 |
def _assoc_list_to_map(lst):
"""
Convert an association list to a dictionary.
"""
d = {}
for run_id, metric in lst:
d[run_id] = d[run_id] + [metric] if run_id in d else [metric]
return d |
Convert an association list to a dictionary.
| _assoc_list_to_map | python | mlflow/mlflow | mlflow/tensorflow/__init__.py | https://github.com/mlflow/mlflow/blob/master/mlflow/tensorflow/__init__.py | Apache-2.0 |
def _setup_callbacks(callbacks, log_every_epoch, log_every_n_steps):
"""
Adds TensorBoard and MlfLowTfKeras callbacks to the
input list, and returns the new list and appropriate log directory.
"""
from mlflow.tensorflow.autologging import _TensorBoard
from mlflow.tensorflow.callback import Mlflo... |
Adds TensorBoard and MlfLowTfKeras callbacks to the
input list, and returns the new list and appropriate log directory.
| _setup_callbacks | python | mlflow/mlflow | mlflow/tensorflow/__init__.py | https://github.com/mlflow/mlflow/blob/master/mlflow/tensorflow/__init__.py | Apache-2.0 |
def load_checkpoint(model=None, run_id=None, epoch=None, global_step=None):
"""
If you enable "checkpoint" in autologging, during Keras model
training execution, checkpointed models are logged as MLflow artifacts.
Using this API, you can load the checkpointed model.
If you want to load the latest c... |
If you enable "checkpoint" in autologging, during Keras model
training execution, checkpointed models are logged as MLflow artifacts.
Using this API, you can load the checkpointed model.
If you want to load the latest checkpoint, set both `epoch` and `global_step` to None.
If "checkpoint_save_freq... | load_checkpoint | python | mlflow/mlflow | mlflow/tensorflow/__init__.py | https://github.com/mlflow/mlflow/blob/master/mlflow/tensorflow/__init__.py | Apache-2.0 |
def log_expectation(
*,
trace_id: str,
name: str,
value: Any,
source: Optional[AssessmentSource] = None,
metadata: Optional[dict[str, Any]] = None,
span_id: Optional[str] = None,
) -> Assessment:
"""
.. important::
This API is currently only available for `Databricks Managed... |
.. important::
This API is currently only available for `Databricks Managed MLflow <https://www.databricks.com/product/managed-mlflow>`_.
Logs an expectation (e.g. ground truth label) to a Trace. This API only takes keyword arguments.
Args:
trace_id: The ID of the trace.
name: Th... | log_expectation | python | mlflow/mlflow | mlflow/tracing/assessment.py | https://github.com/mlflow/mlflow/blob/master/mlflow/tracing/assessment.py | Apache-2.0 |
def update_assessment(
trace_id: str,
assessment_id: str,
assessment: Assessment,
) -> Assessment:
"""
.. important::
This API is currently only available for `Databricks Managed MLflow <https://www.databricks.com/product/managed-mlflow>`_.
Updates an existing expectation (ground truth... |
.. important::
This API is currently only available for `Databricks Managed MLflow <https://www.databricks.com/product/managed-mlflow>`_.
Updates an existing expectation (ground truth) in a Trace.
Args:
trace_id: The ID of the trace.
assessment_id: The ID of the expectation asses... | update_assessment | python | mlflow/mlflow | mlflow/tracing/assessment.py | https://github.com/mlflow/mlflow/blob/master/mlflow/tracing/assessment.py | Apache-2.0 |
def log_feedback(
*,
trace_id: str,
name: str = DEFAULT_FEEDBACK_NAME,
value: Optional[FeedbackValueType] = None,
source: Optional[AssessmentSource] = None,
error: Optional[Union[Exception, AssessmentError]] = None,
rationale: Optional[str] = None,
metadata: Optional[dict[str, Any]] = No... |
.. important::
This API is currently only available for `Databricks Managed MLflow <https://www.databricks.com/product/managed-mlflow>`_.
Logs feedback to a Trace. This API only takes keyword arguments.
Args:
trace_id: The ID of the trace.
name: The name of the feedback assessmen... | log_feedback | python | mlflow/mlflow | mlflow/tracing/assessment.py | https://github.com/mlflow/mlflow/blob/master/mlflow/tracing/assessment.py | Apache-2.0 |
def override_feedback(
*,
trace_id: str,
assessment_id: str,
value: FeedbackValueType,
rationale: Optional[str] = None,
source: Optional[AssessmentSource] = None,
metadata: Optional[dict[str, Any]] = None,
) -> Assessment:
"""
.. important::
This API is currently only availa... |
.. important::
This API is currently only available for `Databricks Managed MLflow <https://www.databricks.com/product/managed-mlflow>`_.
Overrides an existing feedback assessment with a new assessment. This API
logs a new assessment with the `overrides` field set to the provided assessment ID.
... | override_feedback | python | mlflow/mlflow | mlflow/tracing/assessment.py | https://github.com/mlflow/mlflow/blob/master/mlflow/tracing/assessment.py | Apache-2.0 |
def __init__(self, tracking_uri: Optional[str] = None):
"""
Args:
tracking_uri: Address of local or remote tracking server.
"""
self.tracking_uri = _resolve_tracking_uri(tracking_uri)
# NB: Fetch the tracking store (`self.store`) upon client initialization to ensure t... |
Args:
tracking_uri: Address of local or remote tracking server.
| __init__ | python | mlflow/mlflow | mlflow/tracing/client.py | https://github.com/mlflow/mlflow/blob/master/mlflow/tracing/client.py | Apache-2.0 |
def get_trace(self, request_id) -> Trace:
"""
Get the trace matching the ``request_id``.
Args:
request_id: String id of the trace to fetch.
Returns:
The fetched Trace object, of type ``mlflow.entities.Trace``.
"""
trace_info = self.get_trace_info... |
Get the trace matching the ``request_id``.
Args:
request_id: String id of the trace to fetch.
Returns:
The fetched Trace object, of type ``mlflow.entities.Trace``.
| get_trace | python | mlflow/mlflow | mlflow/tracing/client.py | https://github.com/mlflow/mlflow/blob/master/mlflow/tracing/client.py | Apache-2.0 |
def search_traces(
self,
experiment_ids: list[str],
filter_string: Optional[str] = None,
max_results: int = SEARCH_TRACES_DEFAULT_MAX_RESULTS,
order_by: Optional[list[str]] = None,
page_token: Optional[str] = None,
run_id: Optional[str] = None,
include_spa... |
Return traces that match the given list of search expressions within the experiments.
Args:
experiment_ids: List of experiment ids to scope the search.
filter_string: A search filter string.
max_results: Maximum number of traces desired.
order_by: List o... | search_traces | python | mlflow/mlflow | mlflow/tracing/client.py | https://github.com/mlflow/mlflow/blob/master/mlflow/tracing/client.py | Apache-2.0 |
def download_trace_extra_fields(
trace_info: Union[TraceInfoV2, TraceInfo],
) -> Optional[Trace]:
"""
Download trace data and assessments for the given trace_info and returns a Trace object.
If the download fails (e.g., the trace data is missing or corrupted), ret... |
Download trace data and assessments for the given trace_info and returns a Trace object.
If the download fails (e.g., the trace data is missing or corrupted), returns None.
The trace_info parameter can be either TraceInfo or TraceInfoV3 object.
| download_trace_extra_fields | python | mlflow/mlflow | mlflow/tracing/client.py | https://github.com/mlflow/mlflow/blob/master/mlflow/tracing/client.py | Apache-2.0 |
def set_trace_tags(self, request_id, tags):
"""
Set tags on the trace with the given request_id.
Args:
request_id: The ID of the trace.
tags: A dictionary of key-value pairs.
"""
tags = exclude_immutable_tags(tags)
for k, v in tags.items():
... |
Set tags on the trace with the given request_id.
Args:
request_id: The ID of the trace.
tags: A dictionary of key-value pairs.
| set_trace_tags | python | mlflow/mlflow | mlflow/tracing/client.py | https://github.com/mlflow/mlflow/blob/master/mlflow/tracing/client.py | Apache-2.0 |
def set_trace_tag(self, request_id, key, value):
"""
Set a tag on the trace with the given trace ID.
Args:
request_id: The ID of the trace to set the tag on.
key: The string key of the tag. Must be at most 250 characters long, otherwise
it will be truncat... |
Set a tag on the trace with the given trace ID.
Args:
request_id: The ID of the trace to set the tag on.
key: The string key of the tag. Must be at most 250 characters long, otherwise
it will be truncated when stored.
value: The string value of the t... | set_trace_tag | python | mlflow/mlflow | mlflow/tracing/client.py | https://github.com/mlflow/mlflow/blob/master/mlflow/tracing/client.py | Apache-2.0 |
def delete_trace_tag(self, request_id, key):
"""
Delete a tag on the trace with the given trace ID.
Args:
request_id: The ID of the trace to delete the tag from.
key: The string key of the tag. Must be at most 250 characters long, otherwise
it will be tru... |
Delete a tag on the trace with the given trace ID.
Args:
request_id: The ID of the trace to delete the tag from.
key: The string key of the tag. Must be at most 250 characters long, otherwise
it will be truncated when stored.
| delete_trace_tag | python | mlflow/mlflow | mlflow/tracing/client.py | https://github.com/mlflow/mlflow/blob/master/mlflow/tracing/client.py | Apache-2.0 |
def get_assessment(self, trace_id: str, assessment_id: str) -> Assessment:
"""
Get an assessment entity from the backend store.
Args:
trace_id: The ID of the trace.
assessment_id: The ID of the assessment to get.
Returns:
The Assessment object.
... |
Get an assessment entity from the backend store.
Args:
trace_id: The ID of the trace.
assessment_id: The ID of the assessment to get.
Returns:
The Assessment object.
| get_assessment | python | mlflow/mlflow | mlflow/tracing/client.py | https://github.com/mlflow/mlflow/blob/master/mlflow/tracing/client.py | Apache-2.0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.