Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add additional includes example #2341

Merged
merged 7 commits into from
Jun 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions cli/assets/component/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down
2 changes: 2 additions & 0 deletions cli/assets/component/common_src/helper.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
def helper_function():
print("Hello from helper_function")
13 changes: 13 additions & 0 deletions cli/assets/component/component_additional_includes.yml
Original file line number Diff line number Diff line change
@@ -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
3 changes: 3 additions & 0 deletions cli/assets/component/component_src/component.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from common_src.helper import helper_function

helper_function()
2 changes: 2 additions & 0 deletions sdk/python/assets/component/common_src/helper.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
def helper_function():
print("Hello from helper_function")
Loading