aml-run icon indicating copy to clipboard operation
aml-run copied to clipboard

Cannot import yaml library in runconfig_python_file, no traceback

Open NilsHahnBayer opened this issue 2 years ago • 0 comments

Hi,

I am trying to utilize this GitHub Action for a simple CI pipeline. Unfortunately it offers no helpful traceback when it fails. There seems to be an issue when I tray to extend the runconfig_python_file. I am currently using the runconfig_python_file from the test folder an simply adding a few lines of code. One thing I tried to do, was reading a yaml file to make the script more configurable.

Unfortunately then the Action fails already when I just want to import the yaml library without any helpful error information.

Script:

import os
import yaml

from azureml.core import (
    Workspace,
    Experiment,
    ComputeTarget,
    Environment,
    ScriptRunConfig,
)

def main(workspace):
    ws = workspace
    print("Workspace Name: \t{}".format(ws.name))
    print("Resource Group: \t{}".format(ws.resource_group))
    print("Location: \t\t{}".format(ws.location))
    print("Subscription ID: \t{}".format(ws.subscription_id))

    compute_name = 'my-compute'
    compute_target = ws.compute_targets[compute_name]
    print("Compute Cluster Name: \t{}".format(compute_name))

    print("Loading Environment")
    my_env= Environment.from_conda_specification(
        name="my_env",
        file_path="code/environment.yml"
    )

    tasks_source_dir =  '/tasks' 

    print("Loading script parameters")
    script_args = [
        "--kernel", "linear",
        "--penalty", 1.0
    ]
    
    print("Creating run config")
    run_config = ScriptRunConfig(
        source_directory=tasks_source_dir,
        script="T01_Test_Task.py",
        arguments=script_args,
        run_config="",
        compute_target=compute_target,
        environment=my_env
    )

    return run_config

GitHub Action YAML:

# Actions train a model on Azure Machine Learning
name: Continous Integration
on:
  push:
    branches:
      - dev
    # paths:
    #   - 'code/*'
jobs:
  train:
    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
      
    - name: Python Set Up
      uses: actions/setup-python@v4
      with:
        python-version: '3.8'
        # cache: 'pip'
    - run: pip install -r requirements.txt  # this requirements.txt contains pyyaml
    
    # Connect or Create the Azure Machine Learning Workspace
    - name: Connect/Create Azure Machine Learning Workspace
      id: aml_workspace
      uses: Azure/aml-workspace@v1
      with:
          azure_credentials: ${{ secrets.AZURE_CREDENTIALS }}
    
    # Connect or Create a Compute Target in Azure Machine Learning
    - name: Connect/Create Azure Machine Learning Compute Target
      id: aml_compute_training
      uses: Azure/aml-compute@v1
      with:
          azure_credentials: ${{ secrets.AZURE_CREDENTIALS }}
    
    # Submit a training run to the Azure Machine Learning
    - name: Submit training run
      id: aml_run
      uses: Azure/aml-run@v1
      with:
          azure_credentials: ${{ secrets.AZURE_CREDENTIALS }}
          parameters_file: "run.json"

Traceback (most recent call last):
  File "/code/main.py", line 240, in <module>
    main()
	Message: Failed to load RunConfiguration from path=code/train/run_config.yml name=None
	InnerException None
	ErrorResponse 
***
    "error": ***
        "code": "UserError",
        "message": "Failed to load RunConfiguration from path=code/train/run_config.yml name=None"
    ***
***
None
Error: Error when loading runconfig yaml definition your repository (Path: /code/train/run_config.yml).
Error: Error when loading pipeline yaml definition your repository (Path: /code/train/pipeline.yml).
Error: Error when loading python script or function in your repository which defines the experiment config (Script path: '/code/main.py', Function: 'main()').
Error: You have to provide either a yaml definition for your run, a yaml definition of your pipeline or a python script, which returns a runconfig (Pipeline, ScriptRunConfig, AutoMlConfig, Estimator, etc.). Please read the documentation for more details.
  File "/code/main.py", line [15](https://github.com/bayer-int/ch_daa_phinmo/runs/7499494632?check_suite_focus=true#step:10:16)3, in main
    raise AMLExperimentConfigurationException("You have to provide a yaml definition for your run, a yaml definition of your pipeline or a python script, which returns a runconfig. Please read the documentation for more details.")
utils.AMLExperimentConfigurationException: You have to provide a yaml definition for your run, a yaml definition of your pipeline or a python script, which returns a runconfig. Please read the documentation for more details.

NilsHahnBayer avatar Jul 25 '22 12:07 NilsHahnBayer