GitHub Action that allows you to submit a run to your Azure Machine Learning Workspace.
Перейти к файлу
Marvin Buss 3b6e330848 added artifact download 2020-05-07 01:26:41 +02:00
.cloud/.azure added artifact download 2020-05-07 01:26:41 +02:00
.github/workflows updated lint workflow 2020-05-03 09:29:25 +02:00
code added artifact download 2020-05-07 01:26:41 +02:00
tests lint 2020-05-03 09:44:36 +02:00
.gitignore added schema validation partially 2020-04-29 19:15:28 +02:00
CODE_OF_CONDUCT.md Initial CODE_OF_CONDUCT.md commit 2020-03-12 10:15:32 -07:00
Dockerfile updated python sdk 2020-04-30 15:25:04 +02:00
LICENSE Initial LICENSE commit 2020-03-12 10:15:34 -07:00
README.md added artifact download 2020-05-07 01:26:41 +02:00
SECURITY.md Initial SECURITY.md commit 2020-03-12 10:15:36 -07:00
action.yml added artifact download 2020-05-07 01:26:41 +02:00

README.md

Integration Test Lint

Azure Machine Learning Run Action

Usage

The Azure Machine Learning Run action will allow you to submit a run (Estimator, ML Pipeline, ScriptRunConfig or AutoMLConfig) to your Azure Machine Learning Workspace. To submit a run, you have to define

  1. Your python file(s) that should run remotely and

  2. a) Either a runconfig YAML file (default "code/train/run_config.yml"), which describes your Azure Machine Learning Script Run that you want to submit. You can change the default value with the runconfig_yaml_file parameter.

    b) or a Pipeline YAML file (default "code/train/pipeline.yml"), which describes your Azure Machine Learning Pipeline that you want to submit. You can change the default value with the pipeline_yaml_file parameter.

    c) or a python script (default code/train/run_config.py) which includes a function (default def main(workspace):) that describes your run that you want to submit. The python script gets the workspace object injected and has to return one of the following objects:

    If you want to change the default values for the python script, you can specify it with the runconfig_python_file and runconfig_python_function_name parameters.

This action requires an AML workspace to be created or attached to via the aml-workspace action and some compute resources to be available, which can be managed via the aml-compute action.

Template repositories

This action is one in a series of actions that can be used to setup an ML Ops process. Examples of these can be found at

  1. Simple example: ml-template-azure and
  2. Comprehensive example: aml-template.

Example workflow

name: My Workflow
on: [push, pull_request]
jobs:
  build:
    runs-on: ubuntu-latest
    steps:
    # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
    - name: Check Out Repository
      id: checkout_repository
      uses: actions/checkout@v2

    # AML Workspace Action
    - uses: Azure/aml-workspace@v1
      id: aml_workspace
      with:
        azure_credentials: ${{ secrets.AZURE_CREDENTIALS }}

    # AML Run Action
    - uses: Azure/aml-run@v1
      id: aml_run
      with:
        # required inputs as secrets
        azure_credentials: ${{ secrets.AZURE_CREDENTIALS }}
        # optional
        parameters_file: "run.json"

Inputs

Input Required Default Description
azure_credentials x - Output of az ad sp create-for-rbac --name <your-sp-name> --role contributor --scopes /subscriptions/<your-subscriptionId>/resourceGroups/<your-rg> --sdk-auth. This should be stored in your secrets
parameters_file "compute.json" JSON file in the .cloud/.azure folder specifying your Azure Machine Learning compute target details.

Azure Credentials

Azure credentials are required to connect to your Azure Machine Learning Workspace. These may have been created for an action you are already using in your repository, if so, you can skip the steps below.

Install the Azure CLI on your computer or use the Cloud CLI and execute the following command to generate the required credentials:

