Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Log when duration of forward model step is negative #10264

Merged
merged 1 commit into from
Mar 17, 2025

Conversation

JHolba
Copy link
Contributor

@JHolba JHolba commented Mar 11, 2025

Set negative durations to 0 in simulation status
Will also log warnings when encountering these issues.

Issue
Resolves #10150

Approach

  • PR title captures the intent of the changes, and is fitting for release notes.
  • Added appropriate release note label
  • Commit history is consistent and clean, in line with the contribution guidelines.
  • Make sure unit tests pass locally after every commit (git rebase -i main --exec 'just rapid-tests')

When applicable

  • When there are user facing changes: Updated documentation
  • New behavior or changes to existing untested code: Ensured that unit tests are added (See Ground Rules).
  • Large PR: Prepare changes in small commits for more convenient review
  • Bug fix: Add regression test for the bug
  • Bug fix: Create Backport PR to latest release

@JHolba JHolba added the release-notes:logging PR which only changes logging. label Mar 11, 2025
@JHolba JHolba self-assigned this Mar 11, 2025
Copy link

codspeed-hq bot commented Mar 11, 2025

CodSpeed Performance Report

Merging #10264 will not alter performance

Comparing JHolba:fix-negative-duration (ef6b6ac) with main (790e6a7)

Summary

✅ 25 untouched benchmarks

@JHolba JHolba marked this pull request as ready for review March 12, 2025 13:58
Comment on lines +438 to +442
logger.warning(
"Negative duration in snapshot encountered. "
f"start_time={start_time} end_time={node.data.get(ids.END_TIME)} "
f"delta={delta}"
)
Copy link
Contributor

Choose a reason for hiding this comment

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

@xjules showed me a trick in 2023, and now I am showing it to you =)

Suggested change
logger.warning(
"Negative duration in snapshot encountered. "
f"start_time={start_time} end_time={node.data.get(ids.END_TIME)} "
f"delta={delta}"
)
end_time = node.data.get(ids.END_TIME)
logger.warning(
"Negative duration in snapshot encountered. "
f"{start_time=} {end_time=} {delta=}"
)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

in this instance it is not that useful. f"{object=} gives object.__repr__ while I want object.__str__
__str__ '2025-01-01 00:00:00'
__repr__ 'datetime.datetime(2025, 1, 1, 0, 0)'

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't get why this shouldn't work @JHolba ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it works, but you get different text. I want this representation: '2025-01-01 00:00:00'.

you can try this in a repl

from datetime import datetime
start = datetime.now()
print("print using {start=}: " f"{start=}")
print("print using start={start}: " f"start={start}")

Copy link
Contributor

@jonathan-eq jonathan-eq left a comment

Choose a reason for hiding this comment

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

Very good, but let's wait for @eivindjahren

Will also log warnings when encountering these issues.
@JHolba JHolba force-pushed the fix-negative-duration branch from f4d3ce6 to ef6b6ac Compare March 17, 2025 14:18
@JHolba JHolba merged commit d2f2ca9 into equinor:main Mar 17, 2025
27 checks passed
@JHolba JHolba deleted the fix-negative-duration branch March 17, 2025 14:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release-notes:logging PR which only changes logging.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

FMTableView shows negative duration
3 participants