Open CESARDELATORRE opened 4 years ago
this is clearly a regression -- filed bug here: https://msdata.visualstudio.com/Vienna/_workitems/edit/583736
@CESARDELATORRE - Thank you for bringing this to our attention. Yes, the ideal behavior will be for Estimator constructor to take in a curated environment via the environment_definition
param.
For now, however, its functionality is the same as ScriptRunConfig; the curated environment can be directly assigned (without need for registration) only after the Estimator object has been created.
ScriptRunConfig example:
from azureml.core import ScriptRunConfig
from azureml.core.environment import Environment
# Get the curated environment
curated_environment = Environment.get(workspace=ws, name="AzureML-Tutorial")
runconfig = ScriptRunConfig(source_directory=".", script="train.py")
runconfig.run_config.target = "local"
# Attach environment to run config
runconfig.run_config.environment = myenv
Estimator example:
from azureml.train.estimator import Estimator
from azureml.core.environment import Environment
# Get the curated environment
curated_environment = Environment.get(workspace=ws, name="AzureML-Tutorial")
estimator = Estimator(source_directory=project_folder,
compute_target=compute_target,
entry_script='script.py')
# Attach environment to estimator run config
estimator.run_config.environment = curated_environment
Afaik, the Estimator class needs to always use a Custom Environment, probably because it always creates a Docker Image under the covers?
However, for simplicity's sake, it should be able to use a curated Environment (like you actually can do with the ScriptRunConfig class).
If you try to use a curated environment you get this error:
Error: "Environment name can not start with the prefix AzureML. To alter a curated environment first create a copy of it."
Therefore, you need to copy/clone a curated environment first, which is also not straightforward and needs the following code:
If the Estimator could use a curated environment like you can do it with the ScriptRunConfig class, you would simply need the following code: