fmu-sumo 2.3.8__py3-none-any.whl → 2.4.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -17,5 +17,5 @@ __version__: str
17
17
  __version_tuple__: VERSION_TUPLE
18
18
  version_tuple: VERSION_TUPLE
19
19
 
20
- __version__ = version = '2.3.8'
21
- __version_tuple__ = version_tuple = (2, 3, 8)
20
+ __version__ = version = '2.4.0'
21
+ __version_tuple__ = version_tuple = (2, 4, 0)
@@ -7,6 +7,7 @@ import httpx
7
7
  from sumo.wrapper import SumoClient
8
8
 
9
9
  from .objects._search_context import SearchContext
10
+ from .objects.cases import Cases
10
11
 
11
12
 
12
13
  class Explorer(SearchContext):
@@ -57,7 +58,8 @@ class Explorer(SearchContext):
57
58
 
58
59
  @property
59
60
  def cases(self):
60
- return self._context_for_class("case")
61
+ uuids = self._context_for_class("case").uuids
62
+ return Cases(self, uuids)
61
63
 
62
64
  def get_permissions(self, asset: Optional[str] = None):
63
65
  """Get permissions
@@ -10,6 +10,8 @@ from .cpgrid import CPGrid
10
10
  from .cpgrid_property import CPGridProperty
11
11
  from .cube import Cube
12
12
  from .dictionary import Dictionary
13
+ from .ensemble import Ensemble
14
+ from .ensembles import Ensembles
13
15
  from .iteration import Iteration
14
16
  from .iterations import Iterations
15
17
  from .polygons import Polygons
@@ -21,6 +21,33 @@ class Child(Document):
21
21
  self._sumo = sumo
22
22
  self._blob = blob
23
23
 
24
+ def __repr__(self):
25
+ if self.stage == "case" and self.__class__.__name__ != "Case":
26
+ return (
27
+ f"<{self.__class__.__name__}: {self.name} {self.uuid}(uuid) "
28
+ f"in case {self.casename} "
29
+ f"in asset {self.asset}>"
30
+ )
31
+ else:
32
+ if self.realization:
33
+ return (
34
+ f"<{self.__class__.__name__}: {self.name} {self.uuid}(uuid) "
35
+ f"in realization {self.realization} "
36
+ f"in iteration {self.iteration} "
37
+ f"in case {self.casename} "
38
+ f"in asset {self.asset}>"
39
+ )
40
+ if self.operationname:
41
+ return (
42
+ f"<{self.__class__.__name__}: {self.name} {self.uuid}(uuid) "
43
+ f"in operation {self.operationname} "
44
+ f"in iteration {self.iteration} "
45
+ f"in case {self.casename} "
46
+ f"in asset {self.asset}>"
47
+ )
48
+ else:
49
+ return super().__repr__()
50
+
24
51
  @property
25
52
  def blob(self) -> BytesIO:
26
53
  """Object blob"""
@@ -167,3 +194,13 @@ class Child(Document):
167
194
  def name(self) -> str:
168
195
  """Object data name"""
169
196
  return self.get_property("data.name")
197
+
198
+ @property
199
+ def asset(self) -> str:
200
+ """Object asset name"""
201
+ return self.get_property("access.asset.name")
202
+
203
+ @property
204
+ def operationname(self) -> str:
205
+ """Object aggregation operation name"""
206
+ return self.get_property("fmu.aggregation.operation")
@@ -1,5 +1,6 @@
1
1
  """Contains class for one document"""
2
2
 
3
+ import json
3
4
  import re
4
5
  from typing import Any, Dict, List, Union
5
6
 
@@ -18,6 +19,15 @@ class Document:
18
19
  self._uuid = metadata["_id"]
19
20
  self._metadata = metadata["_source"]
20
21
 
22
+ def __str__(self):
23
+ return f"{json.dumps(self.metadata, indent=4)}"
24
+
25
+ def __repr__(self):
26
+ return (
27
+ f"<{self.__class__.__name__}: {self.name} {self.uuid}(uuid) "
28
+ f"in asset {self.asset}>"
29
+ )
30
+
21
31
  @property
22
32
  def uuid(self):
23
33
  """Return uuid
@@ -60,3 +70,11 @@ class Document:
60
70
  @property
61
71
  def template_path(self) -> str:
62
72
  return ""
73
+
74
+ @property
75
+ def name(self) -> str:
76
+ return "Should not happen"
77
+
78
+ @property
79
+ def asset(self) -> str:
80
+ return self.get_property("access.asset.name")
@@ -1,5 +1,6 @@
1
1
  from __future__ import annotations
2
2
 
3
+ import json
3
4
  import uuid
4
5
  import warnings
5
6
  from datetime import datetime
