Skip to content

fmuobs: control package logger levels in default runs - #888

Merged
rnyb merged 2 commits into
mainfrom
fix-failing-test
Oct 8, 2026
Merged

rnyb merged 2 commits into
mainfrom
fix-failing-test

Conversation

@rnyb

@rnyb rnyb commented Oct 7, 2026 •

Copy link
Copy Markdown
Collaborator
  • Add configure_logging to set levels for fmuobs and its submodules
  • Default to WARNING so INFO/DEBUG output no longer leaks in ERT hooks
  • Keep stdout guard when verbose/debug is used with stdout output
  • Extend workflow hook test to assert INFO/DEBUG output per mode

Resolves #887
Resolves #889

@rnyb
rnyb requested a balanced review from Copilot October 7, 2026 14:04

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Quoted test parameters select the wrong assertion branch, leaving verbose/debug workflow test failures unresolved.

Review effort: Balanced
Findings: 1 Medium severity

Open (1)
What changed in this PR

Controls fmuobs logging in ERT workflow hooks, defaulting to WARNING to suppress unwanted INFO/DEBUG output.

Changes:

  • Centralizes package logger configuration.
  • Preserves the verbose/debug stdout guard.
  • Extends mode-specific workflow logging assertions.
File Description
tests/​test_fmuobs.py Adds INFO/DEBUG assertions for workflow logging modes.
src/​subscript/​fmuobs/​fmuobs.py Adds logging configuration and applies it on every invocation.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread tests/test_fmuobs.py
@rnyb
rnyb force-pushed the fix-failing-test branch from 713ab66 to bde6d52 Compare October 7, 2026 14:14
@rnyb
rnyb requested a balanced review from Copilot October 7, 2026 14:14

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Rejected stdout calls change shared logger levels before validation fails.

Review effort: Balanced
Findings: 1 Medium severity

Open (1)
Resolved since last review (1)

Comment thread src/subscript/fmuobs/fmuobs.py Outdated
@rnyb
rnyb force-pushed the fix-failing-test branch from bde6d52 to 1ebe052 Compare October 7, 2026 14:33
@rnyb
rnyb requested a balanced review from Copilot October 7, 2026 14:34

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Verbose-mode ERT log expectations conflict with the linked issue’s stated requirement and need reconciliation.

Review effort: Balanced
Findings: 1 Medium severity

Open (1)
Resolved since last review (1)

Comment thread tests/test_fmuobs.py
- Add configure_logging to set levels for fmuobs and its submodules
- Default to WARNING so INFO/DEBUG output no longer leaks in ERT hooks
- Keep stdout guard when verbose/debug is used with stdout output
- Extend workflow hook test to assert INFO/DEBUG output per mode
@rnyb
rnyb force-pushed the fix-failing-test branch from 1ebe052 to 0856399 Compare October 7, 2026 15:04
@rnyb
rnyb requested a balanced review from Copilot October 8, 2026 07:21

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The focused changes implement the intended logging behavior, with relevant test coverage and no identified blocking issues.

0 open findings

1 resolved since last review

🧠 Review effort: Balanced


Give feedback about Copilot approvals in this survey to enter a drawing for a $150 gift card.

@rnyb
rnyb requested a review from alifbe October 8, 2026 07:34
- Replace reference to history_obs_df with history_df in SEGMENT fillna
@rnyb
rnyb requested a balanced review from Copilot October 8, 2026 07:38

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Module execution leaves the converter’s own logger unconfigured, suppressing expected verbose/debug messages.

0 open findings

Previously missed (1)

In code that hasn't changed since last review

Medium severity Set module logger level for verbose and debug output

src/​subscript/​fmuobs/​fmuobs.py:309

When run via python -m subscript.fmuobs.fmuobs, logger = getLogger(__name__) creates the __main__ logger, which this list does not configure. With the default root level of WARNING, --verbose and --debug therefore suppress the converter's own INFO/DEBUG messages, although submodule messages are enabled. Restore logger.setLevel(loglevel) alongside the package logger updates to preserve module-mode logging.

🧠 Review effort: Balanced


Give feedback about Copilot approvals in this survey to enter a drawing for a $150 gift card.

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 84.30%. Comparing base (2579f6d) to head (75cda1f).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #888      +/-   ##
==========================================
+ Coverage   84.28%   84.30%   +0.01%     
==========================================
  Files          49       49              
  Lines        7530     7531       +1     
==========================================
+ Hits         6347     6349       +2     
+ Misses       1183     1182       -1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment thread tests/test_fmuobs.py
def _has_log(output: str, level: str, logger_name: str, text: str) -> bool:
"""True if some ERT log line has this logger, level and message text"""
return any(
f" - {logger_name} - " in line and f" - {level} - " in line and text in line

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it mean that the log is not printed in the same format as before in ERT log file?

Earlier it checks for this string

assert "INFO:subscript.fmuobs.parsers:Injecting include file" in ert_output

with this test, you are checking for all of these strings in the same line.

- subscript.fmuobs.parser
- INFO -
Injecting include file

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Example of new format:

2026-10-07 16:44:27,688 - subscript.fmuobs.parsers - ert_cli_simulation_thread - INFO - Injecting include file: hist_obs_wells.txt into observation file

Breaking it up makes it less sensitive to match exact order of things

The helper checks logger, level and message on the same line to assert the same thing in the new format. I also added a WARNING positive control, so the absence checks cannot pass on an empty or wrong log.

@alifbe alifbe left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@rnyb
rnyb merged commit 0ffc507 into main Oct 8, 2026
11 checks passed
@rnyb
rnyb deleted the fix-failing-test branch October 8, 2026 08:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fmuobs - fix potential bug fmuobs - Fix failing test

4 participants