Skip to content

Commit

Permalink
try foreasting and scheduling jobs for up to one day (#198)
Browse files Browse the repository at this point in the history
* try foreasting and scheduling for up to one day, after that let Redis remove the job if it needs memory

* changelog entry

* make it possible to control job's time to live in their queue
  • Loading branch information
nhoening committed Oct 1, 2021
1 parent 664c958 commit cf3e260
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 0 deletions.
1 change: 1 addition & 0 deletions documentation/changelog.rst
Expand Up @@ -24,6 +24,7 @@ Infrastructure / Support
* To avoid databases from filling up with irrelevant information, only beliefs data representing *changed beliefs are saved*, and *unchanged beliefs are dropped* [see `PR #194 <http://www.github.com/SeitaBV/flexmeasures/pull/194>`_]
* Monitored CLI tasks can get better names for identification [see `PR #193 <http://www.github.com/SeitaBV/flexmeasures/pull/193>`_]
* Less custom logfile location, document logging for devs [see `PR #196 <http://www.github.com/SeitaBV/flexmeasures/pull/196>`_]
* Keep forecasting and scheduling jobs in the queues for only up to one day [see `PR #198 <http://www.github.com/SeitaBV/flexmeasures/pull/198>`_]


v0.6.1 | September XX, 2021
Expand Down
10 changes: 10 additions & 0 deletions documentation/configuration.rst
Expand Up @@ -207,6 +207,16 @@ Timezone in which the platform operates. This is useful when datetimes are being

Default: ``"Asia/Seoul"``


FLEXMEASURES_JOB_TTL
^^^^^^^^^^^^^^^^^^^^^^^^^

Time to live for jobs (e.g. forecasting, scheduling) in their respective queue.

A job that is passed this time to live might get cleaned out by Redis' memory manager.

Default: ``timedelta(days=1)``

FLEXMEASURES_PLANNING_TTL
^^^^^^^^^^^^^^^^^^^^^^^^^

Expand Down
5 changes: 5 additions & 0 deletions flexmeasures/data/services/forecasting.py
Expand Up @@ -108,6 +108,11 @@ def create_forecasting_jobs(
custom_model_params=custom_model_params,
),
connection=current_app.queues["forecasting"].connection,
ttl=int(
current_app.config.get(
"FLEXMEASURES_JOB_TTL", timedelta(-1)
).total_seconds()
),
)
job.meta["model_search_term"] = model_search_term
job.save_meta()
Expand Down
5 changes: 5 additions & 0 deletions flexmeasures/data/services/scheduling.py
Expand Up @@ -64,6 +64,11 @@ def create_scheduling_job(
),
id=udi_event_ea,
connection=current_app.queues["scheduling"].connection,
ttl=int(
current_app.config.get(
"FLEXMEASURES_JOB_TTL", timedelta(-1)
).total_seconds()
),
result_ttl=int(
current_app.config.get(
"FLEXMEASURES_PLANNING_TTL", timedelta(-1)
Expand Down
1 change: 1 addition & 0 deletions flexmeasures/utils/config_defaults.py
Expand Up @@ -110,6 +110,7 @@ class Config(object):
FLEXMEASURES_MENU_LISTED_VIEW_ICONS: Dict[str, str] = {}
FLEXMEASURES_MENU_LISTED_VIEW_TITLES: Dict[str, str] = {}
FLEXMEASURES_LP_SOLVER: str = "cbc"
FLEXMEASURES_JOB_TTL: timedelta = timedelta(days=1)
FLEXMEASURES_PLANNING_HORIZON: timedelta = timedelta(hours=2 * 24)
FLEXMEASURES_PLANNING_TTL: timedelta = timedelta(
days=7
Expand Down

0 comments on commit cf3e260

Please sign in to comment.