We have created an environment in azure ML shared registry. The environment was built into the registry. Here is what it looks like:
A DevOps pipeline creates this environment:
az ml environment create --name "$azureEnvPrefix" --build-context $dockerContext --dockerfile-path Dockerfile --registry-name $REGISTRY_NAME --tag "dev-$timestamp producer-CI"
The environment seems fine. But, when we use the same environment in ml pipeline using:
try:
cred = ManagedIdentityCredential()
ml_client_registry = MLClient(credential=cred,
registry_name=e.registry_name,
registry_location=e.registry_region)
registyr_envs = [env for env in ml_client_registry.environments.list(e.monitoring)]
except Exception as e:
print("Unable to get environment")
raise e
environment_monitoring = ml_client_registry.environments.get(name=monitoring, version=registyr_envs[0].version)
It works but using this environment with runconfig for a PythonScriptStep results in error:
run_config_monitoring = RunConfiguration()
run_config_monitoring.environment = environment_monitoring
param_actuals_feature_name = PipelineParameter(
name='actuals_feature_name', default_value='payment_amt_acc')
StepMonitoring = PythonScriptStep(
script_name=e.script_path,
arguments=["--actuals_feature_name", param_actuals_feature_name],
source_directory=e.sources_directory,
name='Monitoring',
compute_target=aml_compute_cpu,
allow_reuse=False,
runconfig=run_config_monitoring
)
step_sequence = StepSequence(steps=[StepMonitoring])
pipeline = Pipeline(workspace=ws, steps=step_sequence)
It results in error:
Traceback (most recent call last): File "/anaconda/envs/localpy38/lib/python3.8/runpy.py", line 194, in _run_module_as_main return _run_code(code, main_globals, None, File "/anaconda/envs/localpy38/lib/python3.8/runpy.py", line 87, in _run_code exec(code, run_globals) File "/mnt/batch/tasks/shared/LS_root/mounts/clusters/ourrehmansweden/code/Users/ourrehman/Sweden_cashflow_forecasting_aml/ml_service/pipelines/build_pipeline_active_monitoring.py", line 157, in main(args) File "/mnt/batch/tasks/shared/LS_root/mounts/clusters/ourrehmansweden/code/Users/ourrehman/Sweden_cashflow_forecasting_aml/ml_service/pipelines/build_pipeline_active_monitoring.py", line 70, in main environment_active_monitoring = ml_client_registry.environments.get(name=e.aml_env_name_active_monitoring, version=registyr_envs[0].version) File "/anaconda/envs/localpy38/lib/python3.8/site-packages/azureml/core/_experiment_method.py", line 104, in wrapper return init_func(self, *args, **kwargs) File "/anaconda/envs/localpy38/lib/python3.8/site-packages/azureml/pipeline/core/pipeline.py", line 180, in init self._graph = self._graph_builder.build(self._name, steps, finalize=False) File "/anaconda/envs/localpy38/lib/python3.8/site-packages/azureml/pipeline/core/builder.py", line 1497, in build graph = self.construct(name, steps) File "/anaconda/envs/localpy38/lib/python3.8/site-packages/azureml/pipeline/core/builder.py", line 1519, in construct self.process_collection(steps) File "/anaconda/envs/localpy38/lib/python3.8/site-packages/azureml/pipeline/core/builder.py", line 1555, in process_collection builder.process_collection(collection) File "/anaconda/envs/localpy38/lib/python3.8/site-packages/azureml/pipeline/core/builder.py", line 1809, in process_collection nodes = self._base_builder.process_collection(item) File "/anaconda/envs/localpy38/lib/python3.8/site-packages/azureml/pipeline/core/builder.py", line 1549, in process_collection return self.process_step(collection) File "/anaconda/envs/localpy38/lib/python3.8/site-packages/azureml/pipeline/core/builder.py", line 1593, in process_step node = step.create_node(self._graph, self._default_datastore, self._context) File "/anaconda/envs/localpy38/lib/python3.8/site-packages/azureml/pipeline/steps/python_script_step.py", line 243, in create_node return super(PythonScriptStep, self).create_node( File "/anaconda/envs/localpy38/lib/python3.8/site-packages/azureml/pipeline/core/_python_script_step_base.py", line 156, in create_node module_builder=module_builder, runconfig=repr(self._runconfig)) File "/anaconda/envs/localpy38/lib/python3.8/site-packages/azureml/core/runconfig.py", line 1352, in repr run_config_dict = _serialize_to_dict(self) File "/anaconda/envs/localpy38/lib/python3.8/site-packages/azureml/core/_serialization_utils.py", line 44, in _serialize_to_dict result[name] = field_info.field_type._serialize_to_dict( File "/anaconda/envs/localpy38/lib/python3.8/site-packages/azureml/core/environment.py", line 1685, in _serialize_to_dict if environment.python.conda_dependencies is not None: AttributeError: 'Environment' object has no attribute 'python'
I see that the code which complains is azureml/core/environment.py", line 1685:
if environment is not None and not isinstance(environment, EnvironmentReference):
if environment.python.conda_dependencies is not None:
inline = environment.python.conda_dependencies._conda_dependencies
environment_dict["python"]["condaDependencies"] = inline
Is there something that I am missing, or we can't use environments like this? Would be thankful if anyone could help!
