fmu-sumo 2.4.9__py3-none-any.whl → 2.5.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.
@@ -1,7 +1,14 @@
1
1
  # file generated by setuptools-scm
2
2
  # don't change, don't track in version control
3
3
 
4
- __all__ = ["__version__", "__version_tuple__", "version", "version_tuple"]
4
+ __all__ = [
5
+ "__version__",
6
+ "__version_tuple__",
7
+ "version",
8
+ "version_tuple",
9
+ "__commit_id__",
10
+ "commit_id",
11
+ ]
5
12
 
6
13
  TYPE_CHECKING = False
7
14
  if TYPE_CHECKING:
@@ -9,13 +16,19 @@ if TYPE_CHECKING:
9
16
  from typing import Union
10
17
 
11
18
  VERSION_TUPLE = Tuple[Union[int, str], ...]
19
+ COMMIT_ID = Union[str, None]
12
20
  else:
13
21
  VERSION_TUPLE = object
22
+ COMMIT_ID = object
14
23
 
15
24
  version: str
16
25
  __version__: str
17
26
  __version_tuple__: VERSION_TUPLE
18
27
  version_tuple: VERSION_TUPLE
28
+ commit_id: COMMIT_ID
29
+ __commit_id__: COMMIT_ID
19
30
 
20
- __version__ = version = '2.4.9'
21
- __version_tuple__ = version_tuple = (2, 4, 9)
31
+ __version__ = version = '2.5.0'
32
+ __version_tuple__ = version_tuple = (2, 5, 0)
33
+
34
+ __commit_id__ = commit_id = None
@@ -21,7 +21,7 @@ class Child(Document):
21
21
  self._sumo = sumo
22
22
  self._blob = blob
23
23
 
24
- def __repr__(self):
24
+ def __str__(self):
25
25
  if self.stage == "case" and self.__class__.__name__ != "Case":
26
26
  return (
27
27
  f"<{self.__class__.__name__}: {self.name} {self.uuid}(uuid) "
@@ -46,7 +46,10 @@ class Child(Document):
46
46
  f"in asset {self.asset}>"
47
47
  )
48
48
  else:
49
- return super().__repr__()
49
+ return super().__str__()
50
+
51
+ def __repr__(self):
52
+ return self.__str__()
50
53
 
51
54
  @property
52
55
  def blob(self) -> BytesIO:
@@ -1,6 +1,5 @@
1
1
  """Contains class for one document"""
2
2
 
3
- import json
4
3
  import re
5
4
  from typing import Any, Dict, List, Union
6
5
 
@@ -20,14 +19,14 @@ class Document:
20
19
  self._metadata = metadata["_source"]
21
20
 
22
21
  def __str__(self):
23
- return f"{json.dumps(self.metadata, indent=4)}"
24
-
25
- def __repr__(self):
26
22
  return (
27
23
  f"<{self.__class__.__name__}: {self.name} {self.uuid}(uuid) "
28
24
  f"in asset {self.asset}>"
29
25
  )
30
26
 
27
+ def __repr__(self):
28
+ return self.__str__()
29
+
31
30
  @property
32
31
  def uuid(self):
