Skip to content

Commit aa35772

Browse files
Merge pull request #216523 from Blackmist/training-update
Adding upload of training script
2 parents e36d974 + 67666dc commit aa35772

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

articles/machine-learning/how-to-train-model.md

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -116,14 +116,16 @@ The REST API examples in this article use `$SUBSCRIPTION_ID`, `$RESOURCE_GROUP`,
116116

117117
Administrative REST requests a [service principal authentication token](how-to-manage-rest.md#retrieve-a-service-principal-authentication-token). You can retrieve a token with the following command. The token is stored in the `$TOKEN` environment variable:
118118

119-
```azurecli
120-
TOKEN=$(az account get-access-token --query accessToken -o tsv)
121-
```
119+
:::code language="azurecli" source="~/azureml-examples-main/deploy-arm-templates-az-cli.sh" id="get_access_token":::
122120

123121
The service provider uses the `api-version` argument to ensure compatibility. The `api-version` argument varies from service to service. Set the API version as a variable to accommodate future versions:
124122

125123
:::code language="rest-api" source="~/azureml-examples-main/cli/deploy-rest.sh" id="api_version":::
126124

125+
When you train using the REST API, data and training scripts must be uploaded to a storage account that the workspace can access. The following example gets the storage information for your workspace and saves it into variables so we can use it later:
126+
127+
:::code language="azurecli" source="~/azureml-examples-main/deploy-arm-templates-az-cli.sh" id="get_storage_details":::
128+
127129
---
128130

129131
### 2. Create a compute resource for training
@@ -211,9 +213,15 @@ You can use the stored run ID to return information about the job. The `--web` p
211213

212214
# [REST API](#tab/restapi)
213215

214-
As part of job submission, the training scripts and data must be uploaded to a cloud storage location that your AzureML workspace can access. These examples don't cover the uploading process. For information on using the Blob REST API to upload files, see the [Put Blob](/rest/api/storageservices/put-blob) reference.
216+
As part of job submission, the training scripts and data must be uploaded to a cloud storage location that your AzureML workspace can access.
217+
218+
1. Use the following Azure CLI command to upload the training script. The command specifies the _directory_ that contains the files needed for training, not an individual file. If you'd like to use REST to upload the data instead, see the [Put Blob](/rest/api/storageservices/put-blob) reference:
219+
220+
```azurecli
221+
az storage blob upload-batch -d $AZUREML_DEFAULT_CONTAINER/testjob -s cli/jobs/single-step/scikit-learn/iris/src/ --account-name $AZURE_STORAGE_ACCOUNT
222+
```
215223
216-
1. Create a versioned reference to the training data. In this example, the data is located at `https://azuremlexamples.blob.core.windows.net/datasets/iris.csv`. In your workspace, you might upload the file to the default storage for your workspace:
224+
1. Create a versioned reference to the training data. In this example, the data is already in the cloud and located at `https://azuremlexamples.blob.core.windows.net/datasets/iris.csv`. For more information on referencing data, see [Data in Azure Machine Learning](concept-data.md):
217225
218226
```bash
219227
DATA_VERSION=$RANDOM
@@ -229,7 +237,7 @@ As part of job submission, the training scripts and data must be uploaded to a c
229237
}"
230238
```
231239
232-
1. Register a versioned reference to the training script for use with a job. In this example, the script is located at `https://azuremlexamples.blob.core.windows.net/azureml-blobstore-c8e832ae-e49c-4084-8d28-5e6c88502655/testjob`. This `testjob` is the folder in Blob storage that contains the training script and any dependencies needed by the script. In the following example, the ID of the versioned training code is returned and stored in the `$TRAIN_CODE` variable:
240+
1. Register a versioned reference to the training script for use with a job. In this example, the script location is the default storage account and container you uploaded to in step 1. The ID of the versioned training code is returned and stored in the `$TRAIN_CODE` variable:
233241
234242
```bash
235243
TRAIN_CODE=$(curl --location --request PUT "https://management.azure.com/subscriptions/$SUBSCRIPTION_ID/resourceGroups/$RESOURCE_GROUP/providers/Microsoft.MachineLearningServices/workspaces/$WORKSPACE/codes/train-lightgbm/versions/1?api-version=$API_VERSION" \
@@ -238,7 +246,7 @@ As part of job submission, the training scripts and data must be uploaded to a c
238246
--data-raw "{
239247
\"properties\": {
240248
\"description\": \"Train code\",
241-
\"codeUri\": \"https://azuremlexamples.blob.core.windows.net/azureml-blobstore-c8e832ae-e49c-4084-8d28-5e6c88502655/testjob\"
249+
\"codeUri\": \"https://$AZURE_STORAGE_ACCOUNT.blob.core.windows.net/$AZUREML_DEFAULT_CONTAINER/testjob\"
242250
}
243251
}" | jq -r '.id')
244252
```

0 commit comments

Comments
 (0)