Skip to content

Commit

Permalink
removed all tracy related code (#524)
Browse files Browse the repository at this point in the history
* removed all tracy related code

Signed-off-by: Jonita Ruiter <[email protected]>

* removed the left over tracy things

Signed-off-by: Jonita Ruiter <[email protected]>

* fixed black format code error

Signed-off-by: Jonita Ruiter <[email protected]>

* lint fail fix unused local variable

Signed-off-by: Jonita Ruiter <[email protected]>

* lint fail fix unused local variable and isorted all files

Signed-off-by: Jonita Ruiter <[email protected]>

---------

Signed-off-by: Jonita Ruiter <[email protected]>
  • Loading branch information
JonitaRuiter authored Mar 27, 2024
1 parent 48149fa commit 5f668dd
Show file tree
Hide file tree
Showing 20 changed files with 20 additions and 325 deletions.
21 changes: 0 additions & 21 deletions docs/sql_database_diagram.rst
Original file line number Diff line number Diff line change
Expand Up @@ -299,27 +299,6 @@ API key to retrieve systems measurements.
| apiKey | chr | API key value | uuid-Measurements |
+----------------+----------------+-----------------+-------------------+

todolist
^^^^^^^^

+----------------------+-------------+----------------+----------------+
| **Name** | **Type** | **Comment** | **Example** |
+======================+=============+================+================+
| id | int | id of the job | |
+----------------------+-------------+----------------+----------------+
| created | datetime | | |
+----------------------+-------------+----------------+----------------+
| function | chr | functions to | |
| | | execute | |
+----------------------+-------------+----------------+----------------+
| args | chr | arguments of | |
| | | the functions | |
+----------------------+-------------+----------------+----------------+
| inprogress | int | | |
+----------------------+-------------+----------------+----------------+

The todolist table stores jobs that are picked up by the tracy procces that is run every 5 minutes via a CRON job. This makes it possible to run pipelines manually by adding the respective job to the todo list.

weatherforecastlocations
^^^^^^^^^^^^^^^^^^^^^^^^
Contains the locations of the weather stations. These are used when retrieving weather data for a prediction.
Expand Down
2 changes: 1 addition & 1 deletion openstef/data_classes/data_prep.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import inspect
import json
from importlib import import_module
from typing import Any, Sequence, Union, TypeVar
from typing import Any, Sequence, TypeVar, Union

from pydantic.v1 import BaseModel

Expand Down
2 changes: 1 addition & 1 deletion openstef/data_classes/prediction_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@

from pydantic.v1 import BaseModel

from openstef.data_classes.data_prep import DataPrepDataClass
from openstef.data_classes.model_specifications import ModelSpecificationDataClass
from openstef.data_classes.split_function import SplitFuncDataClass
from openstef.data_classes.data_prep import DataPrepDataClass
from openstef.enums import PipelineType


Expand Down
6 changes: 0 additions & 6 deletions openstef/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,6 @@ class ForecastType(Enum):
BASECASE = "basecase"


class TracyJobResult(Enum):
SUCCESS = "success"
FAILED = "failed"
UNKNOWN = "unknown"


class PipelineType(Enum):
FORECAST = "forecast"
TRAIN = "train"
Expand Down
10 changes: 5 additions & 5 deletions openstef/feature_engineering/data_preparation.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
# SPDX-FileCopyrightText: 2017-2023 Alliander N.V. <[email protected]> # noqa E501>
#
# SPDX-License-Identifier: MPL-2.0
import structlog

from abc import ABC, abstractmethod
from datetime import timedelta
from typing import Optional

import pandas as pd
from datetime import timedelta
import structlog

from openstef.data_classes.model_specifications import ModelSpecificationDataClass
from openstef.data_classes.prediction_job import PredictionJobDataClass
from openstef.model.regressors.regressor import OpenstfRegressor
from openstef.feature_engineering.feature_applicator import (
TrainFeatureApplicator,
OperationalPredictFeatureApplicator,
TrainFeatureApplicator,
)
from openstef.feature_engineering.general import (
enforce_feature_order,
remove_non_requested_feature_columns,
)
from openstef.model.regressors.regressor import OpenstfRegressor
from openstef.pipeline.utils import generate_forecast_datetime_range


Expand Down
2 changes: 1 addition & 1 deletion openstef/model/model_creator.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
import structlog

from openstef.enums import MLModelType
from openstef.model.regressors.arima import ARIMAOpenstfRegressor
from openstef.model.regressors.custom_regressor import is_custom_type, load_custom_model
from openstef.model.regressors.lgbm import LGBMOpenstfRegressor
from openstef.model.regressors.linear import LinearOpenstfRegressor
from openstef.model.regressors.regressor import OpenstfRegressor
from openstef.model.regressors.xgb import XGBOpenstfRegressor
from openstef.model.regressors.xgb_quantile import XGBQuantileOpenstfRegressor
from openstef.model.regressors.arima import ARIMAOpenstfRegressor

logger = structlog.get_logger(__name__)

Expand Down
2 changes: 1 addition & 1 deletion openstef/model/objective_creator.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@

from openstef.enums import MLModelType
from openstef.model.objective import (
ARIMARegressorObjective,
LGBRegressorObjective,
LinearRegressorObjective,
RegressorObjective,
XGBQuantileRegressorObjective,
XGBRegressorObjective,
ARIMARegressorObjective,
)
from openstef.model.regressors.custom_regressor import (
create_custom_objective,
Expand Down
2 changes: 1 addition & 1 deletion openstef/model/regressors/arima.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
import numpy as np
import pandas as pd
import statsmodels.api as sm

from sklearn.metrics import r2_score
from sklearn.model_selection import TimeSeriesSplit

from openstef.model.regressors.regressor import OpenstfRegressor


Expand Down
3 changes: 1 addition & 2 deletions openstef/monitoring/performance_meter.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ def start_level(self, level_label: str, level_name: str, **kwargs):
Args:
level_label: The label of the new level. This could i.e. be 'task'
level_name: The name of the specified level. This could i.e. be
'tracy_todo'
level_name: The name of the specified level.
**kwargs: Any other kwargs are appended to the logging.
Returns:
Expand Down
2 changes: 1 addition & 1 deletion openstef/pipeline/create_basecase_forecast.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import structlog

from openstef.data_classes.prediction_job import PredictionJobDataClass
from openstef.exceptions import NoRealisedLoadError, InputDataOngoingZeroFlatlinerError
from openstef.exceptions import InputDataOngoingZeroFlatlinerError, NoRealisedLoadError
from openstef.feature_engineering.feature_applicator import (
OperationalPredictFeatureApplicator,
)
Expand Down
3 changes: 1 addition & 2 deletions openstef/pipeline/create_component_forecast.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# SPDX-License-Identifier: MPL-2.0

import joblib
import numpy as np
import pandas as pd
import structlog

Expand All @@ -12,8 +13,6 @@
from openstef.enums import ForecastType
from openstef.model.regressors.dazls import Dazls

import numpy as np

# Set the path for the Dazls stored model
DAZLS_STORED = str(
PROJECT_ROOT / "openstef" / "data" / "dazls_model_3.4.7" / "dazls_stored_3.4.7_"
Expand Down
2 changes: 1 addition & 1 deletion openstef/pipeline/optimize_hyperparameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@
from openstef.model.objective_creator import ObjectiveCreator
from openstef.model.regressors.regressor import OpenstfRegressor
from openstef.model.serializer import MLflowSerializer
from openstef.model_selection.model_selection import split_data_train_validation_test
from openstef.pipeline.train_model import (
DEFAULT_TRAIN_HORIZONS_HOURS,
train_model_pipeline_core,
)
from openstef.validation import validation
from openstef.model_selection.model_selection import split_data_train_validation_test

optuna.logging.enable_propagation() # Propagate logs to the root logger.
optuna.logging.disable_default_handler() # Stop showing logs in sys.stderr.
Expand Down
7 changes: 0 additions & 7 deletions openstef/tasks/calculate_kpi.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,6 @@ def check_kpi_task(
rMAE=kpis["47.0h"]["rMAE"],
retraining_threshold=THRESHOLD_RETRAINING,
)
function_name = "train_model"

context.logger.info("Adding tracy job", function=function_name)
context.database.ktp_api.add_tracy_job(pj["id"], function=function_name)

if kpis["47.0h"]["rMAE"] > THRESHOLD_OPTIMIZING:
context.logger.warning(
Expand All @@ -118,9 +114,6 @@ def check_kpi_task(
rMAE=kpis["47.0h"]["rMAE"],
optimizing_threshold=THRESHOLD_OPTIMIZING,
)
function_name = "optimize_hyperparameters"
context.logger.info("Adding tracy job", function=function_name)
context.database.ktp_api.add_tracy_job(pj["id"], function=function_name)


def calc_kpi_for_specific_pid(
Expand Down
2 changes: 1 addition & 1 deletion openstef/tasks/create_components_forecast.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
from datetime import datetime, timedelta, timezone
from pathlib import Path

import structlog
import pandas as pd
import structlog

from openstef.data_classes.prediction_job import PredictionJobDataClass
from openstef.enums import MLModelType
Expand Down
145 changes: 0 additions & 145 deletions openstef/tasks/run_tracy.py

This file was deleted.

8 changes: 3 additions & 5 deletions openstef/tasks/train_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,22 +23,20 @@
from pathlib import Path

from openstef.data_classes.prediction_job import PredictionJobDataClass

from openstef.enums import MLModelType, PipelineType
from openstef.exceptions import (
SkipSaveTrainingForecasts,
InputDataOngoingZeroFlatlinerError,
SkipSaveTrainingForecasts,
)
from openstef.model.serializer import MLflowSerializer
from openstef.pipeline.train_model import (
MAXIMUM_MODEL_AGE,
train_model_pipeline,
train_pipeline_step_load_model,
MAXIMUM_MODEL_AGE,
)
from openstef.tasks.utils.predictionjobloop import PredictionJobLoop
from openstef.tasks.utils.taskcontext import TaskContext

from openstef.model.serializer import MLflowSerializer

TRAINING_PERIOD_DAYS: int = 120
DEFAULT_CHECK_MODEL_AGE: bool = True

Expand Down
Loading

0 comments on commit 5f668dd

Please sign in to comment.