33
32
  """Return uuid
@@ -1,6 +1,5 @@
1
1
  from __future__ import annotations
2
2
 
3
- import json
4
3
  import warnings
5
4
  from datetime import datetime
6
5
  from typing import TYPE_CHECKING, Any, Dict, List, Tuple, Union
@@ -299,14 +298,6 @@ class SearchContext:
299
298
  return
300
299
 
301
300
  def __str__(self):
302
- length = len(self)
303
- if length == 0:
304
- return "None"
305
- else:
306
- preview = [self[i].metadata for i in range(min(5, length))]
307
- return f"Data Preview:\n{json.dumps(preview, indent=4)}"
308
-
309
- def __repr__(self):
310
301
  cls = self.__class__.__name__
311
302
  length = len(self)
312
303
  if length == 0:
@@ -317,6 +308,9 @@ class SearchContext:
317
308
  else:
318
309
  return f"<{cls}: {length} objects of types {self.classes}>"
319
310
 
311
+ def __repr__(self):
312
+ return self.__str__()
313
+
320
314
  @property
321
315
  def _query(self):
322
316
  must = self._must[:]
@@ -581,6 +575,66 @@ class SearchContext:
581
575
  self._cache.clear()
582
576
  return self
583
577
 
578
+ def _ensemble_or_realization_query(self, uuid: str) -> dict:
579
+ return {
580
+ "query": {
581
+ "bool": {
582
+ "minimum_should_match": 1,
583
+ "should": [
584
+ {"term": {"fmu.ensemble.uuid.keyword": uuid}},
585
+ {"term": {"fmu.iteration.uuid.keyword": uuid}},
586
+ {"term": {"fmu.realization.uuid.keyword": uuid}},
587
+ ],
588
+ }
589
+ },
590
+ "size": 1,
591
+ "_source": {
592
+ "includes": [
593
+ "$schema",
594
+ "class",
595
+ "source",
596
+ "version",
597
+ "access",
598
+ "masterdata",
599
+ "fmu.case",
600
+ "fmu.iteration",
601
+ "fmu.ensemble",
602
+ "fmu.realization",
603
+ ],
604
+ },
605
+ }
606
+
607
+ def _patch_ensemble_or_realization(self, uuid, hits):
608
+ if len(hits) == 1:
609
+ obj = hits[0]["_source"]
610
+ if obj["fmu"]["ensemble"]["uuid"] == uuid:
611
+ obj["class"] = "ensemble"
612
+ elif obj["fmu"]["iteration"]["uuid"] == uuid:
613
+ obj["class"] = "iteration"
614
+ elif obj["fmu"]["realization"]["uuid"] == uuid:
615
+ obj["class"] = "realization"
616
+ if (
617
+ obj["class"] in ["iteration", "ensemble"]
618
+ and "realization" in obj["fmu"]
619
+ ):
620
+ del obj["fmu"]["realization"]
621
+
622
+ def _get_ensemble_or_realization(self, uuid: str) -> List[Dict]:
623
+ query = self._ensemble_or_realization_query(uuid)
624
+ res = self._sumo.post("/search", json=query)
625
+ hits = res.json()["hits"]["hits"]
626
+ self._patch_ensemble_or_realization(uuid, hits)
627
+ return hits
628
+
629
+ async def _get_ensemble_or_realization_async(
630
+ self, uuid: str
631
+ ) -> List[Dict]:
632
+ query = self._ensemble_or_realization_query(uuid)
633
+ res = await self._sumo.post_async("/search", json=query)
634
+ hits = res.json()["hits"]["hits"]
635
+ self._patch_ensemble_or_realization(uuid, hits)
636
+ return hits
637
+
584
638
  def get_object(self, uuid: str) -> objects.Document:
585
639
  """Get metadata object by uuid
586
640
 
@@ -603,7 +657,10 @@ class SearchContext:
603
657
  hits = res.json()["hits"]["hits"]
604
658
 
605
659
  if len(hits) == 0:
606
- raise Exception(f"Document not found: {uuid}")
660
+ hits = self._get_ensemble_or_realization(uuid)
661
+ if len(hits) == 0:
662
+ raise Exception(f"Document not found: {uuid}")
663
+ pass
607
664
  obj = hits[0]
608
665
  self._cache.put(uuid, obj)
609
666
 
@@ -632,7 +689,10 @@ class SearchContext:
632
689
  hits = res.json()["hits"]["hits"]
633
690
 
634
691
  if len(hits) == 0:
635
- raise Exception(f"Document not found: {uuid}")
692
+ hits = await self._get_ensemble_or_realization_async(uuid)
693
+ if len(hits) == 0:
694
+ raise Exception(f"Document not found: {uuid}")
695
+ pass
636
696
  obj = hits[0]
637
697
  self._cache.put(uuid, obj)
638
698
 
@@ -1012,6 +1072,22 @@ class SearchContext:
1012
1072
  )
1013
1073
  return objects.Realizations(self, uuids)
1014
1074
 
1075
+ @property
1076
+ def reference_realizations(self):
1077
+ """Reference realizations from current selection."""
1078
+ return self.filter(
1079
+ cls="realization",
1080
+ complex={"term": {"fmu.realization.is_reference": True}},
1081
+ )
1082
+
1083
+ @property
1084
+ async def reference_realizations_async(self):
1085
+ """Reference realizations from current selection."""
1086
+ return self.filter(
1087
+ cls="realization",
1088
+ complex={"term": {"fmu.realization.is_reference": True}},
1089
+ )
1090
+
1015
1091
  @property
