Databricks Machine Learning Professional Question 26
Single answerYou are a data scientist working on a machine learning project in Databricks, and you want to programmatically retrieve the metadata of an MLflow model registered under the name 'sales_forecast_model' to check its latest version and stage (e.g., 'Staging', 'Production'). Which method would you use to achieve this?
- A
mlflow.get_tracking_uri()
- B
mlflow.register_model(model_uri, name)
- C
mlflow.search_registered_models()
- D
mlflow.client.MlflowClient().get_registered_model()
Show answer and explanation
Correct answer: D
Explanation
To programmatically access metadata of a registered MLflow model, such as its version and stage, you must use the get_registered_model method within the MlflowClient class. This method provides detailed information about the model, making it the correct choice for this task. Other options either perform unrelated actions or lack the functionality to retrieve model metadata.
- A. Incorrect.
This method retrieves the tracking server URI but does not provide access to model metadata. It is unrelated to the task described in the question.
- B. Incorrect.
This method is used to register a model to the MLflow model registry, not to retrieve metadata of an already registered model.
- C. Incorrect.
This method allows searching through all registered models but does not retrieve metadata of a specific model like version or stage.
- D. Correct.
This method, from the MlflowClient API, is specifically designed to programmatically retrieve metadata about a registered MLflow model, including its latest version and stage.