Skip to content

Commit

Permalink
Debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
yngve-sk committed Jan 13, 2025
1 parent 96d3029 commit 8627f8f
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 6 deletions.
3 changes: 3 additions & 0 deletions src/ert/analysis/_es_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import functools
import logging
import time
import traceback
from collections.abc import Callable, Iterable, Sequence
from fnmatch import fnmatch
from typing import (
Expand Down Expand Up @@ -875,6 +876,8 @@ def iterative_smoother_update(
initial_mask=initial_mask,
)
except Exception as e:
print("Exception!")
traceback.print_tb(e.__traceback__)
progress_callback(
AnalysisErrorEvent(
error_msg=str(e),
Expand Down
5 changes: 5 additions & 0 deletions src/ert/run_models/base_run_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import os
import shutil
import time
import traceback
import uuid
from abc import ABC, abstractmethod
from collections import defaultdict
Expand Down Expand Up @@ -212,6 +213,10 @@ def group(cls) -> str | None:
return None

def send_event(self, event: StatusEvents) -> None:
if hasattr(event, "error_msg"):
traceback.print_stack()
print(event.error_msg)

self._status_queue.put(event)

def send_smoother_event(
Expand Down
19 changes: 13 additions & 6 deletions tests/ert/ui_tests/cli/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import os
import stat
import threading
import traceback
from datetime import datetime
from pathlib import Path
from textwrap import dedent
Expand Down Expand Up @@ -556,7 +557,7 @@ def test_that_stop_on_fail_workflow_jobs_stop_ert(


@pytest.mark.usefixtures("copy_poly_case")
def test_that_pre_post_experiment_hook_works(capsys):
def test_that_pre_post_experiment_hook_works():
# The executable
with open("hello_post_exp.sh", "w", encoding="utf-8") as f:
f.write(
Expand Down Expand Up @@ -615,11 +616,17 @@ def test_that_pre_post_experiment_hook_works(capsys):
)

for mode in [ITERATIVE_ENSEMBLE_SMOOTHER_MODE, ES_MDA_MODE, ENSEMBLE_SMOOTHER_MODE]:
run_cli(mode, "--disable-monitor", "poly.ert")

captured = capsys.readouterr()
assert "first" in captured.out
assert "just sending regards" in captured.out
try:
run_cli(mode, "--disable-monitor", "poly.ert")
except Exception as e:
print(f"{mode}")
print(traceback.format_exc())
print("\n".join(traceback.format_tb(e.__traceback__)))
print(str(e.__traceback__))

# captured = capsys.readouterr()
# assert "first" in captured.out
# assert "just sending regards" in captured.out


@pytest.fixture(name="mock_cli_run")
Expand Down

0 comments on commit 8627f8f

Please sign in to comment.