1016
1092
  def template_paths(self) -> List[str]:
1017
1093
  return {obj.template_path for obj in self}
@@ -1236,24 +1312,6 @@ class SearchContext:
1236
1312
  """
1237
1313
  return await self._get_object_by_class_and_uuid_async("case", uuid)
1238
1314
 
1239
- def _iteration_query(self, uuid):
1240
- return {
1241
- "query": {"term": {"fmu.iteration.uuid.keyword": {"value": uuid}}},
1242
- "size": 1,
1243
- "_source": {
1244
- "includes": [
1245
- "$schema",
1246
- "class",
1247
- "source",
1248
- "version",
1249
- "access",
1250
- "masterdata",
1251
- "fmu.case",
1252
- "fmu.iteration",
1253
- ],
1254
- },
1255
- }
1256
-
1257
1315
  def get_iteration_by_uuid(self, uuid: str) -> objects.Iteration:
1258
1316
  """Get iteration object by uuid
1259
1317
 
@@ -1262,23 +1320,9 @@ class SearchContext:
1262
1320
 
1263
1321
  Returns: iteration object
1264
1322
  """
1265
- try:
1266
- obj = self.get_object(uuid)
1267
- assert isinstance(obj, objects.Iteration)
1268
- return obj
1269
- except Exception:
1270
- res = self._sumo.post(
1271
- "/search", json=self._iteration_query(uuid)
1272
- ).json()
1273
- hits = res["hits"]["hits"]
1274
- if len(hits) == 0:
1275
- raise Exception(f"Document not found: {uuid}")
1276
- obj = hits[0]
1277
- obj["_id"] = uuid
1278
- obj["_source"]["class"] = "iteration"
1279
- ret = self._to_sumo(obj)
1280
- self._cache.put(uuid, ret)
1281
- return ret
1323
+ obj = self.get_object(uuid)
1324
+ assert isinstance(obj, objects.Iteration)
1325
+ return obj
1282
1326
 
1283
1327
  async def get_iteration_by_uuid_async(
1284
1328
  self, uuid: str
@@ -1290,43 +1334,9 @@ class SearchContext:
1290
1334
 
1291
1335
  Returns: iteration object
1292
1336
  """
1293
- try:
1294
- obj = await self.get_object_async(uuid)
1295
- assert isinstance(obj, objects.Iteration)
1296
- return obj
1297
- except Exception:
1298
- res = (
1299
- await self._sumo.post_async(
1300
- "/search", json=self._iteration_query(uuid)
1301
- )
1302
- ).json()
1303
- hits = res["hits"]["hits"]
1304
- if len(hits) == 0:
1305
- raise Exception(f"Document not found: {uuid}")
1306
- obj = hits[0]
1307
- obj["_id"] = uuid
1308
- obj["_source"]["class"] = "iteration"
1309
- ret = self._to_sumo(obj)
1310
- self._cache.put(uuid, ret)
1311
- return ret
1312
-
1313
- def _ensemble_query(self, uuid):
1314
- return {
1315
- "query": {"term": {"fmu.ensemble.uuid.keyword": {"value": uuid}}},
1316
- "size": 1,
1317
- "_source": {
1318
- "includes": [
1319
- "$schema",
1320
- "class",
1321
- "source",
1322
- "version",
1323
- "access",
1324
- "masterdata",
1325
- "fmu.case",
1326
- "fmu.ensemble",
1327
- ],
1328
- },
1329
- }
1337
+ obj = await self.get_object_async(uuid)
1338
+ assert isinstance(obj, objects.Iteration)
1339
+ return obj
1330
1340
 
1331
1341
  def get_ensemble_by_uuid(self, uuid: str) -> objects.Ensemble:
1332
1342
  """Get ensemble object by uuid
@@ -1336,23 +1346,9 @@ class SearchContext:
1336
1346
 
1337
1347
  Returns: ensemble object
1338
1348
  """
