Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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.
berland committed Oct 2, 2024
1 parent 4321e49 commit 33ea59e
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
@@ -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 or end_event.failed:

Check failure on line 143 in src/ert/cli/main.py

GitHub Actions / type-checking (3.12)

"None" has no attribute "failed"
# If monitor has not reported, give some info if the job failed
msg = end_event.msg if args.disable_monitoring else ""

Check failure on line 145 in src/ert/cli/main.py

GitHub Actions / type-checking (3.12)

Item "None" of "EndEvent | None" has no attribute "msg"
raise ErtCliError(msg)

0 comments on commit 33ea59e

Please sign in to comment.