openstef 3.4.15__py3-none-any.whl → 3.4.16__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- openstef/data_classes/data_prep.py +1 -1
- openstef/data_classes/prediction_job.py +1 -1
- openstef/enums.py +0 -6
- openstef/feature_engineering/data_preparation.py +5 -5
- openstef/model/model_creator.py +1 -1
- openstef/model/objective_creator.py +1 -1
- openstef/model/regressors/arima.py +1 -1
- openstef/monitoring/performance_meter.py +1 -2
- openstef/pipeline/create_basecase_forecast.py +1 -1
- openstef/pipeline/create_component_forecast.py +1 -2
- openstef/pipeline/optimize_hyperparameters.py +1 -1
- openstef/tasks/calculate_kpi.py +0 -7
- openstef/tasks/create_components_forecast.py +1 -1
- openstef/tasks/train_model.py +3 -5
- openstef/validation/validation.py +2 -2
- {openstef-3.4.15.dist-info → openstef-3.4.16.dist-info}/METADATA +1 -1
- {openstef-3.4.15.dist-info → openstef-3.4.16.dist-info}/RECORD +20 -21
- openstef/tasks/run_tracy.py +0 -145
- {openstef-3.4.15.dist-info → openstef-3.4.16.dist-info}/LICENSE +0 -0
- {openstef-3.4.15.dist-info → openstef-3.4.16.dist-info}/WHEEL +0 -0
- {openstef-3.4.15.dist-info → openstef-3.4.16.dist-info}/top_level.txt +0 -0
@@ -6,9 +6,9 @@ from typing import Optional, Union
|
|
6
6
|
|
7
7
|
from pydantic.v1 import BaseModel
|
8
8
|
|
9
|
+
from openstef.data_classes.data_prep import DataPrepDataClass
|
9
10
|
from openstef.data_classes.model_specifications import ModelSpecificationDataClass
|
10
11
|
from openstef.data_classes.split_function import SplitFuncDataClass
|
11
|
-
from openstef.data_classes.data_prep import DataPrepDataClass
|
12
12
|
from openstef.enums import PipelineType
|
13
13
|
|
14
14
|
|
openstef/enums.py
CHANGED
@@ -1,24 +1,24 @@
|
|
1
1
|
# SPDX-FileCopyrightText: 2017-2023 Alliander N.V. <korte.termijn.prognoses@alliander.com> # noqa E501>
|
2
2
|
#
|
3
3
|
# SPDX-License-Identifier: MPL-2.0
|
4
|
-
import structlog
|
5
|
-
|
6
4
|
from abc import ABC, abstractmethod
|
5
|
+
from datetime import timedelta
|
7
6
|
from typing import Optional
|
8
7
|
|
9
8
|
import pandas as pd
|
10
|
-
|
9
|
+
import structlog
|
10
|
+
|
11
11
|
from openstef.data_classes.model_specifications import ModelSpecificationDataClass
|
12
12
|
from openstef.data_classes.prediction_job import PredictionJobDataClass
|
13
|
-
from openstef.model.regressors.regressor import OpenstfRegressor
|
14
13
|
from openstef.feature_engineering.feature_applicator import (
|
15
|
-
TrainFeatureApplicator,
|
16
14
|
OperationalPredictFeatureApplicator,
|
15
|
+
TrainFeatureApplicator,
|
17
16
|
)
|
18
17
|
from openstef.feature_engineering.general import (
|
19
18
|
enforce_feature_order,
|
20
19
|
remove_non_requested_feature_columns,
|
21
20
|
)
|
21
|
+
from openstef.model.regressors.regressor import OpenstfRegressor
|
22
22
|
from openstef.pipeline.utils import generate_forecast_datetime_range
|
23
23
|
|
24
24
|
|
openstef/model/model_creator.py
CHANGED
@@ -6,13 +6,13 @@ from typing import Union
|
|
6
6
|
import structlog
|
7
7
|
|
8
8
|
from openstef.enums import MLModelType
|
9
|
+
from openstef.model.regressors.arima import ARIMAOpenstfRegressor
|
9
10
|
from openstef.model.regressors.custom_regressor import is_custom_type, load_custom_model
|
10
11
|
from openstef.model.regressors.lgbm import LGBMOpenstfRegressor
|
11
12
|
from openstef.model.regressors.linear import LinearOpenstfRegressor
|
12
13
|
from openstef.model.regressors.regressor import OpenstfRegressor
|
13
14
|
from openstef.model.regressors.xgb import XGBOpenstfRegressor
|
14
15
|
from openstef.model.regressors.xgb_quantile import XGBQuantileOpenstfRegressor
|
15
|
-
from openstef.model.regressors.arima import ARIMAOpenstfRegressor
|
16
16
|
|
17
17
|
logger = structlog.get_logger(__name__)
|
18
18
|
|
@@ -6,12 +6,12 @@ from typing import Union
|
|
6
6
|
|
7
7
|
from openstef.enums import MLModelType
|
8
8
|
from openstef.model.objective import (
|
9
|
+
ARIMARegressorObjective,
|
9
10
|
LGBRegressorObjective,
|
10
11
|
LinearRegressorObjective,
|
11
12
|
RegressorObjective,
|
12
13
|
XGBQuantileRegressorObjective,
|
13
14
|
XGBRegressorObjective,
|
14
|
-
ARIMARegressorObjective,
|
15
15
|
)
|
16
16
|
from openstef.model.regressors.custom_regressor import (
|
17
17
|
create_custom_objective,
|
@@ -20,8 +20,7 @@ class PerformanceMeter:
|
|
20
20
|
|
21
21
|
Args:
|
22
22
|
level_label: The label of the new level. This could i.e. be 'task'
|
23
|
-
level_name: The name of the specified level.
|
24
|
-
'tracy_todo'
|
23
|
+
level_name: The name of the specified level.
|
25
24
|
**kwargs: Any other kwargs are appended to the logging.
|
26
25
|
|
27
26
|
Returns:
|
@@ -7,7 +7,7 @@ import pandas as pd
|
|
7
7
|
import structlog
|
8
8
|
|
9
9
|
from openstef.data_classes.prediction_job import PredictionJobDataClass
|
10
|
-
from openstef.exceptions import
|
10
|
+
from openstef.exceptions import InputDataOngoingZeroFlatlinerError, NoRealisedLoadError
|
11
11
|
from openstef.feature_engineering.feature_applicator import (
|
12
12
|
OperationalPredictFeatureApplicator,
|
13
13
|
)
|
@@ -3,6 +3,7 @@
|
|
3
3
|
# SPDX-License-Identifier: MPL-2.0
|
4
4
|
|
5
5
|
import joblib
|
6
|
+
import numpy as np
|
6
7
|
import pandas as pd
|
7
8
|
import structlog
|
8
9
|
|
@@ -12,8 +13,6 @@ from openstef.data_classes.prediction_job import PredictionJobDataClass
|
|
12
13
|
from openstef.enums import ForecastType
|
13
14
|
from openstef.model.regressors.dazls import Dazls
|
14
15
|
|
15
|
-
import numpy as np
|
16
|
-
|
17
16
|
# Set the path for the Dazls stored model
|
18
17
|
DAZLS_STORED = str(
|
19
18
|
PROJECT_ROOT / "openstef" / "data" / "dazls_model_3.4.7" / "dazls_stored_3.4.7_"
|
@@ -21,12 +21,12 @@ from openstef.model.objective import RegressorObjective
|
|
21
21
|
from openstef.model.objective_creator import ObjectiveCreator
|
22
22
|
from openstef.model.regressors.regressor import OpenstfRegressor
|
23
23
|
from openstef.model.serializer import MLflowSerializer
|
24
|
+
from openstef.model_selection.model_selection import split_data_train_validation_test
|
24
25
|
from openstef.pipeline.train_model import (
|
25
26
|
DEFAULT_TRAIN_HORIZONS_HOURS,
|
26
27
|
train_model_pipeline_core,
|
27
28
|
)
|
28
29
|
from openstef.validation import validation
|
29
|
-
from openstef.model_selection.model_selection import split_data_train_validation_test
|
30
30
|
|
31
31
|
optuna.logging.enable_propagation() # Propagate logs to the root logger.
|
32
32
|
optuna.logging.disable_default_handler() # Stop showing logs in sys.stderr.
|
openstef/tasks/calculate_kpi.py
CHANGED
@@ -106,10 +106,6 @@ def check_kpi_task(
|
|
106
106
|
rMAE=kpis["47.0h"]["rMAE"],
|
107
107
|
retraining_threshold=THRESHOLD_RETRAINING,
|
108
108
|
)
|
109
|
-
function_name = "train_model"
|
110
|
-
|
111
|
-
context.logger.info("Adding tracy job", function=function_name)
|
112
|
-
context.database.ktp_api.add_tracy_job(pj["id"], function=function_name)
|
113
109
|
|
114
110
|
if kpis["47.0h"]["rMAE"] > THRESHOLD_OPTIMIZING:
|
115
111
|
context.logger.warning(
|
@@ -118,9 +114,6 @@ def check_kpi_task(
|
|
118
114
|
rMAE=kpis["47.0h"]["rMAE"],
|
119
115
|
optimizing_threshold=THRESHOLD_OPTIMIZING,
|
120
116
|
)
|
121
|
-
function_name = "optimize_hyperparameters"
|
122
|
-
context.logger.info("Adding tracy job", function=function_name)
|
123
|
-
context.database.ktp_api.add_tracy_job(pj["id"], function=function_name)
|
124
117
|
|
125
118
|
|
126
119
|
def calc_kpi_for_specific_pid(
|
@@ -24,8 +24,8 @@ Example:
|
|
24
24
|
from datetime import datetime, timedelta, timezone
|
25
25
|
from pathlib import Path
|
26
26
|
|
27
|
-
import structlog
|
28
27
|
import pandas as pd
|
28
|
+
import structlog
|
29
29
|
|
30
30
|
from openstef.data_classes.prediction_job import PredictionJobDataClass
|
31
31
|
from openstef.enums import MLModelType
|
openstef/tasks/train_model.py
CHANGED
@@ -23,22 +23,20 @@ from datetime import datetime, timedelta
|
|
23
23
|
from pathlib import Path
|
24
24
|
|
25
25
|
from openstef.data_classes.prediction_job import PredictionJobDataClass
|
26
|
-
|
27
26
|
from openstef.enums import MLModelType, PipelineType
|
28
27
|
from openstef.exceptions import (
|
29
|
-
SkipSaveTrainingForecasts,
|
30
28
|
InputDataOngoingZeroFlatlinerError,
|
29
|
+
SkipSaveTrainingForecasts,
|
31
30
|
)
|
31
|
+
from openstef.model.serializer import MLflowSerializer
|
32
32
|
from openstef.pipeline.train_model import (
|
33
|
+
MAXIMUM_MODEL_AGE,
|
33
34
|
train_model_pipeline,
|
34
35
|
train_pipeline_step_load_model,
|
35
|
-
MAXIMUM_MODEL_AGE,
|
36
36
|
)
|
37
37
|
from openstef.tasks.utils.predictionjobloop import PredictionJobLoop
|
38
38
|
from openstef.tasks.utils.taskcontext import TaskContext
|
39
39
|
|
40
|
-
from openstef.model.serializer import MLflowSerializer
|
41
|
-
|
42
40
|
TRAINING_PERIOD_DAYS: int = 120
|
43
41
|
DEFAULT_CHECK_MODEL_AGE: bool = True
|
44
42
|
|
@@ -1,17 +1,17 @@
|
|
1
1
|
# SPDX-FileCopyrightText: 2017-2023 Contributors to the OpenSTEF project <korte.termijn.prognoses@alliander.com> # noqa E501>
|
2
2
|
#
|
3
3
|
# SPDX-License-Identifier: MPL-2.0
|
4
|
+
import math
|
4
5
|
from datetime import datetime, timedelta
|
5
6
|
from typing import Union
|
6
7
|
|
7
|
-
import math
|
8
8
|
import numpy as np
|
9
9
|
import pandas as pd
|
10
10
|
import structlog
|
11
11
|
|
12
12
|
from openstef.exceptions import InputDataOngoingZeroFlatlinerError
|
13
|
-
from openstef.preprocessing.preprocessing import replace_repeated_values_with_nan
|
14
13
|
from openstef.model.regressors.regressor import OpenstfRegressor
|
14
|
+
from openstef.preprocessing.preprocessing import replace_repeated_values_with_nan
|
15
15
|
|
16
16
|
|
17
17
|
def validate(
|
@@ -1,6 +1,6 @@
|
|
1
1
|
openstef/__init__.py,sha256=93UM6m0LLQhO69-mSqLuUy73jgs4W7Iuxfo3Lm8c98g,419
|
2
2
|
openstef/__main__.py,sha256=bIyGTSA4V5VoOLTwdaiJJAnozmpSzvQooVYlsf8H4eU,163
|
3
|
-
openstef/enums.py,sha256=
|
3
|
+
openstef/enums.py,sha256=f3Gw-HlNXeqMZahIAEYSZkPKtKWeNt3tfOJBL45Z2fM,629
|
4
4
|
openstef/exceptions.py,sha256=fVqjyrVMBiSGxcoZ3JfTcgZjIur1cPennZpfwqgc9qY,1992
|
5
5
|
openstef/data/dutch_holidays_2020-2022.csv,sha256=pS-CjE0igYXd-2dG-MlqyvR2fgYgXkbNmgCKyTjmwxs,23704
|
6
6
|
openstef/data/dutch_holidays_2020-2022.csv.license,sha256=AxxHusqwIXU5RHl5ZMU65LyXmgtbj6QlcnFaOEN4kEE,145
|
@@ -25,13 +25,13 @@ openstef/data/dazls_model_3.4.7/dazls_stored_3.4.7_target.z.license,sha256=AxxHu
|
|
25
25
|
openstef/data/dazls_model_3.4.7/dazls_stored_3.4.7_target_scaler.z,sha256=HFldCZItBFxDkFrtg36RS-zyrHHGKOILXya-_hmluYM,686
|
26
26
|
openstef/data/dazls_model_3.4.7/dazls_stored_3.4.7_target_scaler.z.license,sha256=AxxHusqwIXU5RHl5ZMU65LyXmgtbj6QlcnFaOEN4kEE,145
|
27
27
|
openstef/data_classes/__init__.py,sha256=bIyGTSA4V5VoOLTwdaiJJAnozmpSzvQooVYlsf8H4eU,163
|
28
|
-
openstef/data_classes/data_prep.py,sha256=
|
28
|
+
openstef/data_classes/data_prep.py,sha256=gRSL7UiHvZis8m8z7VoTCZc0Ccffhef5_hmSyApnqK0,3417
|
29
29
|
openstef/data_classes/model_specifications.py,sha256=Uod1W3QzhRqVLb6zvXwxh9wRL3EHCzSvX0oDNd28cFk,1197
|
30
|
-
openstef/data_classes/prediction_job.py,sha256=
|
30
|
+
openstef/data_classes/prediction_job.py,sha256=lORSocNT8wkq4JhPFsDM8A3EDRi2Pyx28IaVroImfEk,5048
|
31
31
|
openstef/data_classes/split_function.py,sha256=ljQIQQu1t1Y_CVWGAy25jrM6wG9odIVVQVimrT1n-1s,3358
|
32
32
|
openstef/feature_engineering/__init__.py,sha256=bIyGTSA4V5VoOLTwdaiJJAnozmpSzvQooVYlsf8H4eU,163
|
33
33
|
openstef/feature_engineering/apply_features.py,sha256=-3fyisOVj9ckIkRe2iYfWutbXSX8iqBkcvt8AYr-gmE,3906
|
34
|
-
openstef/feature_engineering/data_preparation.py,sha256=
|
34
|
+
openstef/feature_engineering/data_preparation.py,sha256=rH0e5W47OfKisnvusI9J74MPKz48mDrAD2P016QUZpo,5399
|
35
35
|
openstef/feature_engineering/feature_adder.py,sha256=aSqDl_gUrB3H2TD3cNvU5JniY_KOb4u4a2A6J7zB2BQ,6835
|
36
36
|
openstef/feature_engineering/feature_applicator.py,sha256=DR7jayrEMlra4BFL1Ps5WV2fxbkQ6VaOTa5RIKM-YNk,7447
|
37
37
|
openstef/feature_engineering/general.py,sha256=igAPyejYN5d09-a_c53C79a0A4cHjvMCa47KC4IfgCo,4072
|
@@ -46,16 +46,16 @@ openstef/model/__init__.py,sha256=bIyGTSA4V5VoOLTwdaiJJAnozmpSzvQooVYlsf8H4eU,16
|
|
46
46
|
openstef/model/basecase.py,sha256=caI6Q-8y0ymlxGK9Js_H3Vh0q6ruNHlGD5RG0_kE5M0,2878
|
47
47
|
openstef/model/confidence_interval_applicator.py,sha256=SXUVCnKrhc7lygWqerkBx4eG4tNeLgNEUz-WPqB4Mng,8705
|
48
48
|
openstef/model/fallback.py,sha256=VV9ehgnoMZtWzqKk9H1t8wnERFh5CyC4TvDIuRP_ZDI,2861
|
49
|
-
openstef/model/model_creator.py,sha256
|
49
|
+
openstef/model/model_creator.py,sha256=-AGAxDr9xxyDFQ0rIh0lvzgYUQQJoHPKVYC3q9azZSk,4790
|
50
50
|
openstef/model/objective.py,sha256=eqNBYGfhEVGegOm0PbizowuFImKblRqHgxkp9lgaKQc,13500
|
51
|
-
openstef/model/objective_creator.py,sha256=
|
51
|
+
openstef/model/objective_creator.py,sha256=Rjd2YF1Ie9Z-au_v4fOuR63IcM69EEeoe_5Hj_Dz8-E,1970
|
52
52
|
openstef/model/serializer.py,sha256=SGhhk-NU-J8khRwDqeBnO3wywS193XrkYRe7WFkfiMU,17009
|
53
53
|
openstef/model/standard_deviation_generator.py,sha256=Od9bzXi2TLb1v8Nz-VhBMZHSopWH6ssaDe8gYLlqO1I,2911
|
54
54
|
openstef/model/metamodels/__init__.py,sha256=bIyGTSA4V5VoOLTwdaiJJAnozmpSzvQooVYlsf8H4eU,163
|
55
55
|
openstef/model/metamodels/grouped_regressor.py,sha256=yMN_a6TnQSyFaqlB_6Nifq-ydpb5hs6w_b97IaBbHj4,8337
|
56
56
|
openstef/model/metamodels/missing_values_handler.py,sha256=veyvYZHhKvlYZxaUpxRQ7XoE033_3Lcg9LrbuKchlOk,5241
|
57
57
|
openstef/model/regressors/__init__.py,sha256=bIyGTSA4V5VoOLTwdaiJJAnozmpSzvQooVYlsf8H4eU,163
|
58
|
-
openstef/model/regressors/arima.py,sha256=
|
58
|
+
openstef/model/regressors/arima.py,sha256=wt7FVykjSvljpl7vjtliq61SiyjQ7KKtw8PF9x0xf04,7587
|
59
59
|
openstef/model/regressors/custom_regressor.py,sha256=Hsmxahc9nfSWD0aEZ6cm4pxW2noQ8B1SujS17_fmxcU,1768
|
60
60
|
openstef/model/regressors/dazls.py,sha256=cCYFewJEv3Fn01wdZpaKNSiYmEwzuED7PQrrWzwyTEg,8084
|
61
61
|
openstef/model/regressors/lgbm.py,sha256=zCdn1euEdSFxYJzH8XqQFFnb6R4JVUnmineKjX_Gy-g,800
|
@@ -66,13 +66,13 @@ openstef/model/regressors/xgb_quantile.py,sha256=PzKIxqN_CnEPFmzXACNuzLSmZSHbooT
|
|
66
66
|
openstef/model_selection/__init__.py,sha256=bIyGTSA4V5VoOLTwdaiJJAnozmpSzvQooVYlsf8H4eU,163
|
67
67
|
openstef/model_selection/model_selection.py,sha256=R34tJBecZo6IiUwCCRLeBI2ZCX6GP8W7FDBlGFWtmG8,11167
|
68
68
|
openstef/monitoring/__init__.py,sha256=bIyGTSA4V5VoOLTwdaiJJAnozmpSzvQooVYlsf8H4eU,163
|
69
|
-
openstef/monitoring/performance_meter.py,sha256=
|
69
|
+
openstef/monitoring/performance_meter.py,sha256=6aCGjJFXFq-7qwaJyBkF3MLqjgVK6FMFVcO-bcLLUb4,2803
|
70
70
|
openstef/monitoring/teams.py,sha256=fnZScPD55z9yC0q3YavWj40GEZmL7tsSGhWzG_sMPws,6401
|
71
71
|
openstef/pipeline/__init__.py,sha256=bIyGTSA4V5VoOLTwdaiJJAnozmpSzvQooVYlsf8H4eU,163
|
72
|
-
openstef/pipeline/create_basecase_forecast.py,sha256=
|
73
|
-
openstef/pipeline/create_component_forecast.py,sha256=
|
72
|
+
openstef/pipeline/create_basecase_forecast.py,sha256=osrAlPjveM_fK0TEyVaA6rtqdn-jd1dV7fxU5c3-Muo,4414
|
73
|
+
openstef/pipeline/create_component_forecast.py,sha256=qrIfpCNeoHgSddlzG_-XMHfBmSMclGoOkW-jH35ugkk,6254
|
74
74
|
openstef/pipeline/create_forecast.py,sha256=bE1gTSP-HAjFSt-Xdoiy5BxDIo7lYq-Z-gvU7zFrRfw,5350
|
75
|
-
openstef/pipeline/optimize_hyperparameters.py,sha256=
|
75
|
+
openstef/pipeline/optimize_hyperparameters.py,sha256=dG2GMTwxb5lHBit_xRgVabcC-PHbifccoPgl9nL-1Xk,10836
|
76
76
|
openstef/pipeline/train_create_forecast_backtest.py,sha256=7uNeY8dKtJLha_LkwroyU76oB54R9p3zRlTJAJj4OoI,6048
|
77
77
|
openstef/pipeline/train_model.py,sha256=LWvqANH8fpo8blwQ8Rgc1Z7EXvmZC0vTYwaOvSbr7qM,19496
|
78
78
|
openstef/pipeline/utils.py,sha256=23mB31p19FoGWelLJzxNmqlzGwEr3fCDBEA37V2kpYY,2167
|
@@ -81,24 +81,23 @@ openstef/postprocessing/postprocessing.py,sha256=nehd0tDpkdIaWFJggQ-fDizIKdfmqJ3
|
|
81
81
|
openstef/preprocessing/__init__.py,sha256=bIyGTSA4V5VoOLTwdaiJJAnozmpSzvQooVYlsf8H4eU,163
|
82
82
|
openstef/preprocessing/preprocessing.py,sha256=bM_cSSSb2vGTD79RGzUrI6KoELbzlCyJwc7jqQGNEsE,1454
|
83
83
|
openstef/tasks/__init__.py,sha256=bIyGTSA4V5VoOLTwdaiJJAnozmpSzvQooVYlsf8H4eU,163
|
84
|
-
openstef/tasks/calculate_kpi.py,sha256
|
84
|
+
openstef/tasks/calculate_kpi.py,sha256=-qwZtA5E88t59R53osZegw6-cKkYNrf03EG5bTp1IgE,11589
|
85
85
|
openstef/tasks/create_basecase_forecast.py,sha256=Hk9fDljXvo5TfeS3nWHrerWi7y-lQzoJEaqWbqaxHOs,3852
|
86
|
-
openstef/tasks/create_components_forecast.py,sha256=
|
86
|
+
openstef/tasks/create_components_forecast.py,sha256=X0Vvhm4F3stcq-QSgZsohlrZQ1myAdDwaBLAeIpQ9D4,5660
|
87
87
|
openstef/tasks/create_forecast.py,sha256=FPILsCqt2lT2QIjseXyKjViZG6SVRoGCxoj9tPiozIg,5575
|
88
88
|
openstef/tasks/create_solar_forecast.py,sha256=bTr7NThTF6Yj405qAqRaJmlBUrL7HATqVVzsi9hMdMw,15049
|
89
89
|
openstef/tasks/create_wind_forecast.py,sha256=RhshkmNSyFWx4Y6yQn02GzHjWTREbN5A5GAeWv0JpcE,2907
|
90
90
|
openstef/tasks/optimize_hyperparameters.py,sha256=s-z8YQJF6Lf3DdYgKHEpAdlbFJ3a-0Gj0Ahsqj1DErc,4758
|
91
|
-
openstef/tasks/run_tracy.py,sha256=mWRg5u74iSaUGHRQzIa-2Weyg6ChuW5w3JBL-7MrNBc,5036
|
92
91
|
openstef/tasks/split_forecast.py,sha256=hBRoIlZ_DK4747EtMpY-HVh_tmTdGa65oYOtrjHRUxQ,9118
|
93
|
-
openstef/tasks/train_model.py,sha256=
|
92
|
+
openstef/tasks/train_model.py,sha256=3-7QzyOFQ2jK_RHd7ISpFRnn0V9yEHCWQN3O8qLglqc,7475
|
94
93
|
openstef/tasks/utils/__init__.py,sha256=bIyGTSA4V5VoOLTwdaiJJAnozmpSzvQooVYlsf8H4eU,163
|
95
94
|
openstef/tasks/utils/dependencies.py,sha256=Jy9dtV_G7lTEa5Cdy--wvMxJuAb0adb3R0X4QDjVteM,3077
|
96
95
|
openstef/tasks/utils/predictionjobloop.py,sha256=Ysy3zF5lzPMz_asYDKeF5m0qgVT3tCtwSPihqMjnI5Q,9580
|
97
96
|
openstef/tasks/utils/taskcontext.py,sha256=yI6TntOkZcW8JiNVuw4uJIigEBL0_iIrkPklF4ZeCX4,5401
|
98
97
|
openstef/validation/__init__.py,sha256=bIyGTSA4V5VoOLTwdaiJJAnozmpSzvQooVYlsf8H4eU,163
|
99
|
-
openstef/validation/validation.py,sha256=
|
100
|
-
openstef-3.4.
|
101
|
-
openstef-3.4.
|
102
|
-
openstef-3.4.
|
103
|
-
openstef-3.4.
|
104
|
-
openstef-3.4.
|
98
|
+
openstef/validation/validation.py,sha256=F2tMG8T4sxl3-3zVzshgbBd5xVi7ERmKuqfPVAUp9p0,10445
|
99
|
+
openstef-3.4.16.dist-info/LICENSE,sha256=7Pm2fWFFHHUG5lDHed1vl5CjzxObIXQglnYsEdtjo_k,14907
|
100
|
+
openstef-3.4.16.dist-info/METADATA,sha256=tjLeznPeOd1mRLGirVr8ou6G6s-6TrX62BQ3xMKGPJ4,8125
|
101
|
+
openstef-3.4.16.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
|
102
|
+
openstef-3.4.16.dist-info/top_level.txt,sha256=kD0H4PqrQoncZ957FvqwfBxa89kTrun4Z_RAPs_HhLs,9
|
103
|
+
openstef-3.4.16.dist-info/RECORD,,
|
openstef/tasks/run_tracy.py
DELETED
@@ -1,145 +0,0 @@
|
|
1
|
-
# SPDX-FileCopyrightText: 2017-2023 Contributors to the OpenSTEF project <korte.termijn.prognoses@alliander.com> # noqa E501>
|
2
|
-
#
|
3
|
-
# SPDX-License-Identifier: MPL-2.0
|
4
|
-
"""Tracy checks the mysql todolist and tries her best to execute the functions with desired inputs.
|
5
|
-
|
6
|
-
This scripts works as follows:
|
7
|
-
1. Checks the mysql table 'todolist' for jobs (which are not already in progress and
|
8
|
-
which are not already failed)
|
9
|
-
2. Set all newly acquired jobs to 'in progress'
|
10
|
-
For each job:
|
11
|
-
3. Convert input arguments to a dict with 'args' and 'kwargs'
|
12
|
-
4. Interpret the given function and arguments
|
13
|
-
5. Execute the job
|
14
|
-
6. Post result to Teams
|
15
|
-
7. Remove job from mysql table
|
16
|
-
If job fails, set in progress to 2
|
17
|
-
All functions that tracy is able to execute need to be imported and defined in the
|
18
|
-
available_functions.
|
19
|
-
|
20
|
-
Example:
|
21
|
-
This module is meant to be called directly from a CRON job.
|
22
|
-
|
23
|
-
Alternatively this code can be run directly by running::
|
24
|
-
$ python run_tracy.py
|
25
|
-
|
26
|
-
"""
|
27
|
-
# sql to create the Tracy jobs table (todolist)
|
28
|
-
|
29
|
-
# CREATE TABLE IF NOT EXISTS `tst_icarus`.`todolist` (
|
30
|
-
# `id` INT NOT NULL AUTO_INCREMENT ,
|
31
|
-
# `created` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ,
|
32
|
-
# `function` VARCHAR(200) NOT NULL ,
|
33
|
-
# `args` VARCHAR(200) NOT NULL ,
|
34
|
-
# `inprogress` BOOLEAN NULL DEFAULT NULL ,
|
35
|
-
# PRIMARY KEY (`id`), UNIQUE `id` (`id`))
|
36
|
-
# ENGINE = InnoDB;
|
37
|
-
from pathlib import Path
|
38
|
-
|
39
|
-
from openstef.data_classes.prediction_job import PredictionJobDataClass
|
40
|
-
from openstef.enums import TracyJobResult
|
41
|
-
from openstef.monitoring import teams
|
42
|
-
from openstef.tasks.optimize_hyperparameters import optimize_hyperparameters_task
|
43
|
-
from openstef.tasks.train_model import train_model_task
|
44
|
-
from openstef.tasks.utils.taskcontext import TaskContext
|
45
|
-
|
46
|
-
|
47
|
-
def run_tracy(context: TaskContext) -> None:
|
48
|
-
# Get all Tracy jobs
|
49
|
-
tracy_jobs = context.database.ktp_api.get_all_tracy_jobs(inprogress=0)
|
50
|
-
num_jobs = len(tracy_jobs)
|
51
|
-
|
52
|
-
if num_jobs == 0:
|
53
|
-
context.logger.warning(f"Number of tracy jobs is {num_jobs}, exit task")
|
54
|
-
return
|
55
|
-
|
56
|
-
context.logger.info("Start processing Tracy jobs", num_jobs=num_jobs)
|
57
|
-
|
58
|
-
for i, job in enumerate(tracy_jobs):
|
59
|
-
# get a new logger with bound job
|
60
|
-
logger = context.logger.bind(job=job)
|
61
|
-
logger.info("Process job", job_counter=i, total_jobs=num_jobs)
|
62
|
-
|
63
|
-
# Set all retrieved items of the todolist to inprogress
|
64
|
-
job["inprogress"] = 1
|
65
|
-
context.database.ktp_api.update_tracy_job(job)
|
66
|
-
|
67
|
-
pid = int(job["args"])
|
68
|
-
pj = context.database.get_prediction_job(pid)
|
69
|
-
result, exc = run_tracy_job(job, pj, context)
|
70
|
-
# job processing was succefull
|
71
|
-
if result is TracyJobResult.SUCCESS:
|
72
|
-
logger.info("Succesfully processed Tracy job")
|
73
|
-
# Delete job when succesfull
|
74
|
-
context.database.ktp_api.delete_tracy_job(job)
|
75
|
-
logger.info("Delete Tracy job")
|
76
|
-
|
77
|
-
# job was unknown
|
78
|
-
elif result is TracyJobResult.UNKNOWN:
|
79
|
-
logger.error(f"Unkown Tracy job {job['function']}")
|
80
|
-
|
81
|
-
# job processing failed / raised an exception
|
82
|
-
elif result is TracyJobResult.FAILED:
|
83
|
-
job["inprogress"] = 2
|
84
|
-
context.database.ktp_api.update_tracy_job(job)
|
85
|
-
msg = "Exception occured while processing Tracy job"
|
86
|
-
logger.error(msg, exc_info=exc)
|
87
|
-
teams.post_teams(teams.format_message(title=msg, params=job))
|
88
|
-
|
89
|
-
context.logger.info("Finished processing all Tracy jobs - Tracy out!")
|
90
|
-
|
91
|
-
|
92
|
-
def run_tracy_job(
|
93
|
-
job: dict, pj: PredictionJobDataClass, context: TaskContext
|
94
|
-
) -> TracyJobResult:
|
95
|
-
"""Run tracy job.
|
96
|
-
|
97
|
-
Args:
|
98
|
-
job: Tracy jon
|
99
|
-
pj: Prediction job
|
100
|
-
context: Task context.
|
101
|
-
|
102
|
-
Returns:
|
103
|
-
Result of the Tracy job.
|
104
|
-
|
105
|
-
"""
|
106
|
-
# Try to process Tracy job
|
107
|
-
try:
|
108
|
-
# If train model job (TODO remove old name when jobs are done)
|
109
|
-
if job["function"] in ["train_model", "train_specific_model"]:
|
110
|
-
train_model_task(pj, context, check_old_model_age=False)
|
111
|
-
|
112
|
-
# If optimize hyperparameters job (TODO remove old name when jobs are done)
|
113
|
-
elif job["function"] in [
|
114
|
-
"optimize_hyperparameters",
|
115
|
-
"optimize_hyperparameters_for_specific_pid",
|
116
|
-
]:
|
117
|
-
optimize_hyperparameters_task(pj, context, check_hyper_param_age=False)
|
118
|
-
|
119
|
-
# Else unknown job
|
120
|
-
else:
|
121
|
-
return TracyJobResult.UNKNOWN, None
|
122
|
-
|
123
|
-
# job processing was succesfull
|
124
|
-
return TracyJobResult.SUCCESS, None
|
125
|
-
|
126
|
-
# Processing of Tracy job failed
|
127
|
-
except Exception as e:
|
128
|
-
return TracyJobResult.FAILED, e
|
129
|
-
|
130
|
-
|
131
|
-
def main(config=None, database=None):
|
132
|
-
taskname = Path(__file__).name.replace(".py", "")
|
133
|
-
|
134
|
-
if database is None or config is None:
|
135
|
-
raise RuntimeError(
|
136
|
-
"Please specifiy a config object and/or database connection object. These"
|
137
|
-
" can be found in the openstef-dbc package."
|
138
|
-
)
|
139
|
-
|
140
|
-
with TaskContext(taskname, config, database) as context:
|
141
|
-
run_tracy(context)
|
142
|
-
|
143
|
-
|
144
|
-
if __name__ == "__main__":
|
145
|
-
main()
|
File without changes
|
File without changes
|
File without changes
|