Deploying the model in the Model Registry
Next, you should add the register_model.py
function to register the model in the Model Registry.
This is as simple as executing the mlflow.register_model
method with the Uniform Resource Identifier (URI) of the model and the name of the model. Basically, a model will be created if it doesn't already exist. If it's already in the registry, a new version will be added, allowing the deployment tools to look at the models and trace the training jobs and metrics. It also allows a decision to be made as to whether to promote the model to production or not. The code you'll need is illustrated in the following snippet:
import mlflow if __name__ == "__main__": with mlflow.start_run(run_name="register_model") as run: mlflow.set_tag("mlflow.runName", "register_model") ...