-
-
Notifications
You must be signed in to change notification settings - Fork 104
Description
Describe the bug
Concerning the predict_tryolabs branch of run_forecast...
open-source-quartz-solar-forecast/quartz_solar_forecast/forecast.py
Lines 82 to 84 in e26a827
| if ts is None: | |
| start_date = pd.Timestamp.now().strftime("%Y-%m-%d") | |
| start_time = pd.Timestamp.now().round(freq="h") |
# set start and end time, if no time is given use current time
if ts is None:
start_date = pd.Timestamp.now().strftime("%Y-%m-%d")
start_time = pd.Timestamp.now().round(freq="h")The problem is that if this code runs close to midnight, the start_date and start_time variables can end up set a day apart. The subsequent code then runs the forecast for start_date + 2 days which may actually be only + 1 day from start_time - so the final filtered result will end up only containing a total of 1 days data instead of the desired 2 days worth.
To Reproduce
I haven't reproduced this, but if one wanted to demonstrate it, they could put a breakpoint on L84 and leave the interpreter paused until the time has (been) changed.
Expected behavior
Only get "now" once and derive the start_date and start_time variables from that.
# set start and end time, if no time is given use current time
if ts is None:
now = pd.Timestamp.now()
start_date = now.strftime("%Y-%m-%d")
start_time = now.round(freq="h")Additional context
N/A