# Replace {service-principal-name}, {subscription-id} and {resource-group} with your Azure subscription id and resource group name and any name for your service principle
az ad sp create-for-rbac --name {service-principal-name} \
                         --role contributor \
                         --scopes /subscriptions/{subscription-id}/resourceGroups/{resource-group} \
                         --sdk-auth

This will generate the following JSON output:

{
  "clientId": "<GUID>",
  "clientSecret": "<GUID>",
  "subscriptionId": "<GUID>",
  "tenantId": "<GUID>",
  (...)
}

Add this JSON output as a secret with the name AZURE_CREDENTIALS in your GitHub repository.

Parameter File

The action tries to load a JSON file in the .cloud/.azure folder in your repository, which specifies details of your Azure Machine Learning Run. By default, the action is looking for a file with the name "run.json". If your JSON file has a different name, you can specify it with this parameter. Note that none of these values are required and in the absence, defaults will be created with a combination of the repo name and branch name.

A sample file can be found in this repository in the folder .cloud/.azure. The JSON file can include the following parameters:

Parameter Name Required Allowed Values Default Description
experiment_name str <REPOSITORY_NAME>-<BRANCH_NAME> The name of your experiment in AML, which must be 3-36 characters, start with a letter or a number, and can only contain letters, numbers, underscores, and dashes.
tags dict: {"": "", ...} null Tags to be added to the submitted run.
wait_for_completion bool true Indicates whether the action will wait for completion of the run
runconfig_python_file str "code/train/run_config.py" Path to the python script in your repository in which you define your run and return an Estimator, Pipeline, AutoMLConfig or ScriptRunConfig object.
runconfig_python_function_name str "main" The name of the function in your python script in your repository in which you define your run and return an Estimator, Pipeline, AutoMLConfig or ScriptRunConfig object. The function gets the workspace object passed as an argument.
runconfig_yaml_file str "code/train/run_config.yml" The name of your runconfig YAML file.
pipeline_yaml_file str "code/train/pipeline.yml" The name of your pipeline YAML file.
pipeline_publish bool false Indicates whether the action will publish the pipeline after submitting it to Azure Machine Learning. This only works if you submitted a pipeline.
pipeline_name str <REPOSITORY_NAME>-<BRANCH_NAME> The name of the published pipeline.
pipeline_version str null The version of the published pipeline.
pipeline_continue_on_step_failure bool false Indicates whether the published pipeline will continue execution of other steps in the PipelineRun if a step fails.
download_artifacts bool false Indicates whether the created artifacts and logs from runs, pipelines and steps will be downloaded to your GitHub workspace. This only works if wait_for_completion is set to true.

Outputs

Output Description
experiment_name Name of the experiment of the run
run_id ID of the run
run_url URL to the run in the Azure Machine Learning Studio
run_metrics Metrics of the run (will only be provided if wait_for_completion is set to True)
run_metrics_markdown Metrics of the run formatted as markdown table (will only be provided if wait_for_completion is set to True)
published_pipeline_id Id of the published pipeline (will only be provided if you submitted a pipeline and pipeline_publish is set to True)
published_pipeline_status Status of the published pipeline (will only be provided if you submitted a pipeline and pipeline_publish is set to True)
published_pipeline_endpoint Endpoint of the published pipeline (will only be provided if you submitted a pipeline and pipeline_publish is set to True)
artifact_path Path of downloaded artifacts and logs from Azure Machine Learning (pipeline) run (will only be provided if wait_for_completion and download_artifacts is set to True)

Other Azure Machine Learning Actions

  • aml-workspace - Connects to or creates a new workspace
  • aml-compute - Connects to or creates a new compute target in Azure Machine Learning
  • aml-run - Submits a ScriptRun, an Estimator or a Pipeline to Azure Machine Learning
  • aml-registermodel - Registers a model to Azure Machine Learning
  • aml-deploy - Deploys a model and creates an endpoint for the model

Contributing

This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.opensource.microsoft.com.

When you submit a pull request, a CLA bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.