[2.0] Make mlflow.sagemaker.deploy() / delete() APIs internal, remove CLIs#6650
[2.0] Make mlflow.sagemaker.deploy() / delete() APIs internal, remove CLIs#6650dbczumar merged 14 commits intomlflow:branch-2.0from
Conversation
Signed-off-by: dbczumar <[email protected]>
Signed-off-by: dbczumar <[email protected]>
Signed-off-by: dbczumar <[email protected]>
Signed-off-by: dbczumar <[email protected]>
Signed-off-by: dbczumar <[email protected]>
Signed-off-by: dbczumar <[email protected]>
Signed-off-by: dbczumar <[email protected]>
Signed-off-by: dbczumar <[email protected]>
Signed-off-by: dbczumar <[email protected]>
Signed-off-by: dbczumar <[email protected]>
| from mlflow.utils import env_manager as _EnvManager | ||
|
|
||
|
|
||
| def build_docker( |
There was a problem hiding this comment.
Introduce an API equivalent of mlflow models build-docker so that users don't have to call mlflow.sagemaker.build_and_push_container() with special "no_push" args in order to build an MLflow Model Server docker image. This build_and_push_container should arguably be moved to push_container since it duplicates image building work done by mlflow models build-docker, but that can happen in a follow-up PR.
There was a problem hiding this comment.
This is tested sufficiently by mlflow docker CLI tests, since the CLI calls this method directly. See
mlflow/tests/models/test_cli.py
Lines 416 to 492 in 8098785
| ) | ||
|
|
||
|
|
||
| def _get_flavor_backend(model_uri, **kwargs): |
There was a problem hiding this comment.
Also needs to be called by mlflow.models.build_docker, so move into mlflow.models.flavor_backend_registry and import it from mlflow.models.cli and mlflow.models.
|
|
||
|
|
||
| def deploy( | ||
| def _deploy( |
There was a problem hiding this comment.
Make deploy internal
| def _delete( | ||
| app_name, |
There was a problem hiding this comment.
Make delete internal
|
|
||
|
|
||
| def run_local(model_uri, port=5000, image=DEFAULT_IMAGE_NAME, flavor=None): | ||
| def run_local(name, model_uri, flavor=None, config=None): # pylint: disable=unused-argument |
There was a problem hiding this comment.
Make run_local conform to the interface required by mlflow deployments run-local -t sagemaker
There was a problem hiding this comment.
These changes are tested by test cases that call score_model_in_sagemaker_docker_container, such as
mlflow/tests/spark/test_spark_model_export.py
Lines 292 to 297 in 8098785
| ) | ||
| ), | ||
| ) | ||
| def run_local(model_uri, port, image, flavor): |
There was a problem hiding this comment.
Obviated by mlflow deployments run-local -t sagemaker
| " asynchronously using the `--async` flag, this value is ignored." | ||
| ), | ||
| ) | ||
| def delete(app_name, region_name, archive, asynchronous, timeout): |
There was a problem hiding this comment.
obviated by mlflow deployments delete -t sagemaker
| " asynchronously using the `--async` flag, this value is ignored." | ||
| ), | ||
| ) | ||
| def deploy( |
There was a problem hiding this comment.
Obviated by mlflow deployments create/update -t sagemaker
| @@ -1,875 +0,0 @@ | |||
| import os | |||
There was a problem hiding this comment.
All of the coverage provided in this test suite for mlflow.sagemaker.deploy() / delete() is covered for SageMakerDeploymentClient in https://github.com/mlflow/mlflow/blob/master/tests/sagemaker/test_sagemaker_deployment_client.py
| f" -C image=mlflow-pyfunc -C port={port} --flavor {flavor}" | ||
| ) | ||
| proc = _start_scoring_proc( | ||
| cmd=["mlflow", "sagemaker", "run-local", "-m", model_uri, "-p", "5000", "-f", flavor], |
There was a problem hiding this comment.
mlflow sagemaker run-local is obviated by mlflow deployments run-local -t sagemaker and is removed above, so we migrate this test helper function that relies on sagemaker local deployment to use the mlflow deployments run-local API
Signed-off-by: dbczumar <[email protected]>
Signed-off-by: dbczumar <[email protected]>
docs/source/models.rst
Outdated
| To export a custom model to SageMaker, you need a MLflow-compatible Docker image to be available on Amazon ECR. | ||
| MLflow provides a default Docker image definition; however, it is up to you to build the image and upload it to ECR. | ||
| MLflow includes the utility function ``build_and_push_container`` to perform this step. Once built and uploaded, you can use the MLflow container for all MLflow Models. Model webservers deployed using the :py:mod:`mlflow.sagemaker` | ||
| The :py:mod:`mlflow.deployments` and py:mod:`mlflow.sagemaker` modules can deploy |
There was a problem hiding this comment.
| The :py:mod:`mlflow.deployments` and py:mod:`mlflow.sagemaker` modules can deploy | |
| The :py:mod:`mlflow.deployments` and :py:mod:`mlflow.sagemaker` modules can deploy |
There was a problem hiding this comment.
Thanks for catching this!
docs/source/models.rst
Outdated
| mlflow deployments run-local -t sagemaker -m <path-to-model> - test the model locally | ||
| mlflow deployments -t sagemaker create - deploy the model remotely |
There was a problem hiding this comment.
| mlflow deployments run-local -t sagemaker -m <path-to-model> - test the model locally | |
| mlflow deployments -t sagemaker create - deploy the model remotely | |
| mlflow deployments run-local -t sagemaker -m <path-to-model> # test the model locally | |
| mlflow deployments -t sagemaker create # deploy the model remotely |
Can we replace - with #? - test the model locally looks like a command argument, but it's not.
There was a problem hiding this comment.
Absolutely! Fixed!
mlflow/sagemaker/__init__.py
Outdated
| mlflow deployments run-local --target sagemaker \\ | ||
| --name my-local-deployment \\ | ||
| --model-uri "/mlruns/0/abc/model" \\ | ||
| --flavor python_function\\ |
There was a problem hiding this comment.
| --flavor python_function\\ | |
| --flavor python_function \\ |
nit
mlflow/sagemaker/__init__.py
Outdated
| flavor="python_function", | ||
| config={ | ||
| "port": 5000, | ||
| "image": mlflow-pyfunc, |
There was a problem hiding this comment.
| "image": mlflow-pyfunc, | |
| "image": "mlflow-pyfunc", |
There was a problem hiding this comment.
Fixed! Thanks for catching this!
|
Can we revert the changes in |
docs/source/models.rst
Outdated
| mlflow sagemaker run-local -m <path-to-model> - test the model locally | ||
| mlflow sagemaker deploy <parameters> - deploy the model remotely | ||
| mlflow deployments run-local -t sagemaker -m <path-to-model> - test the model locally | ||
| mlflow deployments -t sagemaker create - deploy the model remotely |
There was a problem hiding this comment.
| mlflow deployments -t sagemaker create - deploy the model remotely | |
| mlflow deployments create -t sagemaker - deploy the model remotely |
mlflow deployments -t sagemaker create gave the following error.
mlflow deployments -t sagemaker create
Usage: mlflow deployments [OPTIONS] COMMAND [ARGS]...
Try 'mlflow deployments --help' for help.
Error: No such option: -t
There was a problem hiding this comment.
Great catch! Fixed!
docs/source/models.rst
Outdated
| * :py:func:`deploy <mlflow.sagemaker.deploy>` deploys the model on Amazon SageMaker. MLflow | ||
| uploads the Python Function model into S3 and starts an Amazon SageMaker endpoint serving | ||
| the model. | ||
| * :py:func:`deploy <mlflow.sagemaker.SageMakerDeploymentClient>` deploys the model on Amazon |
There was a problem hiding this comment.
Is this line correct? In the code block below, create deploys the model.
| * :py:func:`deploy <mlflow.sagemaker.SageMakerDeploymentClient>` deploys the model on Amazon | |
| * :py:func:`create <mlflow.sagemaker.SageMakerDeploymentClient.creaet_deployment>` deploys the model on Amazon |
There was a problem hiding this comment.
Fixed and made the link read mlflow deployments create -t sagemaker, also updated run-local to mlflow deployments run-local -t sagemaker
Signed-off-by: dbczumar <[email protected]>
Signed-off-by: dbczumar <[email protected]>
docs/source/models.rst
Outdated
| To export a custom model to SageMaker, you need a MLflow-compatible Docker image to be available on Amazon ECR. | ||
| MLflow provides a default Docker image definition; however, it is up to you to build the image and upload it to ECR. | ||
| MLflow includes the utility function ``build_and_push_container`` to perform this step. Once built and uploaded, you can use the MLflow container for all MLflow Models. Model webservers deployed using the :py:mod:`mlflow.sagemaker` | ||
| The :py:mod:`mlflow.deployments` and py:mod:`mlflow.sagemaker` modules can deploy |
There was a problem hiding this comment.
Thanks for catching this!
docs/source/models.rst
Outdated
| * :py:func:`deploy <mlflow.sagemaker.deploy>` deploys the model on Amazon SageMaker. MLflow | ||
| uploads the Python Function model into S3 and starts an Amazon SageMaker endpoint serving | ||
| the model. | ||
| * :py:func:`deploy <mlflow.sagemaker.SageMakerDeploymentClient>` deploys the model on Amazon |
There was a problem hiding this comment.
Fixed and made the link read mlflow deployments create -t sagemaker, also updated run-local to mlflow deployments run-local -t sagemaker
docs/source/models.rst
Outdated
| mlflow deployments run-local -t sagemaker -m <path-to-model> - test the model locally | ||
| mlflow deployments -t sagemaker create - deploy the model remotely |
There was a problem hiding this comment.
Absolutely! Fixed!
docs/source/models.rst
Outdated
| mlflow sagemaker run-local -m <path-to-model> - test the model locally | ||
| mlflow sagemaker deploy <parameters> - deploy the model remotely | ||
| mlflow deployments run-local -t sagemaker -m <path-to-model> - test the model locally | ||
| mlflow deployments -t sagemaker create - deploy the model remotely |
There was a problem hiding this comment.
Great catch! Fixed!
mlflow/sagemaker/__init__.py
Outdated
| mlflow deployments run-local --target sagemaker \\ | ||
| --name my-local-deployment \\ | ||
| --model-uri "/mlruns/0/abc/model" \\ | ||
| --flavor python_function\\ |
mlflow/sagemaker/__init__.py
Outdated
| flavor="python_function", | ||
| config={ | ||
| "port": 5000, | ||
| "image": mlflow-pyfunc, |
There was a problem hiding this comment.
Fixed! Thanks for catching this!
Signed-off-by: dbczumar [email protected]
What changes are proposed in this pull request?
Make mlflow.sagemaker.deploy() / delete() APIs internal, since
SageMakerDeploymentClientshould be used instead.This is a follow-up for #6651
How is this patch tested?
Existing tests
Does this PR change the documentation?
Detailslink on thePreview docscheck.Release Notes
Remove the deprecated mlflow.sagemaker.deploy() / delete() APIs, which have been replaced by
SageMakerDeploymentClientwith MLflow Deployments.Is this a user-facing change?
What component(s), interfaces, languages, and integrations does this PR affect?
Components
area/artifacts: Artifact stores and artifact loggingarea/build: Build and test infrastructure for MLflowarea/docs: MLflow documentation pagesarea/examples: Example codearea/model-registry: Model Registry service, APIs, and the fluent client calls for Model Registryarea/models: MLmodel format, model serialization/deserialization, flavorsarea/pipelines: Pipelines, Pipeline APIs, Pipeline configs, Pipeline Templatesarea/projects: MLproject format, project running backendsarea/scoring: MLflow Model server, model deployment tools, Spark UDFsarea/server-infra: MLflow Tracking server backendarea/tracking: Tracking Service, tracking client APIs, autologgingInterface
area/uiux: Front-end, user experience, plotting, JavaScript, JavaScript dev serverarea/docker: Docker use across MLflow's components, such as MLflow Projects and MLflow Modelsarea/sqlalchemy: Use of SQLAlchemy in the Tracking Service or Model Registryarea/windows: Windows supportLanguage
language/r: R APIs and clientslanguage/java: Java APIs and clientslanguage/new: Proposals for new client languagesIntegrations
integrations/azure: Azure and Azure ML integrationsintegrations/sagemaker: SageMaker integrationsintegrations/databricks: Databricks integrationsHow should the PR be classified in the release notes? Choose one:
rn/breaking-change- The PR will be mentioned in the "Breaking Changes" sectionrn/none- No description will be included. The PR will be mentioned only by the PR number in the "Small Bugfixes and Documentation Updates" sectionrn/feature- A new user-facing feature worth mentioning in the release notesrn/bug-fix- A user-facing bug fix worth mentioning in the release notesrn/documentation- A user-facing documentation change worth mentioning in the release notes