equinor / equinor/ert

Revise returning empty dataframes from data_for_parameter

Open
#11,151 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
161
Forks
140
Avg merge
2d 1h
Merged PRs (30d)
138

Description

```
def data_for_parameter(ensemble: Ensemble, key: str) -> pd.DataFrame:
group, _ = _extract_parameter_group_and_key(key)
try:
df = ensemble.load_scalars(group)
except KeyError:
return pd.DataFrame()

dataframe = df.to_pandas().set_index("realization")
dataframe.columns.name = None
dataframe.index.name = "Realization"
data = dataframe.sort_index(axis=1)
if data.empty or key not in data:
return pd.DataFrame()
data = data[key].to_frame().dropna()
data.columns = pd.Index([0])
return data.astype(float)
```

Should instead propagate error up and handle it at callsite, and return an appropriate http error through dark storage which should be handled on the frontend (PlotAPI)

Contributor guide

Open the contributing guide

Research direction

Start at data_for_parameter and trace its callers to identify where empty DataFrames are currently handled. Then follow the dark storage HTTP path and the PlotAPI frontend handling. Done means the underlying error propagates to the callsite, dark storage returns an appropriate HTTP error, and PlotAPI handles that response.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
api, backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.