Databricks Machine Learning Professional Question 113
Single answerYou are deploying a machine learning model on Databricks and want to send a notification via a webhook whenever a model transition event occurs in the Model Registry (e.g., transitioning from 'Staging' to 'Production'). Which of the following code blocks will correctly trigger the configured webhook?
- A
from mlflow.tracking import MlflowClient client = MlflowClient() client.transition_model_version_stage( name='my_model', version=1, stage='Production', archive_existing_versions=False )
- B
from mlflow.tracking import MlflowClient client = MlflowClient() client.create_registered_model('my_model')
- C
import requests requests.post('https://example-webhook-url.com', json={'event': 'model_transition', 'model_name': 'my_model', 'stage': 'Production'})
- D
from mlflow import log_metric log_metric('accuracy', 0.95)
Show answer and explanation
Correct answer: A
Explanation
The Model Registry in Databricks allows you to configure webhooks that can be triggered by specific events, such as model transitions or registered model deletions. The correct code block is the one that transitions a model's stage using MlflowClient.transition_model_version_stage, which is a supported trigger event for the webhook.
- A. Correct.
This code block triggers the webhook because it uses
MlflowClientto transition the model version stage, which is an event that the Model Registry can monitor and notify via the configured webhook. - B. Incorrect.
This code block does not trigger the webhook because creating a registered model is not a model transition event. Webhooks in the Model Registry are only triggered for specific events like model transitions.
- C. Incorrect.
This code block manually sends a POST request to a webhook URL, but it does not integrate with the Model Registry's webhook system, so it will not trigger the configured webhook.
- D. Incorrect.
This code block logs a metric, which is unrelated to the Model Registry and does not trigger any webhook.