Coverage for mlair/workflows/default_workflow.py: 100%
22 statements
« prev ^ index » next coverage.py v6.4.2, created at 2023-12-18 17:51 +0000
« prev ^ index » next coverage.py v6.4.2, created at 2023-12-18 17:51 +0000
1"""Default workflow."""
3__author__ = "Lukas Leufen"
4__date__ = '2020-06-26'
6import inspect
7from mlair.helpers import remove_items
8from mlair.run_modules import ExperimentSetup, PreProcessing, PartitionCheck, ModelSetup, Training, PostProcessing
9from mlair.workflows.abstract_workflow import Workflow
12class DefaultWorkflow(Workflow):
13 """A default workflow executing ExperimentSetup, PreProcessing, ModelSetup, Training and PostProcessing in exact
14 the mentioned ordering."""
16 def __init__(self, stations=None,
17 train_model=None, create_new_model=None,
18 window_history_size=None,
19 experiment_date="testrun",
20 variables=None, statistics_per_var=None,
21 start=None, end=None,
22 target_var=None, target_dim=None,
23 window_lead_time=None,
24 dimensions=None,
25 interpolation_method=None, time_dim=None, limit_nan_fill=None,
26 train_start=None, train_end=None, val_start=None, val_end=None, test_start=None, test_end=None,
27 use_all_stations_on_all_data_sets=None, fraction_of_train=None,
28 experiment_path=None, plot_path=None, forecast_path=None, bootstrap_path=None,
29 overwrite_local_data=None,
30 sampling=None,
31 permute_data_on_training=None, extreme_values=None, extremes_on_right_tail_only=None,
32 transformation=None,
33 train_min_length=None, val_min_length=None, test_min_length=None,
34 plot_list=None,
35 model=None,
36 batch_size=None,
37 epochs=None,
38 data_handler=None,
39 log_level_stream=None,
40 **kwargs):
41 super().__init__(log_level_stream=log_level_stream)
43 # extract all given kwargs arguments
44 params = remove_items(inspect.getfullargspec(self.__init__).args, "self")
45 kwargs_default = {k: v for k, v in locals().items() if k in params and v is not None}
46 self._setup(**kwargs_default, **kwargs)
48 def _setup(self, **kwargs):
49 """Set up default workflow."""
50 self.add(ExperimentSetup, **kwargs)
51 self.add(PreProcessing)
52 self.add(ModelSetup)
53 self.add(Training)
54 self.add(PostProcessing)
57class DefaultWorkflowHPC(DefaultWorkflow):
58 """A default workflow for Jülich HPC systems executing ExperimentSetup, PreProcessing, PartitionCheck, ModelSetup,
59 Training and PostProcessing in exact the mentioned ordering."""
61 def _setup(self, **kwargs):
62 """Set up default workflow."""
63 self.add(ExperimentSetup, **kwargs)
64 self.add(PreProcessing)
65 self.add(PartitionCheck)
66 self.add(ModelSetup)
67 self.add(Training)
68 self.add(PostProcessing)