@@ -136,7 +137,11 @@ _filterspec = {
136
137
  "relative_path": [_gen_filter_gen, "file.relative_path.keyword"],
137
138
  "tagname": [_gen_filter_gen, "data.tagname.keyword"],
138
139
  "dataformat": [_gen_filter_gen, "data.format.keyword"],
139
- "iteration": [_gen_filter_gen, "fmu.iteration.name.keyword"],
140
+ "iteration": [
141
+ _gen_filter_gen,
142
+ "fmu.iteration.name.keyword",
143
+ ], # FIXME: to be removed
144
+ "ensemble": [_gen_filter_gen, "fmu.ensemble.name.keyword"],
140
145
  "realization": [_gen_filter_gen, "fmu.realization.id"],
141
146
  "aggregation": [_gen_filter_gen, "fmu.aggregation.operation.keyword"],
142
147
  "stage": [_gen_filter_gen, "fmu.context.stage.keyword"],
@@ -150,6 +155,7 @@ _filterspec = {
150
155
  "stratigraphic": [_gen_filter_bool, "data.stratigraphic"],
151
156
  "is_observation": [_gen_filter_bool, "data.is_observation"],
152
157
  "is_prediction": [_gen_filter_bool, "data.is_prediction"],
158
+ "standard_result": [_gen_filter_gen, "data.standard_result.name.keyword"],
153
159
  "complex": [_gen_filter_complex, None],
154
160
  "has": [_gen_filter_none, None],
155
161
  }
@@ -262,6 +268,7 @@ class SearchContext:
262
268
  self._visible = visible
263
269
  self._hidden = hidden
264
270
  self._field_values = {}
271
+ self._field_values_and_counts = {}
265
272
  self._hits = None
266
273
  self._cache = LRUCache(capacity=200)
267
274
  self._length = None
@@ -270,6 +277,25 @@ class SearchContext:
270
277
  }
271
278
  return
272
279
 
280
+ def __str__(self):
281
+ length = len(self)
282
+ if length == 0:
283
+ return "None"
284
+ else:
285
+ preview = [self[i].metadata for i in range(min(5, length))]
286
+ return f"Data Preview:\n{json.dumps(preview, indent=4)}"
287
+
288
+ def __repr__(self):
289
+ cls = self.__class__.__name__
290
+ length = len(self)
291
+ if length == 0:
292
+ return f"<{cls}: {length} objects>"
293
+ else:
294
+ if len(self.classes) == 1:
295
+ return f"<{cls}: {length} objects of type {self.classes[0]}>"
296
+ else:
297
+ return f"<{cls}: {length} objects of types {self.classes}>"
298
+
273
299
  @property
274
300
  def _query(self):
275
301
  must = self._must[:]
@@ -303,7 +329,8 @@ class SearchContext:
303
329
  "table": objects.Table,
304
330
  "cpgrid": objects.CPGrid,
305
331
  "cpgrid_property": objects.CPGridProperty,
306
- "iteration": objects.Iteration,
332
+ "iteration": objects.Iteration, # FIXME: to be removed
333
+ "ensemble": objects.Ensemble,
307
334
  "realization": objects.Realization,
308
335
  }.get(cls)
309
336
  if constructor is None:
@@ -775,6 +802,23 @@ class SearchContext:
775
802
 
776
803
  return all_buckets
777
804
 
805
+ def get_field_values_and_counts(self, field: str) -> Dict[str, int]:
806
+ """Get List of unique values with occurrence counts for a given field
807
+
808
+ Arguments:
809
+ - field (str): a metadata field
810
+
811
+ Returns:
812
+ A mapping from unique values to count.
813
+ """
814
+ if field not in self._field_values_and_counts:
815
+ buckets = {
816
+ b["key"]: b["doc_count"] for b in self._get_buckets(field)
817
+ }
818
+ self._field_values_and_counts[field] = buckets
819
+
820
+ return self._field_values_and_counts[field]
821
+
778
822
  def get_field_values(self, field: str) -> List:
779
823
  """Get List of unique values for a given field
780
824
 
@@ -804,6 +848,26 @@ class SearchContext:
804
848
  """
805
849
  return self.get_field_values(field)
806
850
 
851
+ async def get_field_values_and_counts_async(
852
+ self, field: str
853
+ ) -> Dict[str, int]:
854
+ """Get List of unique values with occurrence counts for a given field
855
+
856
+ Arguments:
857
+ - field (str): a metadata field
858
+
859
+ Returns:
860
+ A mapping from unique values to count.
861
+ """
862
+ if field not in self._field_values_and_counts:
863
+ buckets = {
864
+ b["key"]: b["doc_count"]
865
+ for b in await self._get_buckets_async(field)
866
+ }
867
+ self._field_values_and_counts[field] = buckets
868
+
869
+ return self._field_values_and_counts[field]
870
+
807
871
  async def get_field_values_async(self, field: str) -> List:
808
872
  """Get List of unique values for a given field
809
873
 
@@ -886,17 +950,33 @@ class SearchContext:
886
950
  return objects.Cases(self, uuids)
887
951
 
888
952
  @property
953
+ @deprecation.deprecated(details="Use the method 'ensembles' instead.")
889
954
  def iterations(self):
890
955
  """Iterations from current selection."""
891
956
  uuids = self.get_field_values("fmu.iteration.uuid.keyword")
892
957
  return objects.Iterations(self, uuids)
893
958
 
894
959
  @property
960
+ @deprecation.deprecated(
961
+ details="Use the method 'ensembles_async' instead."
962
+ )
895
963
  async def iterations_async(self):
896
964
  """Iterations from current selection."""
897
965
  uuids = await self.get_field_values_async("fmu.iteration.uuid.keyword")
898
966
  return objects.Iterations(self, uuids)
899
967
 
968
+ @property
969
+ def ensembles(self):
970
+ """Ensembles from current selection."""
971
+ uuids = self.get_field_values("fmu.ensemble.uuid.keyword")
972
+ return objects.Ensembles(self, uuids)
973
+
974
+ @property
975
+ async def ensembles_async(self):
976
+ """Ensembles from current selection."""
977
+ uuids = await self.get_field_values_async("fmu.ensemble.uuid.keyword")
978
+ return objects.Ensembles(self, uuids)
979
+
900
980
  @property
901
981
  def realizations(self):
902
982
  """Realizations from current selection."""
@@ -1135,7 +1215,9 @@ class SearchContext:
1135
1215
  obj = hits[0]
1136
1216
  obj["_id"] = uuid
1137
1217
  obj["_source"]["class"] = "iteration"
1138
- return self._to_sumo(obj)
1218
+ ret = self._to_sumo(obj)
1219
+ self._cache.put(uuid, ret)
1220
+ return ret
1139
1221
 
1140
1222
  async def get_iteration_by_uuid_async(
1141
1223
  self, uuid: str
@@ -1163,7 +1245,81 @@ class SearchContext:
1163
1245
  obj = hits[0]
1164
1246
  obj["_id"] = uuid
1165
1247
  obj["_source"]["class"] = "iteration"
1166
- return self._to_sumo(obj)
1248
+ ret = self._to_sumo(obj)
1249
+ self._cache.put(uuid, ret)
1250
+ return ret
1251
+
1252
+ def _ensemble_query(self, uuid):
1253
+ return {
1254
+ "query": {"term": {"fmu.ensemble.uuid.keyword": {"value": uuid}}},
1255
+ "size": 1,
1256
+ "_source": {
1257
+ "includes": [
1258
+ "$schema",
1259
+ "class",
1260
+ "source",
1261
+ "version",
1262
+ "access",
1263
+ "masterdata",
1264
+ "fmu.case",
1265
+ "fmu.ensemble",
1266
+ ],
1267
+ },
1268
+ }
1269
+
1270
+ def get_ensemble_by_uuid(self, uuid: str) -> objects.Ensemble:
1271
+ """Get ensemble object by uuid
1272
+
1273
+ Args:
1274
+ uuid (str): ensemble uuid
1275
+
1276
+ Returns: ensemble object
1277
+ """
1278
+ try:
1279
+ obj = self.get_object(uuid)
1280
+ assert isinstance(obj, objects.Ensemble)
1281
+ return obj
1282
+ except Exception:
1283
+ res = self._sumo.post(
1284
+ "/search", json=self._ensemble_query(uuid)
1285
+ ).json()
1286
+ hits = res["hits"]["hits"]
1287
+ if len(hits) == 0:
1288
+ raise Exception(f"Document not found: {uuid}")
1289
+ obj = hits[0]
1290
+ obj["_id"] = uuid
1291
+ obj["_source"]["class"] = "ensemble"
1292
+ ret = self._to_sumo(obj)
1293
+ self._cache.put(uuid, ret)
1294
+ return ret
1295
+
1296
+ async def get_ensemble_by_uuid_async(self, uuid: str) -> objects.Ensemble:
1297
+ """Get ensemble object by uuid
1298
+
1299
+ Args:
1300
+ uuid (str): ensemble uuid
1301
+
1302
+ Returns: ensemble object
1303
+ """
1304
+ try:
1305
+ obj = await self.get_object_async(uuid)
1306
+ assert isinstance(obj, objects.Ensemble)
1307
+ return obj
1308
+ except Exception:
1309
+ res = (
1310
+ await self._sumo.post_async(
1311
+ "/search", json=self._ensemble_query(uuid)
1312
+ )
1313
+ ).json()
1314
+ hits = res["hits"]["hits"]
1315
+ if len(hits) == 0:
1316
+ raise Exception(f"Document not found: {uuid}")
1317
+ obj = hits[0]
1318
+ obj["_id"] = uuid
1319
+ obj["_source"]["class"] = "ensemble"
1320
+ ret = self._to_sumo(obj)
1321
+ self._cache.put(uuid, ret)
1322
+ return ret
1167
1323
 
1168
1324
  def _realization_query(self, uuid) -> Dict:
1169
1325
  return {
@@ -1181,6 +1337,7 @@ class SearchContext:
1181
1337
  "masterdata",
1182
1338
  "fmu.case",
1183
1339
  "fmu.iteration",
1340
+ "fmu.ensemble",
1184
1341
  "fmu.realization",
1185
1342
  ],
1186
1343
  },
@@ -1316,7 +1473,7 @@ class SearchContext:
1316
1473
  for k in [
1317
1474
  "fmu.case.uuid",
1318
1475
  "class",
1319
- "fmu.iteration.name",
1476
+ "fmu.ensemble.name",
1320
1477
  "data.name",
1321
1478
  "data.tagname",
1322
1479
  "data.content",
@@ -1364,9 +1521,8 @@ class SearchContext:
1364
1521
  del prototype["_source"]["fmu"]["realization"]
1365
1522
  del prototype["_source"]["_sumo"]
1366
1523
  del prototype["_source"]["file"]
1367
- del prototype["_source"]["access"]
1368
1524
  if "context" in prototype["_source"]["fmu"]:
1369
- prototype["_source"]["fmu"]["context"]["stage"] = "iteration"
1525
+ prototype["_source"]["fmu"]["context"]["stage"] = "ensemble"
1370
1526
  pass
1371
1527
  prototype["_source"]["fmu"]["aggregation"] = {
1372
1528
  "id": str(uuid.uuid4()),
@@ -1418,7 +1574,7 @@ class SearchContext:
1418
1574
  for k in [
1419
1575
  "fmu.case.uuid",
1420
1576
  "class",
1421
- "fmu.iteration.name",
1577
+ "fmu.ensemble.name",
1422
1578
  "data.name",
1423
1579
  "data.tagname",
1424
1580
  "data.content",
@@ -1472,9 +1628,8 @@ class SearchContext:
1472
1628
  del prototype["_source"]["fmu"]["realization"]
1473
1629
  del prototype["_source"]["_sumo"]
1474
1630
  del prototype["_source"]["file"]
1475
- del prototype["_source"]["access"]
1476
1631
  if "context" in prototype["_source"]["fmu"]:
1477
- prototype["_source"]["fmu"]["context"]["stage"] = "iteration"
1632
+ prototype["_source"]["fmu"]["context"]["stage"] = "ensemble"
1478
1633
  pass
1479
1634
  prototype["_source"]["fmu"]["aggregation"] = {
1480
1635
  "id": str(uuid.uuid4()),
@@ -1751,6 +1906,28 @@ class SearchContext:
1751
1906
  """List of unique object names."""
1752
1907
  return await self.get_field_values_async("data.name.keyword")
1753
1908
 
1909
+ @property
1910
+ def classes(self) -> List[str]:
1911
+ """List of class names."""
1912
+ return self.get_field_values("class.keyword")
1913
+
1914
+ @property
1915
+ async def classes_async(self) -> List[str]:
1916
+ """List of class names."""
1917
+ return await self.get_field_values_async("class.keyword")
1918
+
1919
+ @property
1920
+ def standard_results(self) -> List[str]:
1921
+ """List of standard result names."""
1922
+ return self.get_field_values("data.standard_result.name.keyword")
1923
+
1924
+ @property
1925
+ async def standard_results_async(self) -> List[str]:
1926
+ """List of standard result names."""
1927
+ return await self.get_field_values_async(
1928
+ "data.standard_result.name.keyword"
1929
+ )
1930
+
1754
1931
 
1755
1932
  def _gen_filter_doc(spec):
1756
1933
  fmap = {
@@ -1805,7 +1982,7 @@ Examples:
1805
1982
  Match one value::
1806
1983
 
1807
1984
  surfs = case.surfaces.filter(
1808
- iteration="iter-0",
1985
+ ensemble="iter-0",
1809
1986
  name="my_surface_name"
1810
1987
  )
1811
1988
 
@@ -17,5 +17,5 @@ class Cases(SearchContext):
17
17
 
18
18
  def filter(self, **kwargs):
19
19
  sc = super().filter(**kwargs)
20
- uuids = sc.uuids
21
- return Cases(self, uuids)
20
+ uuids = sc.get_field_values("fmu.case.uuid.keyword")
21
+ return Cases(sc, uuids)
@@ -0,0 +1,76 @@
1
+ """Module for (pseudo) ensemble class."""
2
+
3
+ from typing import Dict, Optional
4
+
5
+ from sumo.wrapper import SumoClient
6
+
7
+ from ._document import Document
8
+ from ._search_context import SearchContext
9
+
10
+
11
+ class Ensemble(Document, SearchContext):
12
+ """Class for representing an ensemble in Sumo."""
13
+
14
+ def __init__(
15
+ self, sumo: SumoClient, metadata: Dict, blob: Optional[bytes] = None
16
+ ):
17
+ assert blob is None
18
+ Document.__init__(self, metadata)
19
+ SearchContext.__init__(
20
+ self,
21
+ sumo,
22
+ must=[{"term": {"fmu.ensemble.uuid.keyword": self.uuid}}],
23
+ )
24
+ pass
25
+
26
+ def __repr__(self):
27
+ return (
28
+ f"<{self.__class__.__name__}: {self.name} {self.uuid}(uuid) "
29
+ f"in case {self.casename} "
30
+ f"in asset {self.asset}>"
31
+ )
32
+
33
+ @property
34
+ def field(self) -> str:
35
+ """Case field"""
36
+ return self.get_property("masterdata.smda.field[0].identifier")
37
+
38
+ @property
39
+ def asset(self) -> str:
40
+ """Case asset"""
41
+ return self.get_property("access.asset.name")
42
+
43
+ @property
44
+ def user(self) -> str:
45
+ """Name of user who uploaded ensemble."""
46
+ return self.get_property("fmu.case.user.id")
47
+
48
+ @property
49
+ def caseuuid(self) -> str:
50
+ """FMU case uuid"""
51
+ return self.get_property("fmu.case.uuid")
52
+
53
+ @property
54
+ def casename(self) -> str:
55
+ """FMU case name"""
56
+ return self.get_property("fmu.case.name")
57
+
58
+ @property
59
+ def ensembleuuid(self) -> str:
60
+ """FMU ensemble uuid"""
61
+ return self.get_property("fmu.ensemble.uuid")
62
+
63
+ @property
64
+ def ensemblename(self) -> str:
65
+ """FMU ensemble name"""
66
+ return self.get_property("fmu.ensemble.name")
67
+
68
+ @property
69
+ def name(self) -> str:
70
+ """FMU ensemble name"""
71
+ return self.get_property("fmu.ensemble.name")
72
+
73
+ @property
74
+ def uuid(self) -> str:
75
+ """FMU ensemble uuid"""
76
+ return self.get_property("fmu.ensemble.uuid")
@@ -0,0 +1,67 @@
1
+ """Module for searchcontext for collection of ensembles."""
2
+
3
+ from typing import Dict, List
4
+
5
+ from ._search_context import SearchContext
6
+
7
+
8
+ class Ensembles(SearchContext):
9
+ def __init__(self, sc, uuids):
10
+ super().__init__(sc._sumo, must=[{"ids": {"values": uuids}}])
11
+ self._hits = uuids
12
+ return
13
+
14
+ @property
15
+ def classes(self) -> List[str]:
16
+ return ["ensemble"]
17
+
18
+ @property
19
+ async def classes_async(self) -> List[str]:
20
+ return ["ensemble"]
21
+
22
+ def _maybe_prefetch(self, index):
23
+ return
24
+
25
+ async def _maybe_prefetch_async(self, index):
26
+ return
27
+
28
+ def get_object(self, uuid: str) -> Dict:
29
+ """Get metadata object by uuid
30
+
31
+ Args:
32
+ uuid (str): uuid of metadata object
33
+ select (List[str]): list of metadata fields to return
34
+
35
+ Returns:
36
+ Dict: a metadata object
37
+ """
38
+ obj = self._cache.get(uuid)
39
+ if obj is None:
40
+ obj = self.get_ensemble_by_uuid(uuid)
41
+ self._cache.put(uuid, obj)
42
+ pass
43
+
44
+ return obj
45
+
46
+ async def get_object_async(self, uuid: str) -> Dict:
47
+ """Get metadata object by uuid
48
+
49
+ Args:
50
+ uuid (str): uuid of metadata object
51
+ select (List[str]): list of metadata fields to return
52
+
53
+ Returns:
54
+ Dict: a metadata object
55
+ """
56
+
57
+ obj = self._cache.get(uuid)
58
+ if obj is None:
59
+ obj = await self.get_ensemble_by_uuid_async(uuid)
60
+ self._cache.put(uuid, obj)
61
+
62
+ return obj
63
+
64
+ def filter(self, **kwargs):
65
+ sc = super().filter(**kwargs)
66
+ uuids = sc.get_field_values("fmu.ensemble.uuid.keyword")
67
+ return Ensembles(sc, uuids)
@@ -23,6 +23,13 @@ class Iteration(Document, SearchContext):
23
23
  )
24
24
  pass
25
25
 
26
+ def __repr__(self):
27
+ return (
28
+ f"<{self.__class__.__name__}: {self.name} {self.uuid}(uuid) "
29
+ f"in case {self.casename} "
30
+ f"in asset {self.asset}>"
31
+ )
32
+
26
33
  @property
27
34
  def field(self) -> str:
28
35
  """Case field"""
@@ -62,3 +69,8 @@ class Iteration(Document, SearchContext):
62
69
  def name(self) -> str:
63
70
  """FMU iteration name"""
64
71
  return self.get_property("fmu.iteration.name")
72
+
73
+ @property
74
+ def uuid(self) -> str:
75
+ """FMU iteration uuid"""
76
+ return self.get_property("fmu.iteration.uuid")
@@ -1,6 +1,6 @@
1
1
  """Module for searchcontext for collection of iterations."""
2
2
 
3
- from typing import Dict
3
+ from typing import Dict, List
4
4
 
5
5
  from ._search_context import SearchContext
6
6
 
@@ -11,6 +11,14 @@ class Iterations(SearchContext):
11
11
  self._hits = uuids
12
12
  return
13
13
 
14
+ @property
15
+ def classes(self) -> List[str]:
16
+ return ["iteration"]
17
+
18
+ @property
19
+ async def classes_async(self) -> List[str]:
20
+ return ["iteration"]
21
+
14
22
  def _maybe_prefetch(self, index):
15
23
  return
16
24
 
@@ -55,5 +63,5 @@ class Iterations(SearchContext):
55
63
 
56
64
  def filter(self, **kwargs):
57
65
  sc = super().filter(**kwargs)
58
- uuids = sc.uuids
59
- return Iterations(self, uuids)
66
+ uuids = sc.get_field_values("fmu.iteration.uuid.keyword")
67
+ return Iterations(sc, uuids)
@@ -23,6 +23,14 @@ class Realization(Document, SearchContext):
23
23
  )
24
24
  pass
25
25
 
26
+ def __repr__(self):
27
+ return (
28
+ f"<{self.__class__.__name__}: {self.realizationid} {self.uuid}(uuid) "
29
+ f"in iteration {self.iterationname} "
30
+ f"in case {self.casename} "
31
+ f"in asset {self.asset}>"
32
+ )
33
+
26
34
  @property
27
35
  def field(self) -> str:
28
36
  """Case field"""
@@ -72,8 +80,3 @@ class Realization(Document, SearchContext):
72
80
  def realizationid(self) -> int:
73
81
  """FMU realization id"""
74
82
  return self.get_property("fmu.realization.id")
75
-
76
- @property
77
- def name(self) -> str:
78
- """FMU realization name"""
79
- return self.get_property("fmu.realization.name")
@@ -55,5 +55,5 @@ class Realizations(SearchContext):
55
55
 
56
56
  def filter(self, **kwargs):
57
57
  sc = super().filter(**kwargs)
58
- uuids = sc.uuids
58
+ uuids = sc.get_field_values("fmu.realization.uuid.keyword")
59
59
  return Realizations(self, uuids)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: fmu-sumo
3
- Version: 2.3.8
3
+ Version: 2.4.0
4
4
  Summary: Python package for interacting with Sumo in an FMU setting
5
5
  Author: Equinor
6
6
  License: Apache License
@@ -0,0 +1,33 @@
1
+ fmu/__init__.py,sha256=ftS-xRPSH-vU7fIHlnZQaCTWbNvs4owJivNW65kzsIM,85
2
+ fmu/sumo/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
+ fmu/sumo/explorer/__init__.py,sha256=Bc1wd1lQO3HP3tsVyPbqaesf2boZwGdtookWp8lmG-k,317
4
+ fmu/sumo/explorer/_version.py,sha256=KyHVhKcn4Ob8_JP09Buz8x5uB4b7RJZLl3FBlZ8sWSY,511
5
+ fmu/sumo/explorer/cache.py,sha256=uvz8TciwBnDEwJIHa9wneC0WVWuzhUqyF3dzk4kvGNk,1037
6
+ fmu/sumo/explorer/explorer.py,sha256=_3nUTO1E_nf6jqpivjgjKcX6rX1fx_mIG76YOM8xb-8,2931
7
+ fmu/sumo/explorer/filters.py,sha256=_t2PmHeTY9XiBvQeEGM-BpudWUaxIfyUSdNyG70xfRU,875
8
+ fmu/sumo/explorer/timefilter.py,sha256=AQHa18vkCz2BzH7X9GR1ypmNxfvI4gExh_jxAVYrDjc,6260
9
+ fmu/sumo/explorer/objects/__init__.py,sha256=72G0yfWWMTXA-oZw5GMRkrWvQqAYfadjerEwsyndCzc,637
10
+ fmu/sumo/explorer/objects/_child.py,sha256=Cq2jmjRjJDjh0hwy_lKWhPdvkuoMqx6UoHFIcmAJ7OA,5905
11
+ fmu/sumo/explorer/objects/_document.py,sha256=uPAkNzcOk8U4LCtXthWkm7kfU9W4HYHrrqV9HERDhe8,1835
12
+ fmu/sumo/explorer/objects/_metrics.py,sha256=q6CSeCjiN1SjNx4G32Lod7Slnflsu3aoJIpwm_VMIhQ,3954
13
+ fmu/sumo/explorer/objects/_search_context.py,sha256=qCejfIAnLNgGHhqvkhKK8T1JlK9GhV3rMqHpZXGz5z4,62554
14
+ fmu/sumo/explorer/objects/case.py,sha256=fKp7X43ETLE1RaH3rMYxZiIuduRmf0JSnJ5gRoUgNPE,3813
15
+ fmu/sumo/explorer/objects/cases.py,sha256=i2bnvk7NWIkzbdWMs3BXU7TCqD5tH2r7pg1m1QXUj3o,561
16
+ fmu/sumo/explorer/objects/cpgrid.py,sha256=nuRgZ6FVEOPZT1ibd-rJhlbYYZ6BuUxXZPzovcH0kVc,2548
17
+ fmu/sumo/explorer/objects/cpgrid_property.py,sha256=PqqR05oKKKiTTG0iDO9V6TADdHY7VUsLHjai6SqahVo,2694
18
+ fmu/sumo/explorer/objects/cube.py,sha256=6pJLDajex-mblkt9YRZxtcK1XHcRZ8mlPPqJ-yDGEbA,1948
19
+ fmu/sumo/explorer/objects/dictionary.py,sha256=9Nt8Br7H4TgXO6qc46HtV1vB40LsEQb6WjWYDT-Ve0g,1191
20
+ fmu/sumo/explorer/objects/ensemble.py,sha256=PqHUKMxIyT8pMVtPjvgUNS5P3gTeDYI52CqFGB56HUA,2009
21
+ fmu/sumo/explorer/objects/ensembles.py,sha256=Z20a9Vlx-P9Z484ikL_0X_xm5pudVjghmB0tq-_smwE,1718
22
+ fmu/sumo/explorer/objects/iteration.py,sha256=ASZXjsxASEoVgbS-ZNpBNm3qKr1pPG0v7CAlFyiYOk4,2024
23
+ fmu/sumo/explorer/objects/iterations.py,sha256=VzoOQSnqVRXJDCPe9nJCWNtPyVtJEraZPTJsPwXF_j4,1726
24
+ fmu/sumo/explorer/objects/polygons.py,sha256=k5BKuXHsLxzhMR5KId6Fly4FNygTOcShFCCMXvhjWg4,1187
25
+ fmu/sumo/explorer/objects/realization.py,sha256=Th3zr_nT2I1HYHkBojOAKnf_RSIPc-TiDtW0X39eMRw,2259
26
+ fmu/sumo/explorer/objects/realizations.py,sha256=4agtQFJ5pxLyWMeIzdJbkBMc8__Md-tZOj8Un4ol22c,1562
27
+ fmu/sumo/explorer/objects/surface.py,sha256=zHBtjLCIfkRHBv39OeJjA9lq3puLTfTII6TndZTtxVI,1627
28
+ fmu/sumo/explorer/objects/table.py,sha256=vLor3YTddHkDWZSMyWPQsddFNQ2_VXE_O-stmPIWIaQ,4900
29
+ fmu_sumo-2.4.0.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
30
+ fmu_sumo-2.4.0.dist-info/METADATA,sha256=zLtURJg7mo4uO76-hOegZ91uzPE4DXzMi3iuTv4vHn0,14780
31
+ fmu_sumo-2.4.0.dist-info/WHEEL,sha256=pxyMxgL8-pra_rKaQ4drOZAegBVuX-G_4nRHjjgWbmo,91
32
+ fmu_sumo-2.4.0.dist-info/top_level.txt,sha256=Z-FIY3pxn0UK2Wxi9IJ7fKoLSraaxuNGi1eokiE0ShM,4
33
+ fmu_sumo-2.4.0.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (78.1.0)
2
+ Generator: setuptools (79.0.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -1,123 +0,0 @@
1
- """module containing class for table"""
2
-
3
- from fmu.sumo.explorer._utils import Utils
4
- from fmu.sumo.explorer.objects.case import Case
5
- from fmu.sumo.explorer.objects.table import Table
6
-
7
-
8
- class AggregatedTable:
9
- """Class for representing an aggregated table in Sumo"""
10
-
11
- def __init__(
12
- self,
13
- case: Case,
14
- name: str,
15
- tag: str,
16
- iteration: str,
17
- aggregation: str = "collection",
18
- ) -> None:
19
- """Init of aggregated table
20
-
21
- Args:
22
- case (Sumo.Case): given case object
23
- name (str): name of table
24
- tag (str): name of tag
25
- iteration (str): name of interation
26
- aggregation (str, optional): aggregation type
27
- """
28
- self._sumo = case._sumo
29
- self._utils = Utils(self._sumo)
30
- self._case = case
31
- self._name = name
32
- self._tag = tag
33
- self._iteration = iteration
34
- self._aggregation = aggregation
35
- self._parameters = None
36
- self._collection = case.tables.filter(
37
- name=name,
38
- tagname=tag,
39
- iteration=iteration,
40
- aggregation=aggregation,
41
- )
42
-
43
- @property
44
- def columns(self):
45
- """Return column names
46
-
47
- Returns:
48
- list: the column names available
49
- """
50
- return self._collection.columns
51
-
52
- @property
53
- def parameters(self):
54
- """Return parameter set for iteration
55
-
56
- Returns:
57
- dict: parameters connected to iteration
58
- """
59
- if not self._parameters:
60
- must = self._utils.build_terms(
61
- {
62
- "class.keyword": "table",
63
- "_sumo.parent_object.keyword": self._case.uuid,
64
- "data.name.keyword": self._name,
65
- "data.tagname.keyword": self._tag,
66
- "fmu.iteration.name.keyword": self._iteration,
67
- "fmu.aggregation.operation.keyword": "collection",
68
- }
69
- )
70
-
71
- query = {
72
- "size": 1,
73
- "_source": ["fmu.iteration.parameters"],
74
- "query": {"bool": {"must": must}},
75
- }
76
-
77
- res = self._sumo.post("/search", json=query)
78
- doc = res.json()["hits"]["hits"][0]
79
- self._parameters = doc["_source"]["fmu"]["iteration"]["parameters"]
80
-
81
- return self._parameters
82
-
83
- @property
84
- async def parameters_async(self):
85
- """Return parameter set for iteration
86
-
87
- Returns:
88
- dict: parameters connected to iteration
89
- """
90
- if not self._parameters:
91
- must = self._utils.build_terms(
92
- {
93
- "class.keyword": "table",
94
- "_sumo.parent_object.keyword": self._case.uuid,
95
- "data.name.keyword": self._name,
96
- "data.tagname.keyword": self._tag,
97
- "fmu.iteration.name.keyword": self._iteration,
98
- "fmu.aggregation.operation.keyword": "collection",
99
- }
100
- )
101
-
102
- query = {
103
- "size": 1,
104
- "_source": ["fmu.iteration.parameters"],
105
- "query": {"bool": {"must": must}},
106
- }
107
-
108
- res = await self._sumo.post_async("/search", json=query)
109
- doc = res.json()["hits"]["hits"][0]
110
- self._parameters = doc["_source"]["fmu"]["iteration"]["parameters"]
111
-
112
- return self._parameters
113
-
114
- def __len__(self):
115
- return len(self._collection)
116
-
117
- def __getitem__(self, column) -> Table:
118
- try:
119
- return self._collection.filter(column=column)[0]
120
- except IndexError as i_ex:
121
- raise IndexError(
122
- f"Column: '{column}' does not exist, try again"
123
- ) from i_ex
@@ -1,32 +0,0 @@
1
- fmu/__init__.py,sha256=ftS-xRPSH-vU7fIHlnZQaCTWbNvs4owJivNW65kzsIM,85
2
- fmu/sumo/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
- fmu/sumo/explorer/__init__.py,sha256=Bc1wd1lQO3HP3tsVyPbqaesf2boZwGdtookWp8lmG-k,317
4
- fmu/sumo/explorer/_version.py,sha256=3Oc3thyKkSSxKGqu1ruTNsjrUTMaCkmwZoi_w-3OL9M,511
5
- fmu/sumo/explorer/cache.py,sha256=uvz8TciwBnDEwJIHa9wneC0WVWuzhUqyF3dzk4kvGNk,1037
6
- fmu/sumo/explorer/explorer.py,sha256=pVm6hYWxXH22VslATrnWkmgVSF3OSqLDCoAA3S5FvBo,2857
7
- fmu/sumo/explorer/filters.py,sha256=_t2PmHeTY9XiBvQeEGM-BpudWUaxIfyUSdNyG70xfRU,875
8
- fmu/sumo/explorer/timefilter.py,sha256=AQHa18vkCz2BzH7X9GR1ypmNxfvI4gExh_jxAVYrDjc,6260
9
- fmu/sumo/explorer/objects/__init__.py,sha256=WKBwuUuKX7ymBU1C5GiuBBl1Taq7LJPlDe8SuZmlljk,573
10
- fmu/sumo/explorer/objects/_child.py,sha256=7w32fdRgFSK1rcpSrWJeX2aE0RniaTv0H57iatSKscc,4516
11
- fmu/sumo/explorer/objects/_document.py,sha256=ISxLRwWDO6PJRywTfFEua1_D6NgRW2PCbqifHA8ZyPo,1405
12
- fmu/sumo/explorer/objects/_metrics.py,sha256=q6CSeCjiN1SjNx4G32Lod7Slnflsu3aoJIpwm_VMIhQ,3954
13
- fmu/sumo/explorer/objects/_search_context.py,sha256=FQr79ZsLm66_1JdPEzuaqS35YWWcVL6qrOvjtgg_weM,56810
14
- fmu/sumo/explorer/objects/case.py,sha256=fKp7X43ETLE1RaH3rMYxZiIuduRmf0JSnJ5gRoUgNPE,3813
15
- fmu/sumo/explorer/objects/cases.py,sha256=_deqorrU8KjtkJAgtxOBl9Q-3_FVuxkVydul_wknerE,527
16
- fmu/sumo/explorer/objects/cpgrid.py,sha256=nuRgZ6FVEOPZT1ibd-rJhlbYYZ6BuUxXZPzovcH0kVc,2548
17
- fmu/sumo/explorer/objects/cpgrid_property.py,sha256=PqqR05oKKKiTTG0iDO9V6TADdHY7VUsLHjai6SqahVo,2694
18
- fmu/sumo/explorer/objects/cube.py,sha256=6pJLDajex-mblkt9YRZxtcK1XHcRZ8mlPPqJ-yDGEbA,1948
19
- fmu/sumo/explorer/objects/dictionary.py,sha256=9Nt8Br7H4TgXO6qc46HtV1vB40LsEQb6WjWYDT-Ve0g,1191
20
- fmu/sumo/explorer/objects/iteration.py,sha256=CqdXITmClNer_Rq7JPq4TNUwgP3X4PwKQtKDXn8yyqM,1690
21
- fmu/sumo/explorer/objects/iterations.py,sha256=trMtJiIgbTuWiVGfECtJzzwlV_Bc-ehg5ra5lz8hKtE,1509
22
- fmu/sumo/explorer/objects/polygons.py,sha256=k5BKuXHsLxzhMR5KId6Fly4FNygTOcShFCCMXvhjWg4,1187
23
- fmu/sumo/explorer/objects/realization.py,sha256=oikKdV-rCEOVAECJiEMYpfhyYupEIbQ_JcGXJ1Je9LU,2130
24
- fmu/sumo/explorer/objects/realizations.py,sha256=bez1aVgvehmOZ28IyfBv0lFWroG1ZhQ0qH2nvXnRYbQ,1519
25
- fmu/sumo/explorer/objects/surface.py,sha256=zHBtjLCIfkRHBv39OeJjA9lq3puLTfTII6TndZTtxVI,1627
26
- fmu/sumo/explorer/objects/table.py,sha256=vLor3YTddHkDWZSMyWPQsddFNQ2_VXE_O-stmPIWIaQ,4900
27
- fmu/sumo/explorer/objects/table_aggregated.py,sha256=vq2EcR36JTcQsyCeyiMgigJMDFDQfVrlTZe2LdXrDFo,3794
28
- fmu_sumo-2.3.8.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
29
- fmu_sumo-2.3.8.dist-info/METADATA,sha256=PK2TO57uD0AWODdK3b8t9revZHVOiY3UfHozF3Ou0nw,14780
30
- fmu_sumo-2.3.8.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
31
- fmu_sumo-2.3.8.dist-info/top_level.txt,sha256=Z-FIY3pxn0UK2Wxi9IJ7fKoLSraaxuNGi1eokiE0ShM,4
32
- fmu_sumo-2.3.8.dist-info/RECORD,,