Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Melodic
morphemic-preprocessor
Commits
38d77b9a
Commit
38d77b9a
authored
Apr 14, 2022
by
Bizid Imen
Browse files
Update gluonts_listener.py
parent
2f0da411
Changes
1
Hide whitespace changes
Inline
Side-by-side
forecasting_gluonts/gluonts_listener.py
View file @
38d77b9a
...
...
@@ -62,7 +62,7 @@ def worker(self, body, metric):
yhat
=
yhats
[
k
]
yhat_lower
=
yhat_lowers
[
k
]
yhat_upper
=
yhat_uppers
[
k
]
self
.
connector
.
send_to_topic
(
'intermediate_prediction.gluon
machine
s.'
+
metric
,
self
.
connector
.
send_to_topic
(
'intermediate_prediction.gluon
t
s.'
+
metric
,
{
"metricValue"
:
float
(
yhat
),
"level"
:
3
,
...
...
@@ -81,7 +81,7 @@ def worker(self, body, metric):
class
Gluonts
(
morphemic
.
handler
.
ModelHandler
,
messaging
.
listener
.
MorphemicListener
):
id
=
"gluon
machine
s"
id
=
"gluon
t
s"
def
__init__
(
self
):
self
.
_run
=
False
...
...
@@ -91,8 +91,8 @@ class Gluonts(morphemic.handler.ModelHandler, messaging.listener.MorphemicListen
def
run
(
self
):
self
.
connector
.
connect
()
self
.
connector
.
set_listener
(
self
.
id
,
self
)
self
.
connector
.
topic
(
"start_forecasting.gluon
machine
s"
,
self
.
id
)
self
.
connector
.
topic
(
"stop_forecasting.gluon
machine
s"
,
self
.
id
)
self
.
connector
.
topic
(
"start_forecasting.gluon
t
s"
,
self
.
id
)
self
.
connector
.
topic
(
"stop_forecasting.gluon
t
s"
,
self
.
id
)
self
.
connector
.
topic
(
"metrics_to_predict"
,
self
.
id
)
def
reconnect
(
self
):
...
...
@@ -100,7 +100,7 @@ class Gluonts(morphemic.handler.ModelHandler, messaging.listener.MorphemicListen
self
.
run
()
pass
def
on_start_forecasting_gluon
machine
s
(
self
,
body
):
def
on_start_forecasting_gluon
t
s
(
self
,
body
):
sent_metrics
=
body
[
"metrics"
]
logging
.
debug
(
f
"Gluonts Start Forecasting the following metrics:
{
sent_metrics
}
"
)
for
metric
in
sent_metrics
:
...
...
@@ -134,11 +134,11 @@ class Gluonts(morphemic.handler.ModelHandler, messaging.listener.MorphemicListen
self
.
connector
.
send_to_topic
(
"training_models"
,
{
"metrics"
:
list
(
metrics
),
"forecasting_method"
:
"gluon
machine
s"
,
"forecasting_method"
:
"gluon
t
s"
,
"timestamp"
:
int
(
time
())
})
def
on_stop_forecasting_gluon
machine
s
(
self
,
body
):
def
on_stop_forecasting_gluon
t
s
(
self
,
body
):
logging
.
debug
(
f
"Gluonts Stop Forecasting the following metrics:
{
body
[
'metrics'
]
}
"
)
for
metric
in
body
[
"metrics"
]:
if
metric
in
metrics
:
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment