Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mark Model Registry Stages as deprecated #10416

Merged
merged 7 commits into from Nov 17, 2023
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
27 changes: 26 additions & 1 deletion mlflow/tracking/client.py
Expand Up @@ -3,7 +3,7 @@
and model versions. This is a lower level API than the :py:mod:`mlflow.tracking.fluent` module,
and is exposed in the :py:mod:`mlflow.tracking` module.
"""
import contextlib

Check failure on line 6 in mlflow/tracking/client.py

View workflow job for this annotation

GitHub Actions / lint

[*] Import block is un-sorted or un-formatted. Run `ruff --fix .` or comment `@mlflow-automation autoformat` to fix this error.
import json
import logging
import os
Expand Down Expand Up @@ -37,7 +37,7 @@
from mlflow.tracking._tracking_service.client import TrackingServiceClient
from mlflow.tracking.artifact_utils import _upload_artifacts_to_databricks
from mlflow.tracking.registry import UnsupportedModelRegistryStoreURIException
from mlflow.utils.annotations import experimental
from mlflow.utils.annotations import experimental, deprecated
from mlflow.utils.async_logging.run_operations import RunOperations
from mlflow.utils.databricks_utils import get_databricks_run_url
from mlflow.utils.logging_utils import eprint
Expand All @@ -62,6 +62,11 @@

_logger = logging.getLogger(__name__)

_STAGES_DEPRECATION_WARNING = (
"Model registry stages will be removed in a future major release. To learn more about the "
"deprecation of model registry stages, see https://github.com/mlflow/mlflow/issues/10336"
)


class MlflowClient:
"""
Expand Down Expand Up @@ -2406,6 +2411,7 @@
"""
return self._get_registry_client().get_registered_model(name)

@deprecated(since="2.9.0")
def get_latest_versions(
self, name: str, stages: Optional[List[str]] = None
) -> List[ModelVersion]:
Expand Down Expand Up @@ -2480,6 +2486,9 @@
run_id: 31165664be034dc698c52a4bdeb71663
current_stage: None
"""
_logger.warning(
"The `get_latest_versions` API is deprecated. " + _STAGES_DEPRECATION_WARNING
)
return self._get_registry_client().get_latest_versions(name, stages)

def set_registered_model_tag(self, name, key, value) -> None:
Expand Down Expand Up @@ -2876,6 +2885,7 @@
name=name, version=version, description=description
)

@deprecated(since="2.9.0")
jerrylian-db marked this conversation as resolved.
Show resolved Hide resolved
def transition_model_version_stage(
self, name: str, version: str, stage: str, archive_existing_versions: bool = False
) -> ModelVersion:
Expand Down Expand Up @@ -2948,6 +2958,9 @@
Description: A new version of the model using ensemble trees
Stage: Staging
"""
_logger.warning(
"The `transition_model_version_stage` API is deprecated. " + _STAGES_DEPRECATION_WARNING
)
return self._get_registry_client().transition_model_version_stage(
name, version, stage, archive_existing_versions
)
Expand Down Expand Up @@ -3226,6 +3239,7 @@
filter_string, max_results, order_by, page_token
)

@deprecated(since="2.9.0")
def get_model_version_stages(
self, name: str, version: str
) -> List[str]: # pylint: disable=unused-argument
Expand Down Expand Up @@ -3269,6 +3283,9 @@

Model list of valid stages: ['None', 'Staging', 'Production', 'Archived']
"""
_logger.warning(
"The `get_model_version_stages` API is deprecated. " + _STAGES_DEPRECATION_WARNING
)
return ALL_STAGES

def set_model_version_tag(
Expand Down Expand Up @@ -3352,6 +3369,10 @@
"""
_validate_model_version_or_stage_exists(version, stage)
if stage:
_logger.warning(
"The `stage` parameter of the `set_model_version_tag` API is deprecated. "
+ _STAGES_DEPRECATION_WARNING
)
jerrylian-db marked this conversation as resolved.
Show resolved Hide resolved
latest_versions = self.get_latest_versions(name, stages=[stage])
if not latest_versions:
raise MlflowException(f"Could not find any model version for {stage} stage")
Expand Down Expand Up @@ -3437,6 +3458,10 @@
"""
_validate_model_version_or_stage_exists(version, stage)
if stage:
_logger.warning(
"The `stage` parameter of the `set_model_version_tag` API is deprecated. "
+ _STAGES_DEPRECATION_WARNING
)
latest_versions = self.get_latest_versions(name, stages=[stage])
if not latest_versions:
raise MlflowException("Could not find any model version for {stage} stage")
Expand Down