diff --git a/cli/assets/component/README.md b/cli/assets/component/README.md index 3a0cda5223..1fa8846cc9 100644 --- a/cli/assets/component/README.md +++ b/cli/assets/component/README.md @@ -96,6 +96,18 @@ As `learning_rate` and `learning_rate_schedule` have default value defined which python train.py --training_data some_input_path --max_epocs 10 --learning_rate 0.01 --learning_rate_schedule time-based --model_output some_output_path ``` +## Adding common libraries/dependencies to components +In complex machine learning projects, it is common for multiple components to use the same libraries/dependencies. To avoid duplicating these in each component, we provide a way to add common libraries/dependencies to a component. You can add `addtional_includes` propertity to `command` component yaml, and specify the common libraries/dependencies in this property. you can add any file or folder to the `additional_includes` property. + +Here is an example of how to add local files and folders to the `additional_includes` property: + +```yaml +additional_includes: + - your/local/folder + - your/local/file +``` + + To learn more details about `az ml component` commands, Please refer [this link](https://docs.microsoft.com/en-us/cli/azure/ml/component?view=azure-cli-latest). To learn more details about `component` , Please refer [this link](https://docs.microsoft.com/en-us/azure/machine-learning/concept-component). diff --git a/cli/assets/component/common_src/helper.py b/cli/assets/component/common_src/helper.py new file mode 100644 index 0000000000..d5632bd739 --- /dev/null +++ b/cli/assets/component/common_src/helper.py @@ -0,0 +1,2 @@ +def helper_function(): + print("Hello from helper_function") diff --git a/cli/assets/component/component_additional_includes.yml b/cli/assets/component/component_additional_includes.yml new file mode 100644 index 0000000000..aff3ad5942 --- /dev/null +++ b/cli/assets/component/component_additional_includes.yml @@ -0,0 +1,13 @@ +$schema: https://azuremlschemas.azureedge.net/latest/commandComponent.schema.json +name: component_additional_include_cli +display_name: component_additional_include_cli +description: A example of component using additional includes +tags: + author: azureml-sdk-team +type: command +code: ./component_src +environment: azureml:AzureML-sklearn-1.0-ubuntu20.04-py38-cpu:1 +additional_includes: + - common_src +command: >- + python component.py diff --git a/cli/assets/component/component_src/component.py b/cli/assets/component/component_src/component.py new file mode 100644 index 0000000000..ec8a40ed2b --- /dev/null +++ b/cli/assets/component/component_src/component.py @@ -0,0 +1,3 @@ +from common_src.helper import helper_function + +helper_function() diff --git a/sdk/python/assets/component/common_src/helper.py b/sdk/python/assets/component/common_src/helper.py new file mode 100644 index 0000000000..d5632bd739 --- /dev/null +++ b/sdk/python/assets/component/common_src/helper.py @@ -0,0 +1,2 @@ +def helper_function(): + print("Hello from helper_function")