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 23, 2024
1 parent 5717e4d commit b04bd19
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 @@ -124,6 +124,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 @@ -135,7 +136,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 b04bd19

Please sign in to comment.