MachineLearningNotebooks icon indicating copy to clipboard operation
MachineLearningNotebooks copied to clipboard

AzureML Python SDK: Model deserialization ignores tags

Open pbartos opened this issue 5 years ago • 2 comments

Version azureml.core: 1.11.0

from azureml.core import Model

model = Model(ws, "MODEL_NAME")
tags_before_serialization = model.tags
serialized = model.serialize()

deserialized_model = Model.deserialize(ws, serialized)
tags_after_serialization = deserialized_model.tags
print(f"Before: {tags_before_serialization}")
print(f"After: {tags_after_serialization}")

Result:

Before: {'Fit': '0.601', 'BuildId': '271320'}
After: {}

Document Details

Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

pbartos avatar Aug 11 '20 09:08 pbartos

Workaround:

deserialized_model.update(tags=serialized["tags"])

pbartos avatar Aug 13 '20 07:08 pbartos

Hey there, I am encountering a similar issue wherein the model is not registering the tags when calling the model.register method. This is problematic as I want to filter by the model tags downstream using Model.list. I have tried passing the tags parameter in model.register as well as calling model.add_tags after the model registration method.

model = Model.register(
        workspace=ws,
        model_name=model_name, 
        model_path=output_dir,  
        model_framework=Model.Framework.CUSTOM, 
        description="blah blah blah",
        tags={'foo':'bar'}
    )
    
model.add_tags({'green_eggs':'ham'})

Are there any workarounds here?

isaac-bb avatar Aug 19 '22 16:08 isaac-bb