Skip to content

Commit

Permalink
Add additional includes example (#2341)
Browse files Browse the repository at this point in the history
* update

* use sdk readme in master

* revert to master

* reformat
  • Loading branch information
cloga authored Jun 5, 2024
1 parent c8bc451 commit 6027ae5
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 0 deletions.
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")

0 comments on commit 6027ae5

Please sign in to comment.