1339
- try:
1340
- obj = self.get_object(uuid)
1341
- assert isinstance(obj, objects.Ensemble)
1342
- return obj
1343
- except Exception:
1344
- res = self._sumo.post(
1345
- "/search", json=self._ensemble_query(uuid)
1346
- ).json()
1347
- hits = res["hits"]["hits"]
1348
- if len(hits) == 0:
1349
- raise Exception(f"Document not found: {uuid}")
1350
- obj = hits[0]
1351
- obj["_id"] = uuid
1352
- obj["_source"]["class"] = "ensemble"
1353
- ret = self._to_sumo(obj)
1354
- self._cache.put(uuid, ret)
1355
- return ret
1349
+ obj = self.get_object(uuid)
1350
+ assert isinstance(obj, objects.Ensemble)
1351
+ return obj
1356
1352
 
1357
1353
  async def get_ensemble_by_uuid_async(self, uuid: str) -> objects.Ensemble:
1358
1354
  """Get ensemble object by uuid
@@ -1362,47 +1358,9 @@ class SearchContext:
1362
1358
 
1363
1359
  Returns: ensemble object
1364
1360
  """
1365
- try:
1366
- obj = await self.get_object_async(uuid)
1367
- assert isinstance(obj, objects.Ensemble)
1368
- return obj
1369
- except Exception:
1370
- res = (
1371
- await self._sumo.post_async(
1372
- "/search", json=self._ensemble_query(uuid)
1373
- )
1374
- ).json()
1375
- hits = res["hits"]["hits"]
1376
- if len(hits) == 0:
1377
- raise Exception(f"Document not found: {uuid}")
1378
- obj = hits[0]
1379
- obj["_id"] = uuid
1380
- obj["_source"]["class"] = "ensemble"
1381
- ret = self._to_sumo(obj)
1382
- self._cache.put(uuid, ret)
1383
- return ret
1384
-
1385
- def _realization_query(self, uuid) -> Dict:
1386
- return {
1387
- "query": {
1388
- "term": {"fmu.realization.uuid.keyword": {"value": uuid}}
1389
- },
1390
- "size": 1,
1391
- "_source": {
1392
- "includes": [
1393
- "$schema",
1394
- "class",
1395
- "source",
1396
- "version",
1397
- "access",
1398
- "masterdata",
1399
- "fmu.case",
1400
- "fmu.iteration",
1401
- "fmu.ensemble",
1402
- "fmu.realization",
1403
- ],
1404
- },
1405
- }
1361
+ obj = await self.get_object_async(uuid)
1362
+ assert isinstance(obj, objects.Ensemble)
1363
+ return obj
1406
1364
 
1407
1365
  def get_realization_by_uuid(self, uuid: str) -> objects.Realization:
1408
1366
  """Get realization object by uuid
@@ -1412,21 +1370,9 @@ class SearchContext:
1412
1370
 
1413
1371
  Returns: realization object
1414
1372
  """
1415
- try:
1416
- obj = self.get_object(uuid)
1417
- assert isinstance(obj, objects.Realization)
1418
- return obj
1419
- except Exception:
1420
- res = self._sumo.post(
1421
- "/search", json=self._realization_query(uuid)
1422
- ).json()
1423
- hits = res["hits"]["hits"]
1424
- if len(hits) == 0:
1425
- raise Exception(f"Document not found: {uuid}")
1426
- obj = hits[0]
1427
- obj["_id"] = uuid
1428
- obj["_source"]["class"] = "realization"
1429
- return self._to_sumo(obj)
1373
+ obj = self.get_object(uuid)
1374
+ assert isinstance(obj, objects.Realization)
1375
+ return obj
1430
1376
 
