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

How to get run.log() variable values in yaml file?

Open pradeepgaur opened this issue 3 years ago • 5 comments

I am using github workflows and aml-run action, I am setting a custom variables using run.log("my_age", 10) and want to read value of this variable on .yml file for next step. How can I achieve it? I see {{outputs.run_metrics}} gives me this custom value but I am unable to pick it.

pradeepgaur avatar Aug 24 '21 21:08 pradeepgaur

Hi @pradeepgaur,

Thanks for submitting this issue. Did you try to print the output of the Action inside your workflow to check how it is structured? It should be a json/dict that you must parse.

Alternatively, you could use the run ID that is also provided as output to load the exact same details via SDK or CLI. Let me know, if you want me to provide an example.

marvinbuss avatar Aug 24 '21 22:08 marvinbuss

Hi @pradeepgaur, Here you can see how this gets written as an Action Output: https://github.com/Azure/aml-run/blob/9f488e27a86106007c9938731de2672ddfeef739/code/main.py#L190-L192

I just tested the same thing in a notebook quickly to validate this. The output will look similar to this: image

What you will need to do inside your yaml file is to parse the JSON and extract the particular value from the JSON. If you want to validate whether the parameter was better than in the previous run, you can also use the registermodel Action: https://github.com/Azure/aml-registermodel . There are two parameters that can be used to achieve the same thing: metrics_max, metrics_min

marvinbuss avatar Aug 24 '21 22:08 marvinbuss

Thanks for answering, so here is my problem.

I am adding an additional variable to the outputs using aml-run, using below code.

image

then, I need this output to be used in next step of the pipeline. So, I am using following on yaml file.

image

Also, as you can see sample output in the above image, I need 12 to be printed as the output, it prints blank now. How do I parse it? it seems like a dictionary but not JSON to me.

pradeepgaur avatar Aug 25 '21 09:08 pradeepgaur

@pradeepgaur The second one is just a string, which must be first read as JSON and then you can get the desired property. Can you please briefly explain what you are trying to do based on the metric?

Based on your use-case I can probably provide you a sample, which shows you how to achieve what you are trying to do. Thanks for providing more details! 👍

marvinbuss avatar Aug 26 '21 13:08 marvinbuss

Hey @marvinbuss, I think I face the same Problem. What I would like to do is for example to have access to the Accuracy. However the JSON Strucute is like this:

{
    "myRunId": {
        "Accuracy": 1.0
    }
}

So if I want to access the Accuracy, I first need to select the run id. e.g.: ${{ steps.aml_run.outputs.myRunId.Accuracy }}. Because the run id is always different and stored in steps.aml_run.outputs.run_id how do you access the accuracy? If anything is still unclear please do not hesitate to ask. Thanks in advance.

cellularegg avatar Jun 08 '22 06:06 cellularegg