Skip to content

Commit 8750696

Browse files
authored
Merge pull request #40 from v-vfarias/main
Update scripts and instructions Lab06
2 parents 4ecc3fd + 99e4103 commit 8750696

File tree

5 files changed

+10022
-17
lines changed

5 files changed

+10022
-17
lines changed

.github/workflows/manual-trigger-job.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,10 @@ jobs:
1212
- name: Install az ml extension
1313
run: az extension add -n ml -y
1414
- name: Azure login
15-
uses: azure/login@v1
15+
uses: azure/login@v2
1616
with:
1717
creds: ${{secrets.AZURE_CREDENTIALS}}
18+
- name: Run Azure Machine Learning training job
19+
run: az ml job create -f src/job.yml --stream --resource-group ${{vars.AZURE_RESOURCE_GROUP}} --workspace-name ${{vars.AZURE_WORKSPACE_NAME}}
1820

1921

.github/workflows/train-dev.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
uses: actions/checkout@v4
2424

2525
- name: Sign in to Azure
26-
uses: azure/login@v1
26+
uses: azure/login@v2
2727
with:
2828
creds: ${{ secrets.AZURE_CREDENTIALS }}
2929

@@ -59,7 +59,7 @@ jobs:
5959
az ml job create \
6060
-f src/job.yml \
6161
--name "$JOB_NAME" \
62-
--set inputs.training_data=azureml:diabetes-dev-folder@latest \
62+
--set inputs.training_data.path=azureml:diabetes-dev-folder@latest \
6363
--stream | tee training_output.log
6464
6565
- name: Extract dev metrics from logs

.github/workflows/train-prod.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
uses: actions/checkout@v4
2222

2323
- name: Sign in to Azure
24-
uses: azure/login@v1
24+
uses: azure/login@v2
2525
with:
2626
creds: ${{ secrets.AZURE_CREDENTIALS }}
2727

@@ -57,7 +57,7 @@ jobs:
5757
az ml job create \
5858
-f src/job.yml \
5959
--name "$JOB_NAME" \
60-
--set inputs.training_data=azureml:diabetes-prod-folder@latest \
60+
--set inputs.training_data.path=azureml:diabetes-prod-folder@latest \
6161
--stream | tee training_output.log
6262
6363
- name: Extract prod metrics from logs

docs/06-automate-model-training.md

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ To let GitHub Actions authenticate to Azure Machine Learning, you use a service
6969
1. In the Azure portal, select the **[>_]** (**Cloud Shell**) button at the top of the page to open Cloud Shell.
7070
1. Select **Bash** if you are prompted to choose a shell type.
7171
1. Make sure the correct subscription is selected for your Azure Machine Learning workspace.
72-
1. In Cloud Shell, create a service principal that has **Contributor** access to the resource group that contains your Azure Machine Learning workspace. Replace `<service-principal-name>`, `<subscription-id>`, and `<your-resource-group-name>` with your own values before you run the command:
72+
1. In Cloud Shell, create a service principal that has **Contributor** access to the resource group that contains your Azure Machine Learning workspace. Replace `<service-principal-name>`, `<subscription-id>`, and `<your-resource-group-name>` with your own values before you run the command. Use a descriptive name such as `sp-mslearn-mlops-github`:
7373

