Skip to content

Commit

Permalink
Debuggingss
Browse files Browse the repository at this point in the history
  • Loading branch information
yngve-sk committed Jan 14, 2025
1 parent c26056d commit a0fb136
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 7 deletions.
11 changes: 10 additions & 1 deletion .github/workflows/test_ert.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,16 @@ jobs:
- name: CLI Test
if: inputs.test-type == 'cli-tests'
run: |
pytest --cov=ert --cov=everest --cov=_ert --cov-report=xml:cov1.xml --junit-xml=junit.xml -o junit_family=legacy -v --benchmark-disable --dist loadgroup tests/ert/ui_tests/cli --durations=25
echo {{github.workspace}}
pytest -x --cov=ert --cov=everest --cov=_ert --cov-report=xml:cov1.xml --junit-xml=junit.xml -o junit_family=legacy -v --benchmark-disable --dist loadgroup tests/ert/ui_tests/cli --durations=25
- name: Upload checkme folder if exists
if: ${{ !cancelled() }}
continue-on-error: true
uses: actions/upload-artifact@v4
with:
name: folder-artifact
path: '/tmp/pytest-of-runner/**/checkme'

- name: Unit Test
if: inputs.test-type == 'unit-tests'
Expand Down
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 @@ -876,6 +877,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 @@ -213,6 +214,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
32 changes: 26 additions & 6 deletions tests/ert/ui_tests/cli/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
import json
import logging
import os
import shutil
import stat
import threading
import traceback
from datetime import datetime
from pathlib import Path
from textwrap import dedent
Expand Down Expand Up @@ -556,7 +558,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 @@ -613,13 +615,31 @@ def test_that_pre_post_experiment_hook_works(capsys):
"""
)
)
cwd = os.getcwd()
# Copy cwd one level up

for mode in [ITERATIVE_ENSEMBLE_SMOOTHER_MODE, ES_MDA_MODE, ENSEMBLE_SMOOTHER_MODE]:
run_cli(mode, "--disable-monitor", "poly.ert")
dst = str(Path(cwd) / ".." / "checkme")
print(f"If fail, will copy project w/ fail from {cwd} to {dst}")

captured = capsys.readouterr()
assert "first" in captured.out
assert "just sending regards" in captured.out
for mode in [ITERATIVE_ENSEMBLE_SMOOTHER_MODE, ES_MDA_MODE, ENSEMBLE_SMOOTHER_MODE]:
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__))
cwd = os.getcwd()
# Copy cwd one level up

dst = str(Path(cwd) / ".." / "checkme")
shutil.copytree(cwd, dst)
print(f"Copied project w/ fail from {cwd} to {dst}")
raise AssertionError() from e

# 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 a0fb136

Please sign in to comment.