From ed3c27fa9b1658f40073938fd5c76c00a468c31a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A5vard=20Berland?= Date: Wed, 2 Oct 2024 09:05:39 +0200 Subject: [PATCH] Avoid possible UnboundLocalError for end_event The error has been observed to occur in the log. Not trying to display further error messages to why it is None. --- src/ert/cli/main.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/ert/cli/main.py b/src/ert/cli/main.py index 0d10d412d44..fd305b896f0 100644 --- a/src/ert/cli/main.py +++ b/src/ert/cli/main.py @@ -13,7 +13,7 @@ from ert.cli.monitor import Monitor from ert.cli.workflow import execute_workflow from ert.config import ErtConfig, QueueSystem -from ert.ensemble_evaluator import EvaluatorServerConfig +from ert.ensemble_evaluator import EndEvent, EvaluatorServerConfig from ert.mode_definitions import ( ENSEMBLE_EXPERIMENT_MODE, ENSEMBLE_SMOOTHER_MODE, @@ -128,6 +128,7 @@ def run_cli(args: Namespace, plugin_manager: Optional[ErtPluginManager] = None) out = sys.stderr monitor = Monitor(out=out, color_always=args.color_always) thread.start() + end_event: Optional[EndEvent] = None try: end_event = monitor.monitor( status_queue, ert_config.analysis_config.log_path @@ -139,7 +140,7 @@ def run_cli(args: Namespace, plugin_manager: Optional[ErtPluginManager] = None) thread.join() storage.close() - if end_event.failed: + if end_event is not None and end_event.failed: # If monitor has not reported, give some info if the job failed msg = end_event.msg if args.disable_monitoring else "" raise ErtCliError(msg)