Skip to content
Snippets Groups Projects
Commit fbc1e07d authored by lukas leufen's avatar lukas leufen
Browse files

Merge branch 'lukas_issue300_feat_mean-bootstrapping' into 'lukas_issue099_tech_store-run-script'

accidently pushed to wrong branch

See merge request !316
parents 87b5b2b1 61f97525
No related branches found
No related tags found
6 merge requests!319add all changes of dev into release v1.4.0 branch,!318Resolve "release v1.4.0",!317enabled window_lead_time=1,!316accidently pushed to wrong branch,!315Resolve "Store run script in experiment dir",!259Draft: Resolve "WRF-Datahandler should inherit from SingleStationDatahandler"
Pipeline #73875 passed
......@@ -6,6 +6,7 @@ import logging
import os
import sys
from typing import Union, Dict, Any, List, Callable
from dill.source import getsource
from mlair.configuration import path_config
from mlair import helpers
......@@ -217,7 +218,7 @@ class ExperimentSetup(RunEnvironment):
hpc_hosts=None, model=None, batch_size=None, epochs=None, data_handler=None,
data_origin: Dict = None, competitors: list = None, competitor_path: str = None,
use_multiprocessing: bool = None, use_multiprocessing_on_debug: bool = None,
max_number_multiprocessing: int = None, **kwargs):
max_number_multiprocessing: int = None, start_script: Union[Callable, str] = None, **kwargs):
# create run framework
super().__init__()
......@@ -366,6 +367,10 @@ class ExperimentSetup(RunEnvironment):
# set model architecture class
self._set_param("model_class", model, VanillaModel)
# store starting script if provided
if start_script is not None:
self._store_start_script(start_script, experiment_path)
# set remaining kwargs
if len(kwargs) > 0:
for k, v in kwargs.items():
......@@ -387,6 +392,18 @@ class ExperimentSetup(RunEnvironment):
logging.debug(f"set experiment attribute: {param}({scope})={value}")
return value
@staticmethod
def _store_start_script(start_script, store_path):
out_file = os.path.join(store_path, "start_script.txt")
if isinstance(start_script, Callable):
with open(out_file, "w") as fh:
fh.write(getsource(start_script))
if isinstance(start_script, str):
with open(start_script, 'r') as f:
with open(out_file, "w") as out:
for line in (f.readlines()):
print(line, end='', file=out)
def _compare_variables_and_statistics(self):
"""
Compare variables and statistics.
......
......@@ -28,7 +28,7 @@ def main(parser_args):
evaluate_bootstraps=False, # plot_list=["PlotCompetitiveSkillScore"],
competitors=["test_model", "test_model2"],
competitor_path=os.path.join(os.getcwd(), "data", "comp_test"),
**parser_args.__dict__)
**parser_args.__dict__, start_script=__file__)
workflow.run()
......
......@@ -7,7 +7,7 @@ from mlair.workflows import DefaultWorkflowHPC
def main(parser_args):
workflow = DefaultWorkflowHPC(**parser_args.__dict__)
workflow = DefaultWorkflowHPC(**parser_args.__dict__, start_script=__file__)
workflow.run()
......
......@@ -22,7 +22,7 @@ def main(parser_args):
train_model=False,
create_new_model=False,
network="UBA",
plot_list=["PlotStationMap"], **parser_args.__dict__)
plot_list=["PlotStationMap"], **parser_args.__dict__, start_script=__file__)
workflow.run()
......
......@@ -19,7 +19,7 @@ def main(parser_args):
test_end="2011-12-31",
stations=["DEBW107", "DEBW013"]
)
workflow = DefaultWorkflow(**args)
workflow = DefaultWorkflow(**args, start_script=__file__)
workflow.run()
......
......@@ -36,7 +36,7 @@ def main(parser_args):
test_end="2011-12-31",
**parser_args.__dict__,
)
workflow = DefaultWorkflow(**args)
workflow = DefaultWorkflow(**args, start_script=__file__)
workflow.run()
......
......@@ -31,7 +31,7 @@ def load_stations():
def main(parser_args):
workflow = DefaultWorkflowHPC(stations=load_stations(), **parser_args.__dict__)
workflow = DefaultWorkflowHPC(stations=load_stations(), **parser_args.__dict__, start_script=__file__)
workflow.run()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment