Search code examples
azureml-python-sdkazuremlsdk

Azureml SDK v2 The provided asset name will not be used for anonymous registration


I am trying to create an environment using AzureML SDK v2 and it throws Warning/Error as follows:

##[error]Warning: the provided asset name 'my_environment_name' will not be used for anonymous registration

This breaks my Azure Devops Pipeline, and also I do not understand the meaning of it.


Solution

  • TL;DR: Register your model and environment separately


    I assume you followed the how to create component pipeline v2 docs and created a mldesigner.command_component by specifying the environment parameter with a dict object or an Environment object.

    E.g.:

    import mldesigner
    
    environment=dict(
        name="my_env",
        conda_file="conda.yaml",
        image="mcr.microsoft.com/azureml/openmpi4.1.0-ubuntu20.04",
    )
    
    @mldesigner.command_component(
        name="prep_data",
        version="1",
        display_name="Prep Data",
        description="Convert data to CSV file, and split to training and test data",
        environment=environment,
    )
    def prepare_data_component(
        input_data: Input(type="uri_folder"),
        training_data: Output(type="uri_folder"),
        test_data: Output(type="uri_folder"),
    ):
        pass
    

    If you run above Python snippet in a script you will receive a warning:

    Warning: the provided asset name 'my_env' will not be used for anonymous registration
    

    This means, although you specify the name it is not used since a pipeline command job has an anonymous environment. In the Azure ML Environment Docs we find:
    "Anonymous" environments are automatically registered in your workspace when you submit an experiment. They will not be listed but may be retrieved by version.

    More precisely an environment CliV2AnonymousEnvironment will be created with a GUID.

    Using above component in an Azure ML pipeline won't result in an error, though. Of course your Azure DevOps pipeline will fail based on this warning.

    Solutions

    1. Register your model and environment separately

    The advised solution would be to manage your environment separately of your pipeline. So create an environment via the SDK (Manage Environments V2 Docs) and specify it in your command component:

    environment="azureml:my_env@latest"
    
    1. Name your environment CliV2AnonymousEnvironment

    If you would like to keep using an anonymous environment provided via the dictionary object rename it to CliV2AnonymousEnvironment. Using this name won't raise the error from above.

    1. Configure your Azure DevOps pipeline not to fail on this warning

    E.g. (Ignore/supress Warning during Azure Devops Pipeline)


    I hope this helps, looking forward to feedback. I also do not find it obvious how all the components are linked in Azure ML.