1431
1377
  async def get_realization_by_uuid_async(
1432
1378
  self, uuid: str
@@ -1438,23 +1384,9 @@ class SearchContext:
1438
1384
 
1439
1385
  Returns: realization object
1440
1386
  """
1441
- try:
1442
- obj = await self.get_object_async(uuid)
1443
- assert isinstance(obj, objects.Realization)
1444
- return obj
1445
- except Exception:
1446
- res = (
1447
- await self._sumo.post_async(
1448
- "/search", json=self._realization_query(uuid)
1449
- )
1450
- ).json()
1451
- hits = res["hits"]["hits"]
1452
- if len(hits) == 0:
1453
- raise Exception(f"Document not found: {uuid}")
1454
- obj = hits[0]
1455
- obj["_id"] = uuid
1456
- obj["_source"]["class"] = "realization"
1457
- return self._to_sumo(obj)
1387
+ obj = await self.get_object_async(uuid)
1388
+ assert isinstance(obj, objects.Realization)
1389
+ return obj
1458
1390
 
1459
1391
  def get_surface_by_uuid(self, uuid: str) -> objects.Surface:
1460
1392
  """Get surface object by uuid
@@ -1573,7 +1505,7 @@ class SearchContext:
1573
1505
  return caseuuid, classname, entityuuid, ensemblename
1574
1506
 
1575
1507
  def _verify_aggregation_operation(
1576
- self, columns, operation
1508
+ self, columns
1577
1509
  ) -> Tuple[str, str, str, str]:
1578
1510
  assert columns is None or len(columns) == 1, (
1579
1511
  "Exactly one column required for collection aggregation."
@@ -1600,7 +1532,7 @@ class SearchContext:
1600
1532
 
1601
1533
  def _aggregate(self, columns=None, operation=None) -> objects.Child:
1602
1534
  caseuuid, classname, entityuuid, ensemblename = (
1603
- self._verify_aggregation_operation(columns, operation)
1535
+ self._verify_aggregation_operation(columns)
1604
1536
  )
1605
1537
  spec = self.__prepare_aggregation_spec(
1606
1538
  caseuuid, classname, entityuuid, ensemblename, operation, columns
@@ -1623,13 +1555,11 @@ class SearchContext:
1623
1555
  return sc.visible._aggregate(columns=columns, operation=operation)
1624
1556
 
1625
1557
  async def _verify_aggregation_operation_async(
1626
- self, columns, operation
1558
+ self, columns
1627
1559
  ) -> Tuple[str, str, str, str]:
1628
- assert (
1629
- operation != "collection"
1630
- or columns is not None
1631
- and len(columns) == 1
1632
- ), "Exactly one column required for collection aggregation."
1560
+ assert columns is None or len(columns) == 1, (
1561
+ "Exactly one column required for collection aggregation."
1562
+ )
1633
1563
  sc = self if columns is None else self.filter(column=columns)
1634
1564
  query = sc.__prepare_verify_aggregation_query()
1635
1565
  sres = (await self._sumo.post_async("/search", json=query)).json()
@@ -1643,7 +1573,7 @@ class SearchContext:
1643
1573
  classname,
1644
1574
  entityuuid,
1645
1575
  ensemblename,
1646
- ) = await self._verify_aggregation_operation_async(columns, operation)
1576
+ ) = await self._verify_aggregation_operation_async(columns)
1647
1577
  spec = self.__prepare_aggregation_spec(
1648
1578
  caseuuid, classname, entityuuid, ensemblename, operation, columns
1649
1579
  )
@@ -23,13 +23,16 @@ class Ensemble(Document, SearchContext):
23
23
  )
24
24
  pass
25
25
 
26
- def __repr__(self):
26
+ def __str__(self):
27
27
  return (
28
28
  f"<{self.__class__.__name__}: {self.name} {self.uuid}(uuid) "
29
29
  f"in case {self.casename} "
30
30
  f"in asset {self.asset}>"
31
31
  )
32
32
 
33
+ def __repr__(self):
34
+ return self.__str__()
35
+
33
36
  @property
34
37
  def field(self) -> str:
35
38
  """Case field"""
@@ -74,3 +77,23 @@ class Ensemble(Document, SearchContext):
74
77
  def uuid(self) -> str:
75
78
  """FMU ensemble uuid"""
76
79
  return self.get_property("fmu.ensemble.uuid")
80
+
81
+ @property
82
+ def reference_realizations(self):
83
+ """Reference realizations in ensemble. If none, return
84
+ realizations 0 and 1, if they exist."""
85
+ sc = super().reference_realizations
86
+ if len(sc) > 0:
87
+ return sc
88
+ else:
89
+ return self.filter(realization=[0, 1]).realizations
90
+
91
+ @property
92
+ async def reference_realizations_async(self):
93
+ """Reference realizations in ensemble. If none, return
94
+ realizations 0 and 1, if they exist."""
95
+ sc = await super().reference_realizations_async
96
+ if await sc.length_async() > 0:
97
+ return sc
98
+ else:
99
+ return self.filter(realization=[0, 1]).realizations
@@ -1,6 +1,6 @@
1
1
  """Module for searchcontext for collection of ensembles."""
2
2
 
3
- from typing import Dict, List
3
+ from typing import List
4
4
 
5
5
  from ._search_context import SearchContext
6
6
 
@@ -25,42 +25,6 @@ class Ensembles(SearchContext):
25
25
  async def _maybe_prefetch_async(self, index):
26
26
  return
27
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
28
  def filter(self, **kwargs):
65
29
  sc = super().filter(**kwargs)
66
30
  uuids = sc.get_field_values("fmu.ensemble.uuid.keyword")
@@ -23,13 +23,16 @@ class Iteration(Document, SearchContext):
23
23
  )
24
24
  pass
25
25
 
26
- def __repr__(self):
26
+ def __str__(self):
27
27
  return (
28
28
  f"<{self.__class__.__name__}: {self.name} {self.uuid}(uuid) "
29
29
  f"in case {self.casename} "
30
30
  f"in asset {self.asset}>"
31
31
  )
32
32
 
33
+ def __repr__(self):
34
+ return self.__str__()
35
+
33
36
  @property
34
37
  def field(self) -> str:
35
38
  """Case field"""
@@ -74,3 +77,23 @@ class Iteration(Document, SearchContext):
74
77
  def uuid(self) -> str:
75
78
  """FMU iteration uuid"""
76
79
  return self.get_property("fmu.iteration.uuid")
80
+
81
+ @property
82
+ def reference_realizations(self):
83
+ """Reference realizations in iteration. If none, return
84
+ realizations 0 and 1, if they exist."""
85
+ sc = super().reference_realizations
86
+ if len(sc) > 0:
87
+ return sc
88
+ else:
89
+ return self.filter(realization=[0, 1]).realizations
90
+
91
+ @property
92
+ async def reference_realizations_async(self):
93
+ """Reference realizations in iteration. If none, return
94
+ realizations 0 and 1, if they exist."""
95
+ sc = await super().reference_realizations_async
96
+ if await sc.length_async() > 0:
97
+ return sc
98
+ else:
99
+ return self.filter(realization=[0, 1]).realizations
@@ -1,6 +1,6 @@
1
1
  """Module for searchcontext for collection of iterations."""
2
2
 
3
- from typing import Dict, List
3
+ from typing import List
4
4
 
5
5
  from ._search_context import SearchContext
6
6
 
@@ -25,42 +25,6 @@ class Iterations(SearchContext):
25
25
  async def _maybe_prefetch_async(self, index):
26
26
  return
27
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_iteration_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_iteration_by_uuid_async(uuid)
60
- self._cache.put(uuid, obj)
61
-
62
- return obj
63
-
64
28
  def filter(self, **kwargs):
65
29
  sc = super().filter(**kwargs)
66
30
  uuids = sc.get_field_values("fmu.iteration.uuid.keyword")
@@ -23,7 +23,7 @@ class Realization(Document, SearchContext):
23
23
  )
24
24
  pass
25
25
 
26
- def __repr__(self):
26
+ def __str__(self):
27
27
  return (
28
28
  f"<{self.__class__.__name__}: {self.realizationid} {self.uuid}(uuid) "
29
29
  f"in iteration {self.iterationname} "
@@ -31,6 +31,9 @@ class Realization(Document, SearchContext):
31
31
  f"in asset {self.asset}>"
32
32
  )
33
33
 
34
+ def __repr__(self):
35
+ return self.__str__()
36
+
34
37
  @property
35
38
  def field(self) -> str:
36
39
  """Case field"""
@@ -80,3 +83,8 @@ class Realization(Document, SearchContext):
80
83
  def realizationid(self) -> int:
81
84
  """FMU realization id"""
82
85
  return self.get_property("fmu.realization.id")
86
+
87
+ @property
88
+ def is_reference(self) -> bool:
89
+ """Check if reference realization."""
90
+ return self.get_property("fmu.realization.is_reference") is True
@@ -1,6 +1,6 @@
1
1
  """Module for searchcontext for collection of realizations."""
2
2
 
3
- from typing import Dict
3
+ from typing import List
4
4
 
5
5
  from ._search_context import SearchContext
6
6
 
@@ -17,43 +17,26 @@ class Realizations(SearchContext):
17
17
  async def _maybe_prefetch_async(self, index):
18
18
  return
19
19
 
