Skip to content

Commit 829e990

Browse files
committed
update execute script modules
1 parent 4f9b9b0 commit 829e990

File tree

3 files changed

+44
-6
lines changed

3 files changed

+44
-6
lines changed

articles/machine-learning/algorithm-module-reference/execute-python-script.md

Lines changed: 41 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ ms.custom: devx-track-python
1010

1111
author: likebupt
1212
ms.author: keli19
13-
ms.date: 09/29/2020
13+
ms.date: 10/21/2020
1414
---
1515
# Execute Python Script module
1616

@@ -115,9 +115,47 @@ The Execute Python Script module contains sample Python code that you can use as
115115

116116
![Execute Python input map](media/module/python-module.png)
117117

118-
4. To include new Python packages or code, add the zipped file that contains these custom resources on **Script bundle**. The input to **Script bundle** must be a zipped file uploaded to your workspace as a file type dataset. You can upload the dataset on the **Datasets** asset page. You can drag the dataset module from the **My datasets** list in the left module tree on the designer authoring page.
118+
4. To include new Python packages or code, connect the zipped file that contains these custom resources to **Script bundle** port. Or if your script is larger than 16 KB, use the **Script Bundle** port to avoid errors like *CommandLine exceeds the limit of 16597 characters*.
119119

120-
Any file contained in the uploaded zipped archive can be used during pipeline execution. If the archive includes a directory structure, the structure is preserved, but you must prepend a directory called **src** to the path.
120+
121+
1. Bundle the script and other custom resources to a zip file.
122+
1. Upload the zip file as a **File Dataset** to the studio.
123+
1. Drag the dataset module from the *Datasets* list in the left module pane in the designer authoring page.
124+
1. Connect the dataset module to the **Script Bundle** port of **Execute R Script** module.
125+
126+
Any file contained in the uploaded zipped archive can be used during pipeline execution. If the archive includes a directory structure, the structure is preserved.
127+
128+
Following is a script bundle example, which contains a python script file and a txt file:
129+
130+
> [!div class="mx-imgBorder"]
131+
> ![Script bundle example](media/module/python-script-bundle.png)
132+
133+
Following is the content of `my_script.py`:
134+
135+
```python
136+
def my_func(dataframe1):
137+
return dataframe1
138+
```
139+
Following is sample code showing how to consume the files in the script bundle:
140+
141+
```python
142+
import pandas as pd
143+
from my_script import my_func
144+
145+
def azureml_main(dataframe1 = None, dataframe2 = None):
146+
147+
# Execution logic goes here
148+
print(f'Input pandas.DataFrame #1: {dataframe1}')
149+
150+
# Test the custom defined python function
151+
dataframe1 = my_func(dataframe1)
152+
153+
# Test to read custom uploaded files by relative path
154+
with open('./Script Bundle/my_sample.txt', 'r') as text_file:
155+
sample = text_file.read()
156+
157+
return dataframe1, pd.DataFrame(columns=["Sample"], data=[[sample]])
158+
```
121159

122160
5. In the **Python script** text box, type or paste valid Python script.
123161

articles/machine-learning/algorithm-module-reference/execute-r-script.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ ms.topic: reference
99

1010
author: likebupt
1111
ms.author: keli19
12-
ms.date: 07/27/2020
12+
ms.date: 10/21/2020
1313
---
1414

1515
# Execute R Script module
@@ -190,11 +190,11 @@ Datasets stored in the designer are automatically converted to an R data frame w
190190
> [!NOTE]
191191
> Existing R code might need minor changes to run in a designer pipeline. For example, input data that you provide in CSV format should be explicitly converted to a dataset before you can use it in your code. Data and column types used in the R language also differ in some ways from the data and column types used in the designer.
192192
193-
If your script is larger than 16 KB, use the **Script Bundle** port to avoid errors like *CommandLine exceeds the limit of 16597 characters*.
193+
1. If your script is larger than 16 KB, use the **Script Bundle** port to avoid errors like *CommandLine exceeds the limit of 16597 characters*.
194194
195195
1. Bundle the script and other custom resources to a zip file.
196196
1. Upload the zip file as a **File Dataset** to the studio.
197-
1. Drag the dataset module from the *My datasets* list in the left module pane in the designer authoring page.
197+
1. Drag the dataset module from the *Datasets* list in the left module pane in the designer authoring page.
198198
1. Connect the dataset module to the **Script Bundle** port of **Execute R Script** module.
199199
200200
Following is the sample code to consume the script in the script bundle:
7.01 KB
Loading

0 commit comments

Comments
 (0)