Search code examples
azureazure-machine-learning-service

Add model description when registering model after hyperdrive successful run


I have successfully trained a model on Azure Machine Learning Service using Hyperdrive that has now yielded a hyperdrive run instance

hyperdrive_run = exp.submit(config=hypertune_config)
hyperdrive_run
best_run = hyperdrive_run.get_best_run_by_primary_metric()

As a next step, I would like to register a model while adding a description to the model.:

pumps_rf = best_run.register_model(model_name='pumps_rf', model_path='outputs/rf.pkl')

There is a description column in the Models section of my AML Workspace on Azure portal but the register_model method does not seem to have a description flag. So how do I go about adding a description to the model so I see it in Azure Portal?


Solution

  • Good question :).

    Looking at the current version of the API, it doesn't look like you can add the description using Run.register_model, as confirmed by the docs.

    You can go around this however by registering the model using the Model.register method which, fortunately, includes an argument for description as detailed here. In your case, you also need to download the files first.

    In short, use something like:

    best_run.download_file('outputs/rf.pkl', output_file_path='./rf.pkl')
    
    Model.register(workspace=ws, model_path='./rf.pkl', model_name="pumps_rf", description="There are many models like it, but this one is mine.")