7474
```azurecli
7575
az ad sp create-for-rbac --name "<service-principal-name>" --role contributor \
@@ -82,6 +82,9 @@ To let GitHub Actions authenticate to Azure Machine Learning, you use a service
8282
1. Select **New repository secret**.
8383
1. Enter `AZURE_CREDENTIALS` as the **Name** of the secret.
8484
1. Paste the JSON output from the `az ad sp create-for-rbac` command into the **Value** field and select **Add secret**.
85+
1. Select the **Variables** tab and then select **New repository variable**.
86+
1. Enter `AZURE_RESOURCE_GROUP` as the **Name** and your resource group name (for example, `rg-ai300-l<suffix>`) as the **Value**. Select **Add variable**.
87+
1. Select **New repository variable** again. Enter `AZURE_WORKSPACE_NAME` as the **Name** and your Azure Machine Learning workspace name (for example, `mlw-ai300-l<suffix>`) as the **Value**. Select **Add variable**.
8588

8689
Your GitHub repository now has an encrypted secret that GitHub-hosted runners can use to sign in to Azure and submit jobs to your Azure Machine Learning workspace.
8790

@@ -92,8 +95,8 @@ Your GitHub repository now has an encrypted secret that GitHub-hosted runners ca
9295

9396
Before you automate training from GitHub, review how your Azure Machine Learning workspace controls network access.
9497

95-
1. In Azure Machine Learning studio, select **Manage** in the left navigation and then select **Networking** under your workspace.
96-
1. Review the **Public access** and **Private endpoints** settings. Note how you can:
98+
1. In **Azure Portal** on your Azure Machine Learning workspace, select **Settings** in the left navigation and then select **Networking**.
99+
1. Review the **Public access** and the **Private endpoints** settings. Note how you can:
97100
- Allow public network access from all networks.
98101
- Restrict access to specific IP ranges.
99102
- Disable public network access and rely on private endpoints.
@@ -109,22 +112,21 @@ Now that you understand the network options, you are ready to automate a trainin
109112
In this section, you connect your GitHub workflow to Azure Machine Learning and run a command job to train a model. The workflow uses the `AZURE_CREDENTIALS` secret you created earlier.
110113

111114
1. Clone your `mslearn-mlops` repository that you created from the template to a development environment where you can edit files and push changes back to GitHub.
112-
1. In the cloned repository, locate the `.github/workflows/manual-trigger.yml` workflow file.
113-
1. Open `manual-trigger.yml` and review the existing steps. The workflow should:
115+
1. In the cloned repository, locate the `.github/workflows/manual-trigger-job.yml` workflow file.
116+
1. Open `manual-trigger-job.yml` and review the existing steps. The workflow should:
114117
- Check out the repository code.
115-
- Use the `AZURE_CREDENTIALS` secret to sign in to Azure.
116118
- Install the Azure Machine Learning CLI extension.
117-
1. At the end of the workflow, add a new step that submits the Azure Machine Learning job defined in `src/job.yml`. For example:
119+
- Use the `AZURE_CREDENTIALS` secret to sign in to Azure via `azure/login@v2`.
120+
1. At the end of the workflow, add a new step that submits the Azure Machine Learning job defined in `src/job.yml`. The command requires explicit `--resource-group` and `--workspace-name` flags, supplied from the GitHub Actions variables you created:
118121

119122
```yml
120123
- name: Run Azure Machine Learning training job
121-
run: |
122-
az ml job create -f src/job.yml --stream
124+
run: az ml job create -f src/job.yml --stream --resource-group ${{vars.AZURE_RESOURCE_GROUP}} --workspace-name ${{vars.AZURE_WORKSPACE_NAME}}
123125
```
124126

125127
1. Save your changes, commit them to your local repository, and push the changes to the **main** branch of your fork.
126128
1. In GitHub, go to the **Actions** tab for your repository.
127-
1. Select the workflow defined in `manual-trigger.yml` and use **Run workflow** to start it manually.
129+
1. Select the workflow defined in `manual-trigger-job.yml` and use **Run workflow** to start it manually.
128130
1. Wait for the workflow run to complete. Verify that the **Run Azure Machine Learning training job** step completes successfully.
129131
1. In Azure Machine Learning studio, select **Jobs** and confirm that a new job based on `src/job.yml` has run successfully. Review the job inputs, metrics, and logs.
130132

@@ -134,7 +136,7 @@ You have now automated the training job by using a GitHub Actions workflow that
134136

135137
Running workflows manually is useful for initial testing, but in a team environment you usually want training workflows to run automatically when someone proposes a change. Next, you update the existing workflow so it runs for pull requests, and then you use feature branches and branch protection rules to control when the workflow runs.
136138

137-
1. In your GitHub repository, open the `.github/workflows/manual-trigger.yml` workflow file.
139+
1. In your GitHub repository, open the `.github/workflows/manual-trigger-job.yml` workflow file.
138140
1. Update the `on` section so that the workflow can run both manually and when a pull request targets the **main** branch. For example:
139141

140142
```yml
@@ -167,7 +169,7 @@ Running workflows manually is useful for initial testing, but in a team environm
167169
```
168170

169171
1. In GitHub, create a pull request from your feature branch into **main**.
170-
1. On the pull request page, observe that the workflow defined in `manual-trigger.yml` runs automatically because of the `pull_request` trigger you added.
172+
1. On the pull request page, observe that the workflow defined in `manual-trigger-job.yml` runs automatically because of the `pull_request` trigger you added.
171173
1. After the workflow completes successfully, review the results and then complete the pull request to merge your changes into **main**.
172174

173175
By using feature branches, branch protection rules, and pull request–triggered workflows with the same training workflow definition, you ensure that model training automation is tied to controlled changes in source control.

0 commit comments

Comments
 (0)