20
- def get_object(self, uuid: str) -> Dict:
21
- """Get metadata object by uuid
22
-
23
- Args:
24
- uuid (str): uuid of metadata object
25
- select (List[str]): list of metadata fields to return
26
-
27
- Returns:
28
- Dict: a metadata object
29
- """
30
- obj = self._cache.get(uuid)
31
- if obj is None:
32
- obj = self.get_realization_by_uuid(uuid)
33
- self._cache.put(uuid, obj)
34
- pass
35
-
36
- return obj
37
-
38
- async def get_object_async(self, uuid: str) -> Dict:
39
- """Get metadata object by uuid
40
-
41
- Args:
42
- uuid (str): uuid of metadata object
43
- select (List[str]): list of metadata fields to return
44
-
45
- Returns:
46
- Dict: a metadata object
47
- """
48
-
49
- obj = self._cache.get(uuid)
50
- if obj is None:
51
- obj = await self.get_realization_by_uuid_async(uuid)
52
- self._cache.put(uuid, obj)
53
-
54
- return obj
55
-
56
20
  def filter(self, **kwargs):
57
21
  sc = super().filter(**kwargs)
58
22
  uuids = sc.get_field_values("fmu.realization.uuid.keyword")
59
23
  return Realizations(self, uuids)
24
+
25
+ @property
26
+ def classes(self) -> List[str]:
27
+ return ["realization"]
28
+
29
+ @property
30
+ async def classes_async(self) -> List[str]:
31
+ return ["realization"]
32
+
33
+ @property
34
+ def realizationids(self) -> List[int]:
35
+ return [self.get_object(uuid).realizationid for uuid in self._hits]
36
+
37
+ @property
38
+ async def realizationids_async(self) -> List[int]:
39
+ return [
40
+ (await self.get_object_async(uuid)).realizationid
41
+ for uuid in self._hits
42
+ ]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: fmu-sumo
3
- Version: 2.4.9
3
+ Version: 2.5.0
4
4
  Summary: Python package for interacting with Sumo in an FMU setting
5
5
  Author: Equinor
6
6
  License: Apache License
@@ -1,33 +1,33 @@
1
1
  fmu/__init__.py,sha256=ftS-xRPSH-vU7fIHlnZQaCTWbNvs4owJivNW65kzsIM,85
2
2
  fmu/sumo/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
3
  fmu/sumo/explorer/__init__.py,sha256=Bc1wd1lQO3HP3tsVyPbqaesf2boZwGdtookWp8lmG-k,317
4
- fmu/sumo/explorer/_version.py,sha256=dGCSOUYhmqe53xGAFck4Xc6n14wQ2gVa_23SpiLTcCg,511
4
+ fmu/sumo/explorer/_version.py,sha256=bdfCUdK0KgIdZbIExZ_otf09cMr8k-qiQbglewDXQI8,704
5
5
  fmu/sumo/explorer/cache.py,sha256=uvz8TciwBnDEwJIHa9wneC0WVWuzhUqyF3dzk4kvGNk,1037
6
6
  fmu/sumo/explorer/explorer.py,sha256=_3nUTO1E_nf6jqpivjgjKcX6rX1fx_mIG76YOM8xb-8,2931
7
7
  fmu/sumo/explorer/filters.py,sha256=_t2PmHeTY9XiBvQeEGM-BpudWUaxIfyUSdNyG70xfRU,875
8
8
  fmu/sumo/explorer/timefilter.py,sha256=AQHa18vkCz2BzH7X9GR1ypmNxfvI4gExh_jxAVYrDjc,6260
9
9
  fmu/sumo/explorer/objects/__init__.py,sha256=72G0yfWWMTXA-oZw5GMRkrWvQqAYfadjerEwsyndCzc,637
10
- fmu/sumo/explorer/objects/_child.py,sha256=RrH3W3GF5Nhje7VnhmlEwG_jhX0z6CloJgdGJJzk3po,6035
11
- fmu/sumo/explorer/objects/_document.py,sha256=uPAkNzcOk8U4LCtXthWkm7kfU9W4HYHrrqV9HERDhe8,1835
10
+ fmu/sumo/explorer/objects/_child.py,sha256=I-TVxC5JhmcuCAkj1A_dK-cUzvbQarbonX1zq59d0ZU,6088
11
+ fmu/sumo/explorer/objects/_document.py,sha256=UR607n9N33vYaTSsYQoMmJUgnmS3To_uVyRSf7Vxulo,1797
12
12
  fmu/sumo/explorer/objects/_metrics.py,sha256=WITAFAV-3VRd-AqTg0tUwWpOChW4YFfF8ffT2fvOrAo,8144
