Commit eaa4be38 authored by Anna Warno's avatar Anna Warno
Browse files

timestamp format changed seconds -> miliseconds

parent cc5b6cf2
......@@ -94,8 +94,8 @@ def main():
# msg2 = Msg()
# msg2.body = """{
# "metrics": ["cpu_usage"],
# "timestamp": 0,
# "epoch_start": 0,
# "timestamp": 1623057648907,
# "epoch_start": 1623057698298,
# "number_of_forward_predictions": 5,
# "prediction_horizon": 120}"""
......
......@@ -48,7 +48,6 @@ class CustomListener(stomp.ConnectionListener):
metrics = set(json.loads(frame.body)["metrics"])
if self.start:
print("STARTTTTTT", self.start)
predicted_metrics = predicted_metrics.union(metrics)
for metric in metrics:
frame_body = json.loads(frame.body)
......@@ -87,11 +86,13 @@ def main():
influxdb_conn = InfluxdbPredictionsSender(METHOD, APP_NAME)
logging.debug(
f"waiting {msg['epoch_start'] - int(time.time()) - prediction_cycle} seconds"
f"waiting {(msg['epoch_start'] - int(time.time()) * 1000 - prediction_cycle * 1000) // 1000} seconds"
)
print("waiting: ", msg["epoch_start"] - int(time.time()) - prediction_cycle)
time.sleep(max(0, msg["epoch_start"] - int(time.time()) - prediction_cycle))
time.sleep(
max(0, (msg["epoch_start"] - int(time.time()) * 1000 - prediction_cycle * 1000))
// 1000
)
tl = Timeloop()
......
......@@ -91,7 +91,7 @@ def train(target_column, yaml_file="nbeats.yaml"):
msg = {
"metrics": target_column,
"forecasting_method": os.environ.get("METHOD", "nbetas"),
"timestamp": time.time(),
"timestamp": int(time.time()) * 1000,
}
print(msg)
return msg
......@@ -48,7 +48,6 @@ class CustomListener(stomp.ConnectionListener):
metrics = set(json.loads(frame.body)["metrics"])
if self.start:
print("STARTTTTTT", self.start)
predicted_metrics = predicted_metrics.union(metrics)
for metric in metrics:
frame_body = json.loads(frame.body)
......@@ -87,11 +86,13 @@ def main():
influxdb_conn = InfluxdbPredictionsSender(METHOD, APP_NAME)
logging.debug(
f"waiting {msg['epoch_start'] - int(time.time()) - prediction_cycle} seconds"
f"waiting {(msg['epoch_start'] - int(time.time()) * 1000 - prediction_cycle * 1000) // 1000} seconds"
)
print("waiting: ", msg["epoch_start"] - int(time.time()) - prediction_cycle)
time.sleep(max(0, msg["epoch_start"] - int(time.time()) - prediction_cycle))
time.sleep(
max(0, (msg["epoch_start"] - int(time.time()) * 1000 - prediction_cycle * 1000))
// 1000
)
tl = Timeloop()
......
......@@ -95,7 +95,7 @@ def train(target_column, prediction_length, yaml_file="model.yaml"):
msg = {
"metrics": target_column,
"forecasting_method": os.environ.get("METHOD", "tft"),
"timestamp": int(time.time()),
"timestamp": int(time.time()) * 1000,
}
return msg
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment