Skip to content

Commit

Permalink
Update to new ert.dark_storage api
Browse files Browse the repository at this point in the history
  • Loading branch information
eivindjahren committed Oct 11, 2024
1 parent 880fdec commit f318bda
Showing 1 changed file with 10 additions and 5 deletions.
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

0 comments on commit f318bda

Please sign in to comment.