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

Update to new ert.dark_storage api #475

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,5 @@ jobs:
pytest
- name: Run black
if: ${{ matrix.python-version == '3.11'}}
uses: psf/black@stable
4 changes: 2 additions & 2 deletions tests/data/snake_oil_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,14 +207,14 @@ def to_parquet_helper(dataframe: pd.DataFrame) -> bytes:
index=["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"],
).transpose()
),
"http://127.0.0.1:5000/ensembles/3/records/WOPR:OP1": to_parquet_helper(
"http://127.0.0.1:5000/ensembles/3/records/WOPR%253AOP1": to_parquet_helper(
pd.DataFrame(
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9],
columns=[0],
index=["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"],
).transpose()
),
"http://127.0.0.1:5000/ensembles/3/records/WOPR:OP1/observations?realization_index=0": [
"http://127.0.0.1:5000/ensembles/3/records/WOPR%253AOP1/observations?realization_index=0": [
{
"x_axis": [1, 4],
"errors": [1, 1],
Expand Down
15 changes: 10 additions & 5 deletions webviz_ert/data_loader/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import io
import logging
from collections import defaultdict
from typing import Any, Dict, List, Mapping, MutableMapping, Optional, Tuple
from urllib.parse import quote
from typing import Any, List, Mapping, MutableMapping, Optional, Tuple

import pandas as pd
import requests
Expand All @@ -11,6 +12,10 @@
connection_info_map: dict = {}


def escape(s: str) -> str:
return quote(quote(s, safe=""))


def get_connection_info(project_id: Optional[str] = None) -> Mapping[str, str]:
from ert.shared.storage.connection import get_info

Expand Down Expand Up @@ -140,7 +145,7 @@ def get_ensemble_parameters(self, ensemble_id: str) -> list:
def get_record_labels(self, ensemble_id: str, name: str) -> list:
try:
return self._get(
url=f"ensembles/{ensemble_id}/records/{name}/labels"
url=f"ensembles/{ensemble_id}/records/{escape(name)}/labels"
).json()
except DataLoaderException as e:
logger.error(e)
Expand Down Expand Up @@ -168,7 +173,7 @@ def get_ensemble_parameter_data(
params = {}

resp = self._get(
url=f"ensembles/{ensemble_id}/records/{name}",
url=f"ensembles/{ensemble_id}/records/{escape(name)}",
headers={"accept": "application/x-parquet"},
params=params,
)
Expand All @@ -186,7 +191,7 @@ def get_ensemble_record_data(
) -> pd.DataFrame:
try:
resp = self._get(
url=f"ensembles/{ensemble_id}/records/{record_name}",
url=f"ensembles/{ensemble_id}/records/{escape(record_name)}",
headers={"accept": "application/x-parquet"},
)
stream = io.BytesIO(resp.content)
Expand All @@ -210,7 +215,7 @@ def get_ensemble_record_observations(
) -> List[dict]:
try:
return self._get(
url=f"ensembles/{ensemble_id}/records/{record_name}/observations",
url=f"ensembles/{ensemble_id}/records/{escape(record_name)}/observations",
# Hard coded to zero, as all realizations are connected to the same observations
params={"realization_index": 0},
).json()
Expand Down