I want to create Azure Machine Learning component with custom environment. I’ve created the Environment and uploaded it to my workspace.
from azure.ai.ml.entities import Environment
from azure.ai.ml.entities import BuildContext
custom_env_name = "aml-my-custom-env"
custom_job_env = Environment(
build=BuildContext(path="path/to/folder/with/Dockerfile"),
name=custom_env_name,
version='1',
description="Custom environment",
tags={},
)
I can see it in UI in Azure that it’s created. Now I want to create component with the yml file.
YML configuration file
name: my_component
display_name: Run test code
version: 1
type: command
inputs:
data_path:
type: uri_folder
code: .
environment:
name: aml-my-custom-env
version: 1
command: >-
python test_code.py
--data_path ${{inputs.data_path}}
Code
from azure.ai.ml import load_component
data_component = load_component(source=os.path.join(ROOT_PATH, 'configs', "my_component.yml"))
data_component = workspace_ml_client.create_or_update(data_component)
But I’m getting this error:
1) Ensure all parameters required by the Environment schema are specified.
If using the CLI, you can also check the full log in debug mode for more details by adding –debug to the end of your command
I also tried passing only the environment name as a value and the Asset ID, but still cannot run it. I also tried to run it on a different environment which I used for a different job, and I’m still getting the same errors. Do you know what could be wrong here?
Okay, I found what was an issue. The problem was I previously created this component but with a different environment. And because the environment field is not mutable when I tried to update the old one I got this kind of error (for me it’s a little bit confusing but OK). However, if someone will have the same issue how to correctly link your environment inside the yml file here is the correct version:
name: my_component
display_name: Run test code
version: 1
type: command
inputs:
data_path:
type: uri_folder
code: .
environment: azureml:aml-my-custom-env@1
command: >-
python test_code.py
--data_path ${{inputs.data_path}}