-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support remote Databricks model registries in mlflow.<flavor>.load_model
#3330
Conversation
Signed-off-by: Sue Ann Hong <sueann@databricks.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tried it out, and it works! Small note about adding a test - I tried a few of the cases, but would be good to codify in the test
assert models_repo.artifact_uri == model_uri | ||
assert isinstance(models_repo.repo, DbfsRestArtifactRepository) | ||
mock_repo.assert_called_once_with( | ||
"dbfs://scope:key@databricks/databricks/mlflow-registry/12345/models/keras-model" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we also just verify that the right error is thrown if the registry URI is malformed?
Signed-off-by: Sue Ann Hong <sueann@databricks.com>
with mock.patch("mlflow.get_registry_uri", return_value="databricks://scope:key:invalid"): | ||
with pytest.raises(MlflowException) as ex: | ||
ModelsArtifactRepository(model_uri) | ||
assert "Key prefixes cannot contain" in ex.value.message |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ankitmathur-db is something like this what you were thinking? please do let me know if there are other cases you were thinking of I didn't cover here. thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah this is what I was thinking. Have we tested stuff like databricks://scope:key.
(with the extra spaces at the end)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah we don't test it - but that should be handled at a lower level. Created a PR to address that: #3338.
Looks great! |
Signed-off-by: Sue Ann Hong sueann@databricks.com
What changes are proposed in this pull request?
Support remote Databricks model registries in
mlflow.<flavor>.load_model
when called with amodels:/
URI.Currently, the following two ways to call mlflow..load_model from a remote Databricks model registry work:
But the following, more natural, way does not:
This is because each flavor’s
load_model
calls
_download_artifact_from_uri
which calls
get_artifact_repository(artifact_uri=root_uri).download_artifacts
and no registry server information is passed into the eventual DBFS artifact repository instance. So then the DBFS artifact repository uses the tracking URI from the context (i.e. set via the global variable or the environment variable).
To fix this, here we have
ModelsArtifactRepository
automatically use the Databricks model registry server information if specified in the context.How is this patch tested?
Release Notes
Is this a user-facing change?
mlflow.<flavor>.load_model
methods will fetch the model from the Databricks model registry specified bymlflow.set_registry_uri
if it is set to one.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/projects
: MLproject format, project running backendsarea/scoring
: Local serving, model deployment tools, spark UDFsarea/server-infra
: MLflow server, JavaScript dev serverarea/tracking
: Tracking Service, tracking client APIs, autologgingInterface
area/uiux
: Front-end, user experience, JavaScript, plottingarea/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