From 2fd710c32e89aad9fe0b42c74996e033324add7a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A5vard=20Berland?= Date: Tue, 17 Sep 2024 14:14:31 +0200 Subject: [PATCH] Log all settings for run-models --- src/ert/run_models/base_run_model.py | 18 ++++++++++++++++++ src/ert/run_models/ensemble_experiment.py | 2 +- src/ert/run_models/ensemble_smoother.py | 2 +- src/ert/run_models/evaluate_ensemble.py | 2 +- .../run_models/iterated_ensemble_smoother.py | 6 +----- src/ert/run_models/manual_update.py | 2 +- .../run_models/multiple_data_assimilation.py | 3 +-- 7 files changed, 24 insertions(+), 11 deletions(-) diff --git a/src/ert/run_models/base_run_model.py b/src/ert/run_models/base_run_model.py index ef4c1737fc9..6924b048a6a 100644 --- a/src/ert/run_models/base_run_model.py +++ b/src/ert/run_models/base_run_model.py @@ -189,6 +189,24 @@ def __init__( self.start_iteration = start_iteration self.validate() + def log_at_startup(self) -> None: + keys_to_drop = [ + "_end_queue", + "_queue_config", + "_status_queue", + "_storage", + "ert_config", + "rng", + "run_paths", + "substitution_list", + ] + settings_dict = { + key: value + for key, value in self.__dict__.items() + if key not in keys_to_drop + } + logger.info(f"Running '{self.name()}' with settings {settings_dict}") + @classmethod @abstractmethod def name(cls) -> str: ... diff --git a/src/ert/run_models/ensemble_experiment.py b/src/ert/run_models/ensemble_experiment.py index 8fa4487b979..8162c243604 100644 --- a/src/ert/run_models/ensemble_experiment.py +++ b/src/ert/run_models/ensemble_experiment.py @@ -60,7 +60,7 @@ def run_experiment( evaluator_server_config: EvaluatorServerConfig, restart: bool = False, ) -> None: - logger.info(f"Running {self.name()}") + self.log_at_startup() if not restart: self.experiment = self._storage.create_experiment( name=self.experiment_name, diff --git a/src/ert/run_models/ensemble_smoother.py b/src/ert/run_models/ensemble_smoother.py index 2c1f1ab8db2..547efdfcd3e 100644 --- a/src/ert/run_models/ensemble_smoother.py +++ b/src/ert/run_models/ensemble_smoother.py @@ -59,7 +59,7 @@ def __init__( def run_experiment( self, evaluator_server_config: EvaluatorServerConfig, restart: bool = False ) -> None: - logger.info(f"Running {self.name()}") + self.log_at_startup() ensemble_format = self.target_ensemble_format experiment = self._storage.create_experiment( parameters=self.ert_config.ensemble_config.parameter_configuration, diff --git a/src/ert/run_models/evaluate_ensemble.py b/src/ert/run_models/evaluate_ensemble.py index 80c529e67f5..de0079c57d9 100644 --- a/src/ert/run_models/evaluate_ensemble.py +++ b/src/ert/run_models/evaluate_ensemble.py @@ -63,7 +63,7 @@ def __init__( def run_experiment( self, evaluator_server_config: EvaluatorServerConfig, restart: bool = False ) -> None: - logger.info(f"Running {self.name()}") + self.log_at_startup() ensemble = self.ensemble experiment = ensemble.experiment self.set_env_key("_ERT_EXPERIMENT_ID", str(experiment.id)) diff --git a/src/ert/run_models/iterated_ensemble_smoother.py b/src/ert/run_models/iterated_ensemble_smoother.py index c5930299399..c20d12ab2d0 100644 --- a/src/ert/run_models/iterated_ensemble_smoother.py +++ b/src/ert/run_models/iterated_ensemble_smoother.py @@ -120,11 +120,7 @@ def analyzeStep( def run_experiment( self, evaluator_server_config: EvaluatorServerConfig, restart: bool = False ) -> None: - log_msg = ( - f"Running {self.name} for {self._total_iterations} " - f'iteration{"s" if (self._total_iterations != 1) else ""}.' - ) - logger.info(log_msg) + self.log_at_startup() target_ensemble_format = self.target_ensemble_format experiment = self._storage.create_experiment( diff --git a/src/ert/run_models/manual_update.py b/src/ert/run_models/manual_update.py index d166aac08f6..9997430e642 100644 --- a/src/ert/run_models/manual_update.py +++ b/src/ert/run_models/manual_update.py @@ -65,7 +65,7 @@ def __init__( def run_experiment( self, evaluator_server_config: EvaluatorServerConfig, restart: bool = False ) -> None: - logger.info(f"Running {self.name()}") + self.log_at_startup() self.set_env_key("_ERT_EXPERIMENT_ID", str(self.prior.experiment.id)) self.set_env_key("_ERT_ENSEMBLE_ID", str(self.prior.id)) diff --git a/src/ert/run_models/multiple_data_assimilation.py b/src/ert/run_models/multiple_data_assimilation.py index 49090babaf7..9fed4cbbd23 100644 --- a/src/ert/run_models/multiple_data_assimilation.py +++ b/src/ert/run_models/multiple_data_assimilation.py @@ -80,8 +80,7 @@ def __init__( def run_experiment( self, evaluator_server_config: EvaluatorServerConfig, restart: bool = False ) -> None: - logger.info(f"Running {self.name()} with normalized weights {self.weights}") - + self.log_at_startup() if self.restart_run: id = self.prior_ensemble_id try: