Skip to content

Commit

Permalink
Merge pull request #55 from GreenScheduler/remove_simple
Browse files Browse the repository at this point in the history
Remove `simple` method for getting the job start time.
  • Loading branch information
tlestang authored Jul 27, 2023
2 parents a578ecc + d9fdddd commit 9c0c352
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 54 deletions.
2 changes: 1 addition & 1 deletion cats/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def main(arguments=None):
# Find best possible average carbon intensity, along
# with corresponding job start time.
now_avg, best_avg = get_avg_estimates(
CI_forecast, method="windowed", duration=duration
CI_forecast, duration=duration
)
sys.stderr.write(str(best_avg) + "\n")

Expand Down
30 changes: 10 additions & 20 deletions cats/optimise_starttime.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from .forecast import WindowedForecast


def get_avg_estimates(data, method="simple", duration=None):
def get_avg_estimates(data, duration=None):
"""
Get lowest carbon intensity in data depending on user method
return dict of timestamp and carbon intensity
Expand All @@ -17,22 +17,12 @@ def get_avg_estimates(data, method="simple", duration=None):
# "Windowed method timespan cannot be greater than the cached timespan"
# )

METHODS = ["simple", "windowed"]
if method not in METHODS:
raise ValueError(f"Invalid Carbon Intensity Method. Must be one of {METHODS}")

if method == "simple":
# Return element with smallest 2nd value
# if multiple elements have the same value, return the first
return min(data)

if method == "windowed":
# get length of interval between timestamps
interval = (
data[1].datetime - data[0].datetime
).total_seconds() / 60
wf = WindowedForecast(
data=data,
window_size=ceil(duration / interval)
)
return wf[0], min(wf)
# get length of interval between timestamps
interval = (
data[1].datetime - data[0].datetime
).total_seconds() / 60
wf = WindowedForecast(
data=data,
window_size=ceil(duration / interval)
)
return wf[0], min(wf)
33 changes: 0 additions & 33 deletions tests/test_timeseries_conversion.py

This file was deleted.

0 comments on commit 9c0c352

Please sign in to comment.