Skip to content

Plot the carbon intensity time series #112

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

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

andreww
Copy link
Collaborator

@andreww andreww commented Aug 23, 2024

Just a proof of concept for now, but plots the CI forecast time series alongside our planned run times.

Currently looks like this:

cats_plot

I think the optimal and now plots (green and red, respectively) are 30 mins out. Or background data is 30 mins out. Anyhow, this is a start.

Copy link

codecov bot commented Aug 23, 2024

Codecov Report

Attention: Patch coverage is 15.55556% with 38 lines in your changes missing coverage. Please review.

Project coverage is 82.69%. Comparing base (0eb9ffc) to head (aadbf72).

Files with missing lines Patch % Lines
cats/plotting.py 12.19% 36 Missing ⚠️
cats/__init__.py 50.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #112      +/-   ##
==========================================
- Coverage   87.48%   82.69%   -4.79%     
==========================================
  Files          13       14       +1     
  Lines         631      676      +45     
==========================================
+ Hits          552      559       +7     
- Misses         79      117      +38     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Makes use of our 'output' and the 'forecast'
to plot a timeseries of the CI alongside
highlights for the CI of running now or running
at the optimal time.
We may want to think about this a bit
(it's a big package) and the version
number is a guess, but let's get the tests
running for now.
@abhidg
Copy link
Contributor

abhidg commented Feb 25, 2025

@andreww one way to handle matplotlib is by putting in as an optional dependency, in a plots group as an example. Then if users want the plotting functionality they can use pip install 'climate-aware-task-scheduler[plots]'

Add coloured text giving mean carbon intensity for best and now
start times. Make date format on x axis easer to read.
I was seeing a bunch of fractional seconds in the shell
output, which is a bit ugly. Explicity set formatting to match our
test cases.
This should also print a useful error if it's not installed
We just need to print out a message if --plot is passed.
@andreww andreww marked this pull request as ready for review February 25, 2025 11:51
@andreww
Copy link
Collaborator Author

andreww commented Feb 25, 2025

@andreww one way to handle matplotlib is by putting in as an optional dependency, in a plots group as an example. Then if users want the plotting functionality they can use pip install 'climate-aware-task-scheduler[plots]'

Thanks - I did this. It ended up being a little fiddly because of the type testing but it seems to be working. Ready to merge?

@sadielbartholomew sadielbartholomew changed the title Plot the carbon intensity time serise Plot the carbon intensity time series Feb 25, 2025
@abhidg
Copy link
Contributor

abhidg commented Jun 6, 2025

@andreww I don't see any interpolation here, running with cats -d 60 --loc OX1 --plot, I get this output:


The.____ ..... __ .... ________ . ______...
.. /  __)...../  \....(__    __).)  ____)....
..|  /......./    \......|  |...(  (___........
..| |limate./  ()  \ware.|  |ask.\___  \cheduler
..|  \__...|   __   |....|  |....____)  )....
...\    )..|  (..)  |....|  |...(      (..

WARNING:root:config file not found
WARNING:root:Unspecified carbon intensity forecast service, using carbonintensity.org.uk

Best job start time                       = 2025-06-08 10:40:44
Carbon intensity if job started now       = 76.08 gCO2eq/kWh
Carbon intensity at optimal time          = 63.87 gCO2eq/kWh

Zooming in on the plots figure, I see a 30 min window highlighted, rather than 60 minutes (starting now, red):
Screenshot 2025-06-06 at 15 15 15

and the optimal time (green)

Screenshot 2025-06-06 at 15 16 14

@andreww
Copy link
Collaborator Author

andreww commented Jun 6, 2025

Ugh, yes, I see. I need to add the start and end times and interpolated values on the start and end of the series of points plotted in green and red. We must have this calculated somewhere - it'll be a case of getting it into the plotting function. Good spot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants