Skip to content

Commit 3c59974

Browse files
Bump sumo (#482)
1 parent eaba110 commit 3c59974

6 files changed

Lines changed: 186 additions & 458 deletions

File tree

backend/poetry.lock

Lines changed: 108 additions & 278 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

backend/pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ pandas = {version = "2.0.1", extras = ["performance"]}
2323
httpx = "^0.24.0"
2424
psutil = "^5.9.5"
2525
vtk = "^9.2.6"
26-
fmu-sumo = "^0.5.4"
27-
sumo-wrapper-python = "^0.4.1"
26+
fmu-sumo = "1.0.3"
27+
sumo-wrapper-python = "1.0.6"
2828

2929

3030
[tool.poetry.group.dev.dependencies]

backend/src/services/sumo_access/dev_sumo_access_test_driver.py

Lines changed: 0 additions & 120 deletions
This file was deleted.

backend/src/services/sumo_access/grid_access.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ async def get_grid_geometry(self, grid_name: str, realization: int) -> xtgeo.Gri
4040
)
4141
stream = self._sumo_client.get(f"/objects('{geometry_blob_id}')/blob")
4242
print(f"{grid_name} {realization} {geometry_blob_id} in {round(timer.lap_s(),2)}s")
43-
grid_geom = xtgeo.grid_from_file(BytesIO(stream))
43+
grid_geom = xtgeo.grid_from_file(BytesIO(stream.content))
4444

4545
return grid_geom
4646

@@ -58,7 +58,7 @@ async def get_grid_parameter(
5858
)
5959
stream = self._sumo_client.get(f"/objects('{parameter_blob_id}')/blob")
6060
print(f"{grid_name} {grid_parameter_name} {realization} {parameter_blob_id} in {round(timer.lap_s(),2)}s")
61-
grid_param = xtgeo.gridproperty_from_file(BytesIO(stream))
61+
grid_param = xtgeo.gridproperty_from_file(BytesIO(stream.content))
6262
return grid_param
6363

6464
async def grids_have_equal_nxnynz(self, grid_name: str) -> bool:

backend/src/services/sumo_access/queries/case.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,26 +5,26 @@
55

66
async def get_stratigraphic_column_identifier(sumo_client: SumoClient, case_id: str) -> str:
77
"""Get stratigraphic column identifier for a case (assuming unique for all objects)"""
8-
response = await sumo_client.get_async(
9-
"/search",
10-
query=f"_sumo.parent_object:{case_id}",
11-
size=1,
12-
select="masterdata.smda.stratigraphic_column.identifier",
13-
)
14-
15-
hits = response["hits"]["hits"]
8+
params = {
9+
"query": f"_sumo.parent_object:{case_id}",
10+
"size": 1,
11+
"select": "masterdata.smda.stratigraphic_column.identifier",
12+
}
13+
response = await sumo_client.get_async("/search", params)
14+
result = response.json()
15+
hits = result["hits"]["hits"]
1616
return hits[0]["_source"]["masterdata"]["smda"]["stratigraphic_column"]["identifier"]
1717

1818

1919
async def get_field_identifiers(sumo_client: SumoClient, case_id: str) -> List[str]:
2020
"""Get field identifiers for a case (assuming unique for all objects)"""
21-
response = await sumo_client.get_async(
22-
"/search",
23-
query=f"_sumo.parent_object:{case_id}",
24-
size=1,
25-
select="masterdata.smda.field.identifier",
26-
)
27-
28-
hits = response["hits"]["hits"]
21+
params = {
22+
"query": f"_sumo.parent_object:{case_id}",
23+
"size": 1,
24+
"select": "masterdata.smda.field.identifier",
25+
}
26+
response = await sumo_client.get_async("/search", params)
27+
result = response.json()
28+
hits = result["hits"]["hits"]
2929
fields = hits[0]["_source"]["masterdata"]["smda"]["field"]
3030
return [field["identifier"] for field in fields]

backend/src/services/sumo_access/queries/cpgrid.py

