-
Notifications
You must be signed in to change notification settings - Fork 138
Store optimization data using blobs #13948
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
Open
frode-aarstad
wants to merge
1
commit into
equinor:main
Choose a base branch
from
frode-aarstad:everest-data-in-blobs
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| from __future__ import annotations | ||
|
|
||
| import json | ||
| import logging | ||
| import uuid as _uuid | ||
| from pathlib import Path | ||
|
|
||
| logger = logging.getLogger(__name__) | ||
|
|
||
| info = "Move everest batch dataframes into ensemble blobs" | ||
|
|
||
| _BATCH_DATAFRAME_NAMES = ( | ||
| "batch_objectives", | ||
| "batch_constraints", | ||
| "batch_bound_constraint_violations", | ||
| "batch_input_constraint_violations", | ||
| "batch_output_constraint_violations", | ||
| "batch_objective_gradient", | ||
| "batch_constraint_gradient", | ||
| ) | ||
|
|
||
|
|
||
| def _move_batch_dataframes_into_blobs(path: Path) -> None: | ||
| ensembles_dir = path / "ensembles" | ||
| if not ensembles_dir.exists(): | ||
| return | ||
|
|
||
| for ens_dir in ensembles_dir.iterdir(): | ||
| if not ens_dir.is_dir(): | ||
| continue | ||
|
|
||
| for dataframe_name in _BATCH_DATAFRAME_NAMES: | ||
| parquet_file = ens_dir / f"{dataframe_name}.parquet" | ||
| if not parquet_file.exists(): | ||
| continue | ||
|
|
||
| blob_dir = ens_dir / "blobs" | ||
| blob_dir.mkdir(parents=True, exist_ok=True) | ||
|
|
||
| data = parquet_file.read_bytes() | ||
| uri = f"{_uuid.uuid4().hex[:8]}.blob" | ||
| blob_data = { | ||
| "uri": uri, | ||
| "file_size": len(data), | ||
| "file_type": "application/parquet", | ||
| "name": dataframe_name, | ||
| "blob_info": { | ||
| "blob_type": "everest_batch_data", | ||
| "dataframe_name": dataframe_name, | ||
| }, | ||
| } | ||
|
|
||
| (blob_dir / uri).write_bytes(data) | ||
| (blob_dir / f"{uri}.json").write_text( | ||
| json.dumps(blob_data, indent=2), encoding="utf-8" | ||
| ) | ||
| parquet_file.unlink() | ||
| logger.info("Moved %s into blob %s", parquet_file, uri) | ||
|
|
||
|
|
||
| def migrate(path: Path) -> None: | ||
| _move_batch_dataframes_into_blobs(path) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm wondering here if we should have the same pattern like in ert?
Each of the update algorithm are not storing the data, but just send a dedicated event to a common broker (update_run_model) - which then internalizes the data.
Not sure how doable that is or possible at all.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should create a new issue for this