Skip to content
Snippets Groups Projects

Better handling of start_forecasting message

1 file
+ 2
1
Compare changes
  • Side-by-side
  • Inline
@@ -171,6 +171,7 @@ def calculate_and_publish_predictions(prediction_horizon,maximum_time_required_f
for prediction_index in range(0,State.total_time_intervals_to_predict):
prediction_time = int(State.next_prediction_time)+prediction_index*prediction_horizon
try:
print_with_time ("Initiating predictions for all metrics for next_prediction_time, which is "+str(State.next_prediction_time))
prediction = predict_attributes(State.metrics_to_predict,prediction_time)
if (prediction_time == int(State.next_prediction_time)):
first_prediction = prediction
@@ -269,7 +270,7 @@ class Listener(messaging.listener.MorphemicListener):
Listener.start_forecasting = True
State.epoch_start = json.loads(body)["epoch_start"]
prediction_horizon = int(json.loads(body)["prediction_horizon"])
State.next_prediction_time = State.epoch_start
State.next_prediction_time = update_prediction_time(State.epoch_start,prediction_horizon,State.prediction_processing_time_safety_margin_seconds) # State.next_prediction_time was assigned the value of State.epoch_start here, but this re-initializes targeted prediction times after each start_forecasting message, which is not desired necessarily
except Exception as e:
print_with_time("Problem while retrieving epoch start and/or prediction_horizon")
return
Loading