Lines changed: 58 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
async def get_grid_names(sumo_client: SumoClient, case_id: str, iteration: str) -> List[str]:
77
"""Get a list of grid names for a case and iteration"""
8-
query = {
8+
payload = {
99
"size": 0,
1010
"query": {
1111
"bool": {
@@ -25,7 +25,7 @@ async def get_grid_names(sumo_client: SumoClient, case_id: str, iteration: str)
2525
}
2626
},
2727
}
28-
response = await sumo_client.post_async("/search", json=query)
28+
response = await sumo_client.post_async("/search", json=payload)
2929

3030
result = response.json()
3131
grid_names = result.get("aggregations").get("grid_names").get("buckets")
@@ -38,7 +38,7 @@ async def get_grid_geometry_checksums(
3838
sumo_client: SumoClient, case_id: str, iteration: str, grid_name: str
3939
) -> List[str]:
4040
"""Get a list of checksums for a grid geometry in a case and iteration"""
41-
query = {
41+
payload = {
4242
"size": 0,
4343
"query": {
4444
"bool": {
@@ -59,7 +59,7 @@ async def get_grid_geometry_checksums(
5959
}
6060
},
6161
}
62-
response = sumo_client.post_async("/search", json=query)
62+
response = sumo_client.post_async("/search", json=payload)
6363

6464
result = response.json()
6565
checksums = result.get("aggregations").get("checksums").get("buckets")
@@ -75,18 +75,25 @@ async def get_grid_geometry_blob_id(
7575
grid_name: str,
7676
) -> str:
7777
"""Get the blob id for a given grid geometry in a case, iteration and realization"""
78-
response = await sumo_client.get_async(
79-
"/search",
80-
query=f"_sumo.parent_object:{case_id} AND \
81-
class.keyword:cpgrid AND \
82-
fmu.iteration.name:{iteration} AND \
83-
fmu.realization.id:{realization} AND \
84-
data.name.keyword:{grid_name}",
85-
size=1000,
86-
select="_id",
87-
)
88-
89-
hits = response["hits"]["hits"]
78+
payload = {
79+
"query": {
80+
"bool": {
81+
"must": [
82+
{"match": {"_sumo.parent_object.keyword": case_id}},
83+
{"match": {"class": "cpgrid"}},
84+
{"match": {"fmu.iteration.name": iteration}},
85+
{"match": {"fmu.realization.id": realization}},
86+
{"match": {"data.name.keyword": grid_name}},
87+
]
88+
}
89+
},
90+
"size": 1,
91+
}
92+
response = await sumo_client.post_async("/search", json=payload)
93+
94+
result = response.json()
95+
hits = result["hits"]["hits"]
96+
print(hits)
9097
if len(hits) != 1:
9198
raise ValueError(f"Expected 1 hit, got {len(hits)}")
9299
return [hit["_id"] for hit in hits][0]
@@ -101,19 +108,25 @@ async def get_grid_parameter_blob_id(
101108
parameter_name: str,
102109
) -> str:
103110
"""Get the blob id for a given grid parameter in a case, iteration and realization""" ""
104-
response = await sumo_client.get_async(
105-
"/search",
106-
query=f"_sumo.parent_object:{case_id} AND \
107-
class.keyword:cpgrid_property AND \
108-
fmu.iteration.name:{iteration} AND \
109-
fmu.realization.id:{realization} AND \
110-
data.name.keyword:{parameter_name} AND \
111-
data.tagname.keyword:{grid_name}",
112-
size=1000,
113-
select="_id",
114-
)
115-
116-
hits = response["hits"]["hits"]
111+
payload = {
112+
"query": {
113+
"bool": {
114+
"must": [
115+
{"match": {"_sumo.parent_object.keyword": case_id}},
116+
{"match": {"class": "cpgrid_property"}},
117+
{"match": {"fmu.iteration.name": iteration}},
118+
{"match": {"fmu.realization.id": realization}},
119+
{"match": {"data.name.keyword": parameter_name}},
120+
{"match": {"data.tagname.keyword": grid_name}},
121+
]
122+
}
123+
},
124+
"size": 1,
125+
}
126+
response = await sumo_client.post_async("/search", json=payload)
127+
128+
result = response.json()
129+
hits = result["hits"]["hits"]
117130

118131
if len(hits) != 1:
119132
raise ValueError(f"Expected 1 hit, got {len(hits)}")
@@ -158,18 +171,23 @@ async def get_nx_ny_nz_for_ensemble_grids(
158171
sumo_client: SumoClient, case_uuid: str, iteration: str, grid_name: str
159172
) -> List[List[int]]:
160173
"""Get a list of nxnynz for all realizations of a grid model in a case and iteration"""
174+
payload = {
175+
"query": {
176+
"bool": {
177+
"must": [
178+
{"match": {"_sumo.parent_object.keyword": case_uuid}},
179+
{"match": {"class": "cpgrid"}},
180+
{"match": {"fmu.iteration.name": iteration}},
181+
{"match": {"data.name.keyword": grid_name}},
182+
]
183+
}
184+
},
185+
"size": 1000,
186+
}
161187

162-
response = await sumo_client.get_async(
163-
"/search",
164-
query=f"_sumo.parent_object:{case_uuid} AND \
165-
class.keyword:cpgrid AND \
166-
fmu.iteration.name:{iteration} AND \
167-
data.name.keyword:{grid_name}",
168-
size=1000,
169-
select="data",
170-
)
171-
172-
hits = response["hits"]["hits"]
188+
response = await sumo_client.post_async("/search", json=payload)
189+
result = response.json()
190+
hits = result["hits"]["hits"]
173191

174192
nxnynz = []
175193
for hit in hits:

0 commit comments

Comments
 (0)