13
- fmu/sumo/explorer/objects/_search_context.py,sha256=IVojlbbUiu6VIsMaXB_aMM8mQ8JNySqI5a5RLFAeWuA,63415
13
+ fmu/sumo/explorer/objects/_search_context.py,sha256=5deY3H5tFj9zuQwKEwPSkL6XzlWuKKWpedACReUHqCc,61338
14
14
  fmu/sumo/explorer/objects/case.py,sha256=fKp7X43ETLE1RaH3rMYxZiIuduRmf0JSnJ5gRoUgNPE,3813
15
15
  fmu/sumo/explorer/objects/cases.py,sha256=i2bnvk7NWIkzbdWMs3BXU7TCqD5tH2r7pg1m1QXUj3o,561
16
16
  fmu/sumo/explorer/objects/cpgrid.py,sha256=nuRgZ6FVEOPZT1ibd-rJhlbYYZ6BuUxXZPzovcH0kVc,2548
17
17
  fmu/sumo/explorer/objects/cpgrid_property.py,sha256=PqqR05oKKKiTTG0iDO9V6TADdHY7VUsLHjai6SqahVo,2694
18
18
  fmu/sumo/explorer/objects/cube.py,sha256=6pJLDajex-mblkt9YRZxtcK1XHcRZ8mlPPqJ-yDGEbA,1948
19
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
20
+ fmu/sumo/explorer/objects/ensemble.py,sha256=MoGiXrtyVL8_cQt5vjh0rIA5bMMGRahPb284teQEqfs,2767
21
+ fmu/sumo/explorer/objects/ensembles.py,sha256=uFtnWDgk316NRM_JvD1C7PK20gDOPQVQjCygPFhe3ZE,772
22
+ fmu/sumo/explorer/objects/iteration.py,sha256=vXaH6G93pNPvufgliqRSs4fpqgNvgxa7QI0G0ucgr_U,2784
23
+ fmu/sumo/explorer/objects/iterations.py,sha256=ZRQOxPl6MpX7JV7lfvtXp8mGLHl37pl3-F9YAXYfRgc,778
24
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
25
+ fmu/sumo/explorer/objects/realization.py,sha256=HK47WyX6kwe6ZoHaGHeTWEno86Wkh9THLOtEzOt1FGE,2483
26
+ fmu/sumo/explorer/objects/realizations.py,sha256=ojyQDZNEGubRE97z7c5WHK1ZnO267jsIureNeIzouAw,1120
27
27
  fmu/sumo/explorer/objects/surface.py,sha256=zHBtjLCIfkRHBv39OeJjA9lq3puLTfTII6TndZTtxVI,1627
28
28
  fmu/sumo/explorer/objects/table.py,sha256=vLor3YTddHkDWZSMyWPQsddFNQ2_VXE_O-stmPIWIaQ,4900
29
- fmu_sumo-2.4.9.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
30
- fmu_sumo-2.4.9.dist-info/METADATA,sha256=0hr4415f1vw5gVzYpowUs5h833HlwoqAmirunQ0wSE8,14781
31
- fmu_sumo-2.4.9.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
32
- fmu_sumo-2.4.9.dist-info/top_level.txt,sha256=Z-FIY3pxn0UK2Wxi9IJ7fKoLSraaxuNGi1eokiE0ShM,4
33
- fmu_sumo-2.4.9.dist-info/RECORD,,
29
+ fmu_sumo-2.5.0.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
30
+ fmu_sumo-2.5.0.dist-info/METADATA,sha256=16cMsikSdmEshj0jSh7fz_fqtf7T-nAWBwBSvlOK_no,14781
31
+ fmu_sumo-2.5.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
32
+ fmu_sumo-2.5.0.dist-info/top_level.txt,sha256=Z-FIY3pxn0UK2Wxi9IJ7fKoLSraaxuNGi1eokiE0ShM,4
33
+ fmu_sumo-2.5.0.dist-info/RECORD,,