locked
Where do environments get saved when they are registered in Azure ML RRS feed

  • Question

  • I have students I am training and one had asked where the registered environments are found. I checked the Azure ML studio and cannot find any reference to a registered environment and also checked the blob storage and it is difficult to navigate the container. Is there a way, besides listing the available environments in SDK that you can find access and share outside of the workspace?
    Thursday, May 28, 2020 9:45 PM

All replies

  • Hi,

    Please follow the below to list and get the existing environments using SDK in the workspace.

    List and get existing environments

    Your workspace contains a dictionary of registered environments. You can then use Environment.get to retrieve a specific environment with specific version.

    In [ ]:
    for name,env in ws.environments.items():
        print("Name {} \t version {}".format(name,env.version))
    
    restored_environment = Environment.get(workspace=ws,name="myenv",version="1")
    
    print("Attributes of restored environment")
    restored_environment

    Use curated environments

    Curated environments are provided by Azure Machine Learning and are available in your workspace by default. They contain collections of Python packages and settings to help you get started different machine learning frameworks.

    • The AzureML-Minimal environment contains a minimal set of packages to enable run tracking and asset uploading. You can use it as a starting point for your own environment.
    • The AzureML-Tutorial environment contains common data science packages, such as Scikit-Learn, Pandas and Matplotlib, and larger set of azureml-sdk packages.

    Curated environments are backed by cached Docker images, reducing the run preparation cost.

    You can get a curated environment using

    In [ ]:
    from azureml.core import Environment
    
    curated_env = Environment.get(workspace=ws, name="AzureML-Minimal")

    To list curated environments, use following code.

    Note: The name prefixes AzureML and Microsoft are reserved for curated environments. Do not use them for your own environments

    In [ ]:
    envs = Environment.list(workspace=ws)
    
    for env in envs:
        if env.startswith("AzureML"):
            print("Name",env)
            print("packages", envs[env].python.conda_dependencies.serialize_to_string())

    Create your own environment

    You can create an environment by instantiating Environment object and then setting its attributes: set of Python packages, environment variables and others.

    Add Python packages

    The recommended way is to specify Conda packages, as they typically come with complete set of pre-built binaries.

    In [ ]:
    from azureml.core.environment import CondaDependencies
    
    myenv = Environment(name="myenv")
    conda_dep = CondaDependencies()
    conda_dep.add_conda_package("scikit-learn")

    You can also add pip packages, and specify the version of package

    In [ ]:
    conda_dep.add_pip_package("pillow==5.4.1")
    myenv.python.conda_dependencies=conda_dep

    Specify environment variables

    You can add environment variables to your environment. These then become available using os.environ.get in your training script.

    In [ ]:
    myenv.environment_variables = {"MESSAGE":"Hello from Azure Machine Learning"}

    Thanks


    Friday, May 29, 2020 10:25 AM