Azure / aml-workspace

GitHub Action that allows you to create or connect to your Azure Machine Learning Workspace.
MIT License
22 stars 16 forks source link

Accessing workspace from inside python code #14

Closed waqassiddiqi closed 4 years ago

waqassiddiqi commented 4 years ago

How to access workspace from inside the python code for training? If I call: ws = Workspace.get("workspace_name", resource_group="resource_group") It gets stuck at: Performing interactive authentication. Please follow the instructions on the terminal.

Do I need to construct ServicePrincipalAuthentication and pass it as an auth mechanism? If that is so, how can I pass github secrets via actions to my job running on remote node?

marvinbuss commented 4 years ago

Hi @waqassiddiqi, I am assuming that you would like to define your run, by using Python code. The function in the Python script gets the workspace object passed and you do not have to take care of the login. This is already handled for you within the aml-run action.

An example workflow is available here (branch runconfig_python): https://github.com/machine-learning-apps/ml-template-azure/tree/runconfig_python And here is the python script that shows you how you can use the workspace object (no login required): https://github.com/machine-learning-apps/ml-template-azure/blob/runconfig_python/code/train/run_config.py

When you click on Use this template, just make sure that you also click on "Include all branches": image

This will also clone the runconfig_python branch to your repo and it will help you get started. Please let me know, if my answer was helpful.

waqassiddiqi commented 4 years ago

@marvinbuss Thanks for quick reply. Actually, I am using run_config.yml, wasn't sure how to get hold of workspace in my code as I am trying to use existing code we have to log using MLFlow. But, now I think I get it, using run.experiment.workspace I was able to get active workspace.

marvinbuss commented 4 years ago

@waqassiddiqi That is correct. Sorry for the misunderstanding. Let us know, if you are running into any other issues.

waqassiddiqi commented 4 years ago

@marvinbuss well, I am still struggling to find the root cause but neither metrics nor artifacts being logged if i use mlflow api (ref: https://docs.microsoft.com/en-us/azure/machine-learning/how-to-use-mlflow#track-remote-runs) And submit step always fails with reason:

Traceback (most recent call last): File "/code/main.py", line 220, in <module> main() File "/code/main.py", line 172, in main run_metrics_markdown = convert_to_markdown(run_metrics) File "/code/utils.py", line 21, in convert_to_markdown experiment = exp[0] IndexError: list index out of range

Because it tries to access element which doesn't exist.

marvinbuss commented 4 years ago

Thanks for submitting this. I will fix this quickly. Give me 20 mins.

marvinbuss commented 4 years ago

@waqassiddiqi Can you please re-run your workflow?

marvinbuss commented 4 years ago

@waqassiddiqi It looks like you are unblocked? Let me know, if there is anything else you need help with.

waqassiddiqi commented 4 years ago

@marvinbuss thanks mate, that was quick & yes! it is working now!