Skip to content

Migrate surfaces over to binary format#12840

Open
jonathan-eq wants to merge 4 commits intoequinor:mainfrom
jonathan-eq:surface-warning
Open

Migrate surfaces over to binary format#12840
jonathan-eq wants to merge 4 commits intoequinor:mainfrom
jonathan-eq:surface-warning

Conversation

@jonathan-eq
Copy link
Contributor

@jonathan-eq jonathan-eq commented Feb 11, 2026

Issue
Resolves #12824

Approach
Before this commit, surfaces are read by ert in ascii format. This commit changes the default to be binary, with the option to override by setting SURFACE .... FORMAT:ASCII in config. This will retain the SURFACE old behavior.

(Screenshot of new behavior in GUI if applicable)

  • 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: Add backport label to latest release (format: 'backport release-branch-name')

@jonathan-eq jonathan-eq added the release-notes:user-impact Automatically categorise as breaking for people using CLI/GUI label Feb 11, 2026
@jonathan-eq jonathan-eq self-assigned this Feb 11, 2026
@jonathan-eq jonathan-eq force-pushed the surface-warning branch 2 times, most recently from 0c2cb0c to 475a8c6 Compare February 11, 2026 09:11
@codecov-commenter
Copy link

codecov-commenter commented Feb 11, 2026

Codecov Report

❌ Patch coverage is 91.66667% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 90.11%. Comparing base (a64ca23) to head (1a079ec).
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
src/ert/config/surface_config.py 91.66% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #12840      +/-   ##
==========================================
- Coverage   90.12%   90.11%   -0.02%     
==========================================
  Files         447      447              
  Lines       30946    30967      +21     
==========================================
+ Hits        27890    27905      +15     
- Misses       3056     3062       +6     
Flag Coverage Δ
cli-tests 36.79% <62.50%> (+0.01%) ⬆️
gui-tests 67.23% <37.50%> (-0.03%) ⬇️
performance-and-unit-tests 76.79% <91.66%> (-0.01%) ⬇️
test 45.91% <20.83%> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

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

@jonathan-eq jonathan-eq force-pushed the surface-warning branch 2 times, most recently from a074e70 to 14c8ab6 Compare February 11, 2026 11:12
Comment on lines 131 to 139
file_format = SurfaceFileFormat.BINARY
try:
surf = IrapSurface.from_ascii_file(Path(base_surface))
try:
surf = IrapSurface.from_binary_file(Path(base_surface))
logger.info("Loaded surface in binary format")
except Exception:
surf = IrapSurface.from_ascii_file(Path(base_surface))
ConfigWarning.warn(ASCII_SURFACE_WARNING_MESSAGE)
file_format = SurfaceFileFormat.ASCII
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The idea here is that if you have binary on the initial validation, then you stick with the binary version when writing/reading from runpath. If you still use ascii, you get the warning, but ert will continue as before, thus not breaking any forward models that still read/write ascii surfaces

@codspeed-hq
Copy link

codspeed-hq bot commented Feb 11, 2026

Merging this PR will not alter performance

✅ 35 untouched benchmarks


Comparing jonathan-eq:surface-warning (49e32d4) with main (f684095)

Open in CodSpeed

super().__init__(msg)


ASCII_SURFACE_WARNING_MESSAGE = (
Copy link
Contributor

Choose a reason for hiding this comment

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

We should probably add something about this in the docs aswell

)


@pytest.mark.parametrize("is_ascii_surface", [True, False])
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we add a test that tests if we read ascii we also write ascii

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, added 👌



ASCII_SURFACE_WARNING_MESSAGE = (
"From this release, the default format for surfaces is changing from ASCII "
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd remove "From this release" :)
And refactor the text a bit

@xjules
Copy link
Contributor

xjules commented Feb 13, 2026

What about storage migration? ..._file_format?

Copy link
Contributor

@xjules xjules left a comment

Choose a reason for hiding this comment

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

Nice one! 🚀

ASCII_SURFACE_WARNING_MESSAGE = (
"The default format for surfaces is changing from ASCII "
"to binary, but Ert will temporarily still support ASCII surfaces. Binary "
"surfaces are recommended, as it is faster to write and read from runpath."
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's add a sentence that the forward model creating the surfaces need to be changed too to export surfaces in binary format.

@jonathan-eq
Copy link
Contributor Author

jonathan-eq commented Feb 16, 2026

Added a note section in the docs, is this enough? @frode-aarstad
image

@jonathan-eq
Copy link
Contributor Author

image

base_surface_path=base_surface,
update=update_parameter,
)
instance._file_format = file_format
Copy link
Collaborator

Choose a reason for hiding this comment

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

Dont think this will work, because when we read from storage this will never be set, as an example, if you change:

base_surface.to_file("surf.irap", fformat="irap_ascii")
to irap_ascii I would expect this setting to be: ascii, but it is binary when we go to read the file from runpath.

Copy link
Contributor

Choose a reason for hiding this comment

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

No sure I understand. Base surface creates surf.irap that is binary and we still gonna read it from runpath as binary (by default). So binary all the way.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think this needs more discussion @xjules @oyvindeide
If I set the default to ASCII, then old storages will be handled. If there is no key for file_format in parameters.json, then it will use ASCII and write file_format: ASCII to parameters.json and that will be picked up on the next reading. If there is a new field already in binary format, that will write file_format: BINARY to parameters.json, and that will also work downstream.

Comment on lines 77 to 80
@@ -59,6 +78,8 @@ class SurfaceConfig(ParameterConfig):
output_file: Path
base_surface_path: str

Copy link
Collaborator

Choose a reason for hiding this comment

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

These file names should be mentioned explicitly in the warning message.

@jonathan-eq jonathan-eq force-pushed the surface-warning branch 2 times, most recently from 20437c4 to da961a5 Compare February 18, 2026 08:47
Before this commit, surfaces are only read by ert in ascii format. This commit changes the default to be binary, but falls back to ascii if it fails. It will also emit warnings if binary reading fails.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release-notes:user-impact Automatically categorise as breaking for people using CLI/GUI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Writing surfaces in create_run_path(...) can we very slow

5 participants