green-coding-solutions / eco-ci-energy-estimation

Eco CI Energy estimation for Github Actions Runner VMs
MIT License
48 stars 10 forks source link

display-results tasks yields error: `max_measurement_number: unbound variable` #43

Closed marians closed 9 months ago

marians commented 9 months ago

I just added the two steps shown in the example in https://github.com/marketplace/actions/eco-ci-energy-estimation to a workflow and executed it. As a result, I got this error in the "Show energy results" step

Running a measurement to have at least one result to display.
|Label|🖥 avg. CPU utilization [%]|🔋 Total Energy [Joules]|🔌 avg. Power [Watts]|Duration [Seconds]|
|---|---|---|---|---|
|Total Run|2.38538|360.733|1.97122|184|
/home/runner/work/_actions/green-coding-berlin/eco-ci-energy-estimation/v2/scripts/display_results.sh: line 98: max_measurement_number: unbound variable
Error: Process completed with exit code 1.

The workflow snippet:

      - name: Show energy results
        uses: green-coding-berlin/eco-ci-energy-estimation@v2
        with:
          task: display-results
marians commented 9 months ago

FYI This happened in a private github.com repository

ribalba commented 9 months ago

Hey, sorry you encountered an error. Did you see the extra setup steps for private repos under:

https://github.com/green-coding-berlin/eco-ci-energy-estimation#note-on-private-repos

marians commented 9 months ago

Got it in the meantime and added get-measurement steps. The error is gone now.

Would it make sense to make the action work so that get-measurement is optional. In other words, a measurement would have to be taken always at the end, before generating the output. That would allow for a simpler workflow and would prevent this error.

ribalba commented 9 months ago

@dan-mm is there a way we can just output everything when calling display-results? I remember there was a reason we needed to call get-measurement at least once. But I can't remember why.

dan-mm commented 9 months ago

Hm it should already work that way.

Get-measurement is there for the user to explicitly say, here is where I want to make a measurement, and display-results is decoupled from actually making any measurements but just displaying the results of all your previous measurements.

But there is a safety clause in display-measurement where if get-measurement was never called, it makes at least one measurement then and there to have something to display. This clearly has a bug in it so I'll investigate now

dan-mm commented 9 months ago

@marians - found and fixed the issue. It should now work again even if make-measurement is never called. Thank you for the bug report!

Lemme know if it works this way for you now, or if you have any other issues!

marians commented 9 months ago

Thanks for that! Closing this issue then.