Skip to content

Commit

Permalink
Avoid possible UnboundLocalError for end_event
Browse files Browse the repository at this point in the history
The error has been observed to occur in the log. Not trying
to display further error messages to why it is None.
  • Loading branch information
berland committed Oct 11, 2024
1 parent 776174b commit c31c5d8
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/ert/cli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand All @@ -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)

0 comments on commit c31c5d8

Please sign in to comment.