Extend darkstorage observation endpoint#13543
Draft
SAKavli wants to merge 1 commit into
Draft
Conversation
We wish to use this endpoint to query ert for wellnames. However, it currently only contains observation name, which does not necessarily contain the summary key. This change extends the endpoint to explicitly contain the summary key.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR extends the dark storage observations endpoints to include the underlying response_key (summary/response key) in the returned observation objects, enabling clients (e.g. GUI) to derive well names even when the observation name doesn’t encode the key.
Changes:
- Added
response_keyto theObservationOutJSON schema. - Populated
response_keyin both experiment-wide and per-response observation endpoints. - Included
response_keywhen constructing observation dicts from stored observation dataframes.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
src/ert/dark_storage/json_schema/observation.py |
Extends the Observation schema with a response_key field. |
src/ert/dark_storage/endpoints/observations.py |
Populates and returns response_key from stored observation datasets in both observations endpoints. |
| @dataclass | ||
| class _Observation: | ||
| name: str | ||
| response_key: list[str] |
Comment on lines
148
to
+151
| observations.append( | ||
| { | ||
| "name": obs_key[0], | ||
| "response_key": obs_df["response_key"].to_list(), |
Comment on lines
24
to
46
| @router.get( | ||
| "/experiments/{experiment_id}/observations", response_model=list[js.ObservationOut] | ||
| ) | ||
| def get_observations( | ||
| *, storage: Storage = DEFAULT_STORAGE, experiment_id: UUID | ||
| ) -> list[js.ObservationOut]: | ||
| with reraise_as_http_errors(logger, {404: "Experiment not found"}): | ||
| experiment = storage.get_experiment(experiment_id) | ||
|
|
||
| return [ | ||
| js.ObservationOut( | ||
| id=UUID(int=0), | ||
| userdata={}, | ||
| errors=observation["errors"], | ||
| values=observation["values"], | ||
| x_axis=observation["x_axis"], | ||
| east=observation["east"], | ||
| north=observation["north"], | ||
| radius=observation["radius"], | ||
| name=observation["name"], | ||
| response_key=observation["response_key"], | ||
| ) | ||
| for observation in _get_observations(experiment) |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #13543 +/- ##
==========================================
- Coverage 89.63% 89.62% -0.02%
==========================================
Files 460 460
Lines 32519 32520 +1
==========================================
- Hits 29150 29147 -3
- Misses 3369 3373 +4
Flags with carried forward coverage won't be shown. Click here to find out more.
|
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
We wish to use this endpoint to query ert for wellnames. However, it currently only contains observation name, which does not necessarily contain the summary key.
This change extends the endpoint to explicitly contain the summary key.
Issue
Resolves #13542
Approach
Short description of the approach
(Screenshot of new behavior in GUI if applicable)
git rebase -i main --exec 'just rapid-tests')When applicable