Skip to content

Commit 4c87a31

Browse files
committed
Add warning when warning-cap is reached
1 parent a04e284 commit 4c87a31

2 files changed

Lines changed: 9 additions & 0 deletions

File tree

src/ert/scheduler/job.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -581,4 +581,8 @@ async def wait_for_file(file_path: Path, _timeout: int) -> int:
581581
)
582582
if timeout_seconds <= 0:
583583
break
584+
if log_count >= max_logged_warnings:
585+
logger.warning(
586+
"Reached maximum number of forward model step warnings to extract"
587+
)
584588
return timeout_seconds

tests/ert/unit_tests/scheduler/test_job.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -483,6 +483,7 @@ async def test_log_warnings_from_forward_model(
483483
warnings.simplefilter("error")
484484
await log_warnings_from_forward_model(realization, start_time - 1)
485485
assert emitted_warning_str not in caplog.text
486+
assert "Reached maximum number" not in caplog.text
486487

487488

488489
@pytest.mark.usefixtures("use_tmpdir")
@@ -505,6 +506,7 @@ async def test_old_warnings_are_not_logged(realization, caplog, mocker):
505506
job_start_time = time.time() + 1 # Pretend that the job started in the future
506507
await log_warnings_from_forward_model(realization, job_start_time)
507508
assert "FutureWarning: Feature XYZ" not in caplog.text
509+
assert "Reached maximum number" not in caplog.text
508510

509511

510512
@pytest.mark.usefixtures("use_tmpdir")
@@ -535,6 +537,7 @@ async def test_long_warning_from_forward_model_is_truncated(
535537
for line in caplog.text.splitlines():
536538
if "Realization 0 step foo.0 warned" in line:
537539
assert len(line) <= 2048 + 91
540+
assert "Reached maximum number" not in caplog.text
538541

539542

540543
@pytest.mark.usefixtures("use_tmpdir")
@@ -564,6 +567,7 @@ async def test_deduplication_of_repeated_warnings_from_forward_model(
564567
in caplog.text
565568
)
566569
assert caplog.text.count(emitted_warning_str) == 1
570+
assert "Reached maximum number" not in caplog.text
567571

568572

569573
@pytest.mark.filterwarnings("ignore:FutureWarning")
@@ -591,6 +595,7 @@ async def test_excessive_warnings_from_fm_step_can_be_capped(
591595
realization, start_time - 1, max_logged_warnings=log_count_cap
592596
)
593597
assert caplog.text.count("FutureWarning") == max(0, log_count_cap)
598+
assert "Reached maximum number" in caplog.text
594599

595600

596601
async def test_log_warnings_from_forward_model_can_detect_files_being_created_after_delay( # noqa: E501

0 commit comments

Comments
 (0)