Skip to content

Added codecarbon tracking to Simvue Run #508

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Sep 24, 2024
Merged

Added codecarbon tracking to Simvue Run #508

merged 8 commits into from
Sep 24, 2024

Conversation

kzscisoft
Copy link
Collaborator

Uses Code Carbon to track emissions during a Simvue run, this can be disabled via the config method.

@kzscisoft kzscisoft added the enhancement New feature or request label Sep 9, 2024
@kzscisoft kzscisoft requested a review from alahiff September 11, 2024 08:40
@kzscisoft kzscisoft added this to the API v1.1 milestone Sep 11, 2024
@wk9874 wk9874 requested review from wk9874 and removed request for alahiff September 11, 2024 12:30

if self._emissions_tracker:
with contextlib.suppress(Exception):
self._emissions_tracker.stop()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could add the final total carbon spent as metadata here?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And in _error, _exit etc

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Definitely worth bearing in mind, maybe open an issue for future reference on this @wk9874

"codecarbon.emissions.delta": delta.emissions,
"codecarbon.energy_consumed.delta": delta.energy_consumed,
}
)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also in the same way that Resources has its own view in the Run Metrics page, we should add a Emissions view and have these metrics stored in there (discuss with Andrew / raise an issue)

Use separate step counter for CC

Allow setting of emission metric interval

Use multiple CC trackers
@kzscisoft kzscisoft requested a review from wk9874 September 12, 2024 15:01
@alahiff
Copy link
Collaborator

alahiff commented Sep 13, 2024

The names of the metrics are possibly not compatible with the standard way "magic" metrics grouping works in the UI. By default the following will be grouped:

  • codecarbon.emissions.delta, codecarbon.emissions.total
  • codecarbon.energy_consumed.delta, codecarbon.energy_consumed.total

Does it make sense for deltas and totals to be displayed together?

Update: with the special Emissions page the above is not really an issue anymore.

@alahiff
Copy link
Collaborator

alahiff commented Sep 13, 2024

Is it possible to suppress this message to stdout?

[codecarbon WARNING @ 05:39:03] Multiple instances of codecarbon are allowed to run at the same time.

I also get this warning now when running the client:

/home/alahiff/.cache/pypoetry/virtualenvs/simvue-0vzJveOR-py3.10/lib/python3.10/site-packages/codecarbon/output_methods/file.py:52: FutureWarning: The behavior of DataFrame concatenation with empty or all-NA entries is deprecated. In a future version, this will no longer exclude empty or all-NA columns when determining the result dtypes. To retain the old behavior, exclude the relevant entries before the concat operation.
  df = pd.concat([df, pd.DataFrame.from_records([dict(total.values)])])

@alahiff
Copy link
Collaborator

alahiff commented Sep 13, 2024

When running this for 180 seconds I only get a single set of codecarbon metrics at the very end. Is this expected?

@kzscisoft
Copy link
Collaborator Author

Is it possible to suppress this message to stdout?

[codecarbon WARNING @ 05:39:03] Multiple instances of codecarbon are allowed to run at the same time.

I also get this warning now when running the client:

/home/alahiff/.cache/pypoetry/virtualenvs/simvue-0vzJveOR-py3.10/lib/python3.10/site-packages/codecarbon/output_methods/file.py:52: FutureWarning: The behavior of DataFrame concatenation with empty or all-NA entries is deprecated. In a future version, this will no longer exclude empty or all-NA columns when determining the result dtypes. To retain the old behavior, exclude the relevant entries before the concat operation.
  df = pd.concat([df, pd.DataFrame.from_records([dict(total.values)])])

I would need to see if it is possible to disable CC logging. As for the second that would be a fix to CC itself, my concern would be changing this would break it for older Python versions

@AbyAbraham21
Copy link
Collaborator

"Keep emissions data off by default" - Why? I would assume you want it on by default?

@kzscisoft
Copy link
Collaborator Author

@AbyAbraham21 Due to the fact that setup is required on the host machine for the CC metrics to be valid and correct we should make the user accountable for their recording as opposed to it being our responsibility that their setup is correct. @alahiff and I agreed having these off by default made sense.

We will of course need to document enabling the feature.

@kzscisoft kzscisoft merged commit ff4b173 into dev Sep 24, 2024
14 checks passed
@kzscisoft kzscisoft deleted the feature/eco-track branch September 24, 2024 13:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants