Environment class

Definition

Configure the python environment where the experiment is executed.

Environment(name, _skip_defaults=False)
Inheritance
builtins.object
azureml._base_sdk_common.abstract_run_config_element._AbstractRunConfigElement
Environment

Parameters

name
string

The name of the environment

version
string

The version of the environment

environment_variables
dict

A dictionary of environment variables names and values. These environment variables are set on the process where user script is being executed.

python
PythonSection

This section specifies which python environment and interpreter to use on the target compute.

docker
DockerSection

This section configures if and how Docker containers are used by the run.

spark
SparkSection

The section configures Spark settings. It is only used when framework is set to PySpark.

databricks
azureml.core._databricks.DatabricksSection

The section configures Databricks library dependencies.

inferencing_stack_version
string

This section specifies the inferencing stack version added to the image. To avoid adding an inferencing stack, do not set this value. Valid values: "latest"

Methods

add_private_pip_wheel(workspace, file_path, exist_ok=False)

Upload the private pip wheel file on disk to the Azure storage blob attached to the workspace.

Throws an exception if a private pip wheel with the same name already exists in the workspace storage blob.

build(workspace)

Build a Docker image for this environment in the cloud.

build_local(workspace)

Build the local docker or conda environment.

from_conda_specification(name, file_path)

Create an environment object created from a environment specification yaml file.

To get an environment specification yaml file, please refer to the conda docs link below. https://docs.conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html#exporting-the-environment-file

from_existing_conda_environment(name, conda_environment_name)

Create an environment object created from a locally existing conda environment.

To get a list of existing conda environments, run "conda env list" https://docs.conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html#viewing-a-list-of-your-environments

from_pip_requirements(name, file_path)

Create an environment object created from a pip requirements file.

get(workspace, name, version=None)

Return the environment object.

get_image_details(workspace)

Return the Image details.

list(workspace)

Return the list of environments in the workspace.

load_from_directory(path)

Load an environment definition from the files in a directory.

register(workspace)

Register the environment object in your workspace.

save_to_directory(path, overwrite=False)

Save an environment definition to a directory in an easily editable format.

add_private_pip_wheel(workspace, file_path, exist_ok=False)

Upload the private pip wheel file on disk to the Azure storage blob attached to the workspace.

Throws an exception if a private pip wheel with the same name already exists in the workspace storage blob.

add_private_pip_wheel(workspace, file_path, exist_ok=False)

Parameters

workspace
Workspace

Workspace object to use to register the private pip wheel.

file_path
str

Path to the local pip wheel on disk, including the file extension.

exist_ok
bool

If set to True, the method will not throw an exception if the wheel already exists.

default value: False

Returns

Returns the full URI to the uploaded pip wheel on Azure blob storage to use in conda dependencies.

Return type

str

build(workspace)

Build a Docker image for this environment in the cloud.

build(workspace)

Parameters

workspace
Workspace

The workspace

Returns

Returns the image build details object

Return type

azureml.core.environment._ImageBuildDetails

build_local(workspace)

Build the local docker or conda environment.

build_local(workspace)

Parameters

workspace
Workspace

The workspace

Returns

Streams the build environment output

Return type

str

from_conda_specification(name, file_path)

Create an environment object created from a environment specification yaml file.

To get an environment specification yaml file, please refer to the conda docs link below. https://docs.conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html#exporting-the-environment-file

from_conda_specification(name, file_path)

Parameters

name
str

The environment name

file_path
str

The conda environment specification yaml file path.

Returns

Returns the environment object

Return type

from_existing_conda_environment(name, conda_environment_name)

Create an environment object created from a locally existing conda environment.

To get a list of existing conda environments, run "conda env list" https://docs.conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html#viewing-a-list-of-your-environments

from_existing_conda_environment(name, conda_environment_name)

Parameters

name
str

The environment name

conda_environment_name
str

The name of a locally existing conda environment.

Returns

Returns the environment object or None if exporting the conda specification file fails.

Return type

from_pip_requirements(name, file_path)

Create an environment object created from a pip requirements file.

from_pip_requirements(name, file_path)

Parameters

name
str

The environment name

file_path
str

The pip requirements file path.

Returns

Returns the environment object

Return type

get(workspace, name, version=None)

Return the environment object.

get(workspace, name, version=None)

Parameters

workspace
Workspace

The workspace

name
str
version
str
default value: None

Returns

Returns the environment object

Return type

get_image_details(workspace)

Return the Image details.

get_image_details(workspace)

Parameters

workspace
Workspace

The workspace

Returns

Returns the image details object

Return type

azureml.core.environment._ImageDetails

list(workspace)

Return the list of environments in the workspace.

list(workspace)

Parameters

workspace
Workspace

The workspace from which to list the environments.

Returns

list of environment objects.

Return type

load_from_directory(path)

Load an environment definition from the files in a directory.

load_from_directory(path)

Parameters

path
str

Path to the source directory.

register(workspace)

Register the environment object in your workspace.

register(workspace)

Parameters

workspace
Workspace

The workspace

name
str

Returns

Returns the environment object

Return type

save_to_directory(path, overwrite=False)

Save an environment definition to a directory in an easily editable format.

save_to_directory(path, overwrite=False)

Parameters

path
str

Path to the destination directory.

overwrite
bool

If an existing directory should be overwritten. Defaults false.

default value: False