fmu-sumo 2.8.1__tar.gz → 2.9.0__tar.gz

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.
Files changed (67) hide show
  1. {fmu_sumo-2.8.1/src/fmu_sumo.egg-info → fmu_sumo-2.9.0}/PKG-INFO +1 -1
  2. {fmu_sumo-2.8.1 → fmu_sumo-2.9.0}/src/fmu/sumo/explorer/_version.py +3 -3
  3. {fmu_sumo-2.8.1 → fmu_sumo-2.9.0}/src/fmu/sumo/explorer/objects/__init__.py +0 -2
  4. {fmu_sumo-2.8.1 → fmu_sumo-2.9.0}/src/fmu/sumo/explorer/objects/_search_context.py +12 -118
  5. {fmu_sumo-2.8.1 → fmu_sumo-2.9.0}/src/fmu/sumo/explorer/objects/cases.py +13 -8
  6. fmu_sumo-2.9.0/src/fmu/sumo/explorer/objects/ensembles.py +34 -0
  7. fmu_sumo-2.9.0/src/fmu/sumo/explorer/objects/realizations.py +34 -0
  8. {fmu_sumo-2.8.1 → fmu_sumo-2.9.0/src/fmu_sumo.egg-info}/PKG-INFO +1 -1
  9. {fmu_sumo-2.8.1 → fmu_sumo-2.9.0}/src/fmu_sumo.egg-info/SOURCES.txt +0 -2
  10. fmu_sumo-2.8.1/src/fmu/sumo/explorer/objects/ensembles.py +0 -90
  11. fmu_sumo-2.8.1/src/fmu/sumo/explorer/objects/iteration.py +0 -99
  12. fmu_sumo-2.8.1/src/fmu/sumo/explorer/objects/iterations.py +0 -31
  13. fmu_sumo-2.8.1/src/fmu/sumo/explorer/objects/realizations.py +0 -96
  14. {fmu_sumo-2.8.1 → fmu_sumo-2.9.0}/.github/pull_request_template.md +0 -0
  15. {fmu_sumo-2.8.1 → fmu_sumo-2.9.0}/.github/workflows/build_docs.yaml +0 -0
  16. {fmu_sumo-2.8.1 → fmu_sumo-2.9.0}/.github/workflows/check_formatting.yml +0 -0
  17. {fmu_sumo-2.8.1 → fmu_sumo-2.9.0}/.github/workflows/publish_release.yaml +0 -0
  18. {fmu_sumo-2.8.1 → fmu_sumo-2.9.0}/.github/workflows/run_tests.yaml +0 -0
  19. {fmu_sumo-2.8.1 → fmu_sumo-2.9.0}/.gitignore +0 -0
  20. {fmu_sumo-2.8.1 → fmu_sumo-2.9.0}/.pre-commit-config.yaml +0 -0
  21. {fmu_sumo-2.8.1 → fmu_sumo-2.9.0}/.readthedocs.yml +0 -0
  22. {fmu_sumo-2.8.1 → fmu_sumo-2.9.0}/CONTRIBUTING.md +0 -0
  23. {fmu_sumo-2.8.1 → fmu_sumo-2.9.0}/LICENSE +0 -0
  24. {fmu_sumo-2.8.1 → fmu_sumo-2.9.0}/README.md +0 -0
  25. {fmu_sumo-2.8.1 → fmu_sumo-2.9.0}/SECURITY.md +0 -0
  26. {fmu_sumo-2.8.1 → fmu_sumo-2.9.0}/docs/_static/equinor-logo.png +0 -0
  27. {fmu_sumo-2.8.1 → fmu_sumo-2.9.0}/docs/_static/equinor-logo2.jpg +0 -0
  28. {fmu_sumo-2.8.1 → fmu_sumo-2.9.0}/docs/_static/equinor_logo.jpg +0 -0
  29. {fmu_sumo-2.8.1 → fmu_sumo-2.9.0}/docs/_static/equinor_logo_only.jpg +0 -0
  30. {fmu_sumo-2.8.1 → fmu_sumo-2.9.0}/docs/_templates/layout.html +0 -0
  31. {fmu_sumo-2.8.1 → fmu_sumo-2.9.0}/docs/conf.py +0 -0
  32. {fmu_sumo-2.8.1 → fmu_sumo-2.9.0}/docs/explorer.rst +0 -0
  33. {fmu_sumo-2.8.1 → fmu_sumo-2.9.0}/docs/index.rst +0 -0
  34. {fmu_sumo-2.8.1 → fmu_sumo-2.9.0}/examples/explorer.ipynb +0 -0
  35. {fmu_sumo-2.8.1 → fmu_sumo-2.9.0}/examples/explorer2.ipynb +0 -0
  36. {fmu_sumo-2.8.1 → fmu_sumo-2.9.0}/examples/grids-and-properties.ipynb +0 -0
  37. {fmu_sumo-2.8.1 → fmu_sumo-2.9.0}/examples/metrics.ipynb +0 -0
  38. {fmu_sumo-2.8.1 → fmu_sumo-2.9.0}/examples/table-aggregation.ipynb +0 -0
  39. {fmu_sumo-2.8.1 → fmu_sumo-2.9.0}/pyproject.toml +0 -0
  40. {fmu_sumo-2.8.1 → fmu_sumo-2.9.0}/setup.cfg +0 -0
  41. {fmu_sumo-2.8.1 → fmu_sumo-2.9.0}/src/fmu/__init__.py +0 -0
  42. {fmu_sumo-2.8.1 → fmu_sumo-2.9.0}/src/fmu/sumo/__init__.py +0 -0
  43. {fmu_sumo-2.8.1 → fmu_sumo-2.9.0}/src/fmu/sumo/explorer/__init__.py +0 -0
  44. {fmu_sumo-2.8.1 → fmu_sumo-2.9.0}/src/fmu/sumo/explorer/cache.py +0 -0
  45. {fmu_sumo-2.8.1 → fmu_sumo-2.9.0}/src/fmu/sumo/explorer/explorer.py +0 -0
  46. {fmu_sumo-2.8.1 → fmu_sumo-2.9.0}/src/fmu/sumo/explorer/filters.py +0 -0
  47. {fmu_sumo-2.8.1 → fmu_sumo-2.9.0}/src/fmu/sumo/explorer/objects/_child.py +0 -0
  48. {fmu_sumo-2.8.1 → fmu_sumo-2.9.0}/src/fmu/sumo/explorer/objects/_document.py +0 -0
  49. {fmu_sumo-2.8.1 → fmu_sumo-2.9.0}/src/fmu/sumo/explorer/objects/_metrics.py +0 -0
  50. {fmu_sumo-2.8.1 → fmu_sumo-2.9.0}/src/fmu/sumo/explorer/objects/case.py +0 -0
  51. {fmu_sumo-2.8.1 → fmu_sumo-2.9.0}/src/fmu/sumo/explorer/objects/cpgrid.py +0 -0
  52. {fmu_sumo-2.8.1 → fmu_sumo-2.9.0}/src/fmu/sumo/explorer/objects/cpgrid_property.py +0 -0
  53. {fmu_sumo-2.8.1 → fmu_sumo-2.9.0}/src/fmu/sumo/explorer/objects/cube.py +0 -0
  54. {fmu_sumo-2.8.1 → fmu_sumo-2.9.0}/src/fmu/sumo/explorer/objects/dictionary.py +0 -0
  55. {fmu_sumo-2.8.1 → fmu_sumo-2.9.0}/src/fmu/sumo/explorer/objects/ensemble.py +0 -0
  56. {fmu_sumo-2.8.1 → fmu_sumo-2.9.0}/src/fmu/sumo/explorer/objects/polygons.py +0 -0
  57. {fmu_sumo-2.8.1 → fmu_sumo-2.9.0}/src/fmu/sumo/explorer/objects/realization.py +0 -0
  58. {fmu_sumo-2.8.1 → fmu_sumo-2.9.0}/src/fmu/sumo/explorer/objects/surface.py +0 -0
  59. {fmu_sumo-2.8.1 → fmu_sumo-2.9.0}/src/fmu/sumo/explorer/objects/table.py +0 -0
  60. {fmu_sumo-2.8.1 → fmu_sumo-2.9.0}/src/fmu/sumo/explorer/timefilter.py +0 -0
  61. {fmu_sumo-2.8.1 → fmu_sumo-2.9.0}/src/fmu_sumo.egg-info/dependency_links.txt +0 -0
  62. {fmu_sumo-2.8.1 → fmu_sumo-2.9.0}/src/fmu_sumo.egg-info/requires.txt +0 -0
  63. {fmu_sumo-2.8.1 → fmu_sumo-2.9.0}/src/fmu_sumo.egg-info/top_level.txt +0 -0
  64. {fmu_sumo-2.8.1 → fmu_sumo-2.9.0}/tests/conftest.py +0 -0
  65. {fmu_sumo-2.8.1 → fmu_sumo-2.9.0}/tests/context.py +0 -0
  66. {fmu_sumo-2.8.1 → fmu_sumo-2.9.0}/tests/test_explorer.py +0 -0
  67. {fmu_sumo-2.8.1 → fmu_sumo-2.9.0}/tests/test_objects_table.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: fmu-sumo
3
- Version: 2.8.1
3
+ Version: 2.9.0
4
4
  Summary: Python package for interacting with Sumo in an FMU setting
5
5
  Author: Equinor
6
6
  License: Apache License
@@ -28,7 +28,7 @@ version_tuple: VERSION_TUPLE
28
28
  commit_id: COMMIT_ID
29
29
  __commit_id__: COMMIT_ID
30
30
 
31
- __version__ = version = '2.8.1'
32
- __version_tuple__ = version_tuple = (2, 8, 1)
31
+ __version__ = version = '2.9.0'
32
+ __version_tuple__ = version_tuple = (2, 9, 0)
33
33
 
34
- __commit_id__ = commit_id = 'g085fb1035'
34
+ __commit_id__ = commit_id = 'gbcff66149'
@@ -12,8 +12,6 @@ from .cube import Cube
12
12
  from .dictionary import Dictionary
13
13
  from .ensemble import Ensemble
14
14
  from .ensembles import Ensembles
15
- from .iteration import Iteration
16
- from .iterations import Iterations
17
15
  from .polygons import Polygons
18
16
  from .realization import Realization
19
17
  from .realizations import Realizations
@@ -368,7 +368,6 @@ class SearchContext:
368
368
  "table": objects.Table,
369
369
  "cpgrid": objects.CPGrid,
370
370
  "cpgrid_property": objects.CPGridProperty,
371
- "iteration": objects.Iteration, # FIXME: to be removed
372
371
  "ensemble": objects.Ensemble,
373
372
  "realization": objects.Realization,
374
373
  }.get(cls)
@@ -481,16 +480,22 @@ class SearchContext:
481
480
  query=self._query, size=1000, select=select
482
481
  )
483
482
 
483
+ def _getuuids(self):
484
+ return self._search_all()
485
+
486
+ async def _getuuids_async(self):
487
+ return await self._search_all_async()
488
+
484
489
  @property
485
490
  def uuids(self):
486
491
  if self._hits is None:
487
- self._hits = self._search_all()
492
+ self._hits = self._getuuids()
488
493
  return self._hits
489
494
 
490
495
  @property
491
496
  async def uuids_async(self):
492
497
  if self._hits is None:
493
- self._hits = await self._search_all_async()
498
+ self._hits = await self._getuuids_async()
494
499
  return self._hits
495
500
 
496
501
  def __iter__(self):
@@ -527,15 +532,17 @@ class SearchContext:
527
532
 
528
533
  def __getitem__(self, index):
529
534
  if self._hits is None:
530
- self._hits = self._search_all()
535
+ self._hits = self._getuuids()
531
536
  pass
537
+ self._maybe_prefetch(index)
532
538
  uuid = self._hits[index]
533
539
  return self.get_object(uuid)
534
540
 
535
541
  async def getitem_async(self, index):
536
542
  if self._hits is None:
537
- self._hits = await self._search_all_async()
543
+ self._hits = await self._getuuids_async()
538
544
  pass
545
+ await self._maybe_prefetch_async(index)
539
546
  uuid = self._hits[index]
540
547
  return await self.get_object_async(uuid)
541
548
 
@@ -599,66 +606,6 @@ class SearchContext:
599
606
  self._cache.clear()
600
607
  return self
601
608
 
602
- def _ensemble_or_realization_query(self, uuid: str) -> dict:
603
- return {
604
- "query": {
605
- "bool": {
606
- "minimum_should_match": 1,
607
- "should": [
608
- {"term": {"fmu.ensemble.uuid.keyword": uuid}},
609
- {"term": {"fmu.iteration.uuid.keyword": uuid}},
610
- {"term": {"fmu.realization.uuid.keyword": uuid}},
611
- ],
612
- }
613
- },
614
- "size": 1,
615
- "_source": {
616
- "includes": [
617
- "$schema",
618
- "class",
619
- "source",
620
- "version",
621
- "access",
622
- "masterdata",
623
- "fmu.case",
624
- "fmu.iteration",
625
- "fmu.ensemble",
626
- "fmu.realization",
627
- ],
628
- },
629
- }
630
-
631
- def _patch_ensemble_or_realization(self, uuid, hits):
632
- if len(hits) == 1:
633
- obj = hits[0]["_source"]
634
- if obj["fmu"]["ensemble"]["uuid"] == uuid:
635
- obj["class"] = "ensemble"
636
- elif obj["fmu"]["iteration"]["uuid"] == uuid:
637
- obj["class"] = "iteration"
638
- elif obj["fmu"]["realization"]["uuid"] == uuid:
639
- obj["class"] = "realization"
640
- if (
641
- obj["class"] in ["iteration", "ensemble"]
642
- and "realization" in obj["fmu"]
643
- ):
644
- del obj["fmu"]["realization"]
645
-
646
- def _get_ensemble_or_realization(self, uuid: str) -> List[Dict]:
647
- query = self._ensemble_or_realization_query(uuid)
648
- res = self._sumo.post("/search", json=query)
649
- hits = res.json()["hits"]["hits"]
650
- self._patch_ensemble_or_realization(uuid, hits)
651
- return hits
652
-
653
- async def _get_ensemble_or_realization_async(
654
- self, uuid: str
655
- ) -> List[Dict]:
656
- query = self._ensemble_or_realization_query(uuid)
657
- res = await self._sumo.post_async("/search", json=query)
658
- hits = res.json()["hits"]["hits"]
659
- self._patch_ensemble_or_realization(uuid, hits)
660
- return hits
661
-
662
609
  def get_object(self, uuid: str) -> objects.Document:
663
610
  """Get metadata object by uuid
664
611
 
@@ -679,12 +626,6 @@ class SearchContext:
679
626
 
680
627
  res = self._sumo.post("/search", json=query)
681
628
  hits = res.json()["hits"]["hits"]
682
-
683
- if len(hits) == 0:
684
- hits = self._get_ensemble_or_realization(uuid)
685
- if len(hits) == 0:
686
- raise Exception(f"Document not found: {uuid}")
687
- pass
688
629
  obj = hits[0]
689
630
  self._cache.put(uuid, obj)
690
631
 
@@ -712,11 +653,6 @@ class SearchContext:
712
653
  res = await self._sumo.post_async("/search", json=query)
713
654
  hits = res.json()["hits"]["hits"]
714
655
 
715
- if len(hits) == 0:
716
- hits = await self._get_ensemble_or_realization_async(uuid)
717
- if len(hits) == 0:
718
- raise Exception(f"Document not found: {uuid}")
719
- pass
720
656
  obj = hits[0]
721
657
  self._cache.put(uuid, obj)
722
658
 
@@ -1142,22 +1078,6 @@ class SearchContext:
1142
1078
  uuids = await self.get_field_values_async("fmu.case.uuid.keyword")
1143
1079
  return objects.Cases(self, uuids)
1144
1080
 
1145
- @property
1146
- @deprecation.deprecated(details="Use the method 'ensembles' instead.")
1147
- def iterations(self):
1148
- """Iterations from current selection."""
1149
- uuids = self.get_field_values("fmu.iteration.uuid.keyword")
1150
- return objects.Iterations(self, uuids)
1151
-
1152
- @property
1153
- @deprecation.deprecated(
1154
- details="Use the method 'ensembles_async' instead."
1155
- )
1156
- async def iterations_async(self):
1157
- """Iterations from current selection."""
1158
- uuids = await self.get_field_values_async("fmu.iteration.uuid.keyword")
1159
- return objects.Iterations(self, uuids)
1160
-
1161
1081
  @property
1162
1082
  def ensembles(self):
1163
1083
  """Ensembles from current selection."""
@@ -1424,32 +1344,6 @@ class SearchContext:
1424
1344
  """
1425
1345
  return await self._get_object_by_class_and_uuid_async("case", uuid)
1426
1346
 
1427
- def get_iteration_by_uuid(self, uuid: str) -> objects.Iteration:
1428
- """Get iteration object by uuid
1429
-
1430
- Args:
1431
- uuid (str): iteration uuid
1432
-
1433
- Returns: iteration object
1434
- """
1435
- obj = self.get_object(uuid)
1436
- assert isinstance(obj, objects.Iteration)
1437
- return obj
1438
-
1439
- async def get_iteration_by_uuid_async(
1440
- self, uuid: str
1441
- ) -> objects.Iteration:
1442
- """Get iteration object by uuid
1443
-
1444
- Args:
1445
- uuid (str): iteration uuid
1446
-
1447
- Returns: iteration object
1448
- """
1449
- obj = await self.get_object_async(uuid)
1450
- assert isinstance(obj, objects.Iteration)
1451
- return obj
1452
-
1453
1347
  def get_ensemble_by_uuid(self, uuid: str) -> objects.Ensemble:
1454
1348
  """Get ensemble object by uuid
1455
1349
 
@@ -1,5 +1,7 @@
1
1
  """Module for searchcontext for collection of cases."""
2
2
 
3
+ from typing import List
4
+
3
5
  from ._search_context import SearchContext
4
6
 
5
7
 
@@ -9,16 +11,19 @@ class Cases(SearchContext):
9
11
  self._hits = uuids
10
12
  return
11
13
 
12
- def _maybe_prefetch(self, index):
13
- return
14
+ def __len__(self):
15
+ return len(self.uuids)
14
16
 
15
- async def _maybe_prefetch_async(self, index):
16
- return
17
+ async def length_async(self):
18
+ return len(await self.uuids_async)
17
19
 
18
- def filter(self, **kwargs):
19
- sc = super().filter(**kwargs)
20
- uuids = sc.get_field_values("fmu.case.uuid.keyword")
21
- return Cases(sc, uuids)
20
+ @property
21
+ def classes(self) -> List[str]:
22
+ return ["case"]
23
+
24
+ @property
25
+ async def classes_async(self) -> List[str]:
26
+ return ["case"]
22
27
 
23
28
  @property
24
29
  def names(self):
@@ -0,0 +1,34 @@
1
+ """Module for searchcontext for collection of ensembles."""
2
+
3
+ from typing import 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
+ def __len__(self):
15
+ return len(self.uuids)
16
+
17
+ async def length_async(self):
18
+ return len(await self.uuids_async)
19
+
20
+ @property
21
+ def classes(self) -> List[str]:
22
+ return ["ensemble"]
23
+
24
+ @property
25
+ async def classes_async(self) -> List[str]:
26
+ return ["ensemble"]
27
+
28
+ @property
29
+ def ensemblenames(self) -> List[str]:
30
+ return self.get_field_values("fmu.ensemble.name.keyword")
31
+
32
+ @property
33
+ async def ensemblenames_async(self) -> List[str]:
34
+ return await self.get_field_values_async("fmu.ensemble.name.keyword")
@@ -0,0 +1,34 @@
1
+ """Module for searchcontext for collection of realizations."""
2
+
3
+ from typing import List
4
+
5
+ from ._search_context import SearchContext
6
+
7
+
8
+ class Realizations(SearchContext):
9
+ def __init__(self, sc, uuids):
10
+ super().__init__(sc._sumo, must=[{"ids": {"values": uuids}}])
11
+ self._hits = uuids
12
+ return
13
+
14
+ def __len__(self):
15
+ return len(self.uuids)
16
+
17
+ async def length_async(self):
18
+ return len(await self.uuids_async)
19
+
20
+ @property
21
+ def classes(self) -> List[str]:
22
+ return ["realization"]
23
+
24
+ @property
25
+ async def classes_async(self) -> List[str]:
26
+ return ["realization"]
27
+
28
+ @property
29
+ def realizationids(self) -> List[int]:
30
+ return self.get_field_values("fmu.realization.id")
31
+
32
+ @property
33
+ async def realizationids_async(self) -> List[int]:
34
+ return await self.get_field_values_async("fmu.realization.id")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: fmu-sumo
3
- Version: 2.8.1
3
+ Version: 2.9.0
4
4
  Summary: Python package for interacting with Sumo in an FMU setting
5
5
  Author: Equinor
6
6
  License: Apache License
@@ -45,8 +45,6 @@ src/fmu/sumo/explorer/objects/cube.py
45
45
  src/fmu/sumo/explorer/objects/dictionary.py
46
46
  src/fmu/sumo/explorer/objects/ensemble.py
47
47
  src/fmu/sumo/explorer/objects/ensembles.py
48
- src/fmu/sumo/explorer/objects/iteration.py
49
- src/fmu/sumo/explorer/objects/iterations.py
50
48
  src/fmu/sumo/explorer/objects/polygons.py
51
49
  src/fmu/sumo/explorer/objects/realization.py
52
50
  src/fmu/sumo/explorer/objects/realizations.py
@@ -1,90 +0,0 @@
1
- """Module for searchcontext for collection of ensembles."""
2
-
3
- from copy import deepcopy
4
- from typing import List
5
-
6
- from fmu.sumo.explorer.objects.ensemble import Ensemble
7
-
8
- from ._search_context import SearchContext
9
-
10
-
11
- class Ensembles(SearchContext):
12
- def __init__(self, sc, uuids):
13
- super().__init__(sc._sumo, must=[{"ids": {"values": uuids}}])
14
- self._hits = uuids
15
- self._prototype = None
16
- self._map = {}
17
- return
18
-
19
- def _maybe_prefetch(self, index):
20
- return
21
-
22
- async def _maybe_prefetch_async(self, index):
23
- return
24
-
25
- def filter(self, **kwargs):
26
- sc = super().filter(**kwargs)
27
- uuids = sc.get_field_values("fmu.ensemble.uuid.keyword")
28
- return Ensembles(sc, uuids)
29
-
30
- def get_object(self, uuid):
31
- if self._prototype is None:
32
- obj = super().get_object(uuid)
33
- if len(self.get_field_values("fmu.case.uuid.keyword")) > 1:
34
- return obj
35
- # ELSE
36
- self._prototype = obj.metadata
37
- buckets = self.get_composite_agg(
38
- {
39
- "uuid": "fmu.ensemble.uuid.keyword",
40
- "name": "fmu.ensemble.name.keyword",
41
- }
42
- )
43
- self._map = {b["uuid"]: b for b in buckets}
44
- pass
45
- metadata = deepcopy(self._prototype)
46
- b = self._map[uuid]
47
- metadata["fmu"]["ensemble"] = b
48
- return Ensemble(self._sumo, {"_id": uuid, "_source": metadata})
49
-
50
- async def get_object_async(self, uuid):
51
- if self._prototype is None:
52
- obj = await super().get_object_async(uuid)
53
- if (
54
- len(await self.get_field_values_async("fmu.case.uuid.keyword"))
55
- > 1
56
- ):
57
- return obj
58
- # ELSE
59
- self._prototype = obj.metadata
60
- buckets = await self.get_composite_agg_async(
61
- {
62
- "uuid": "fmu.ensemble.uuid.keyword",
63
- "name": "fmu.ensemble.name.keyword",
64
- }
65
- )
66
- self._map = {b["uuid"]: b for b in buckets}
67
- pass
68
- metadata = deepcopy(self._prototype)
69
- b = self._map[uuid]
70
- metadata["fmu"]["ensemble"] = b
71
- return Ensemble(self._sumo, {"_id": uuid, "_source": metadata})
72
-
73
- @property
74
- def classes(self) -> List[str]:
75
- return ["ensemble"]
76
-
77
- @property
78
- async def classes_async(self) -> List[str]:
79
- return ["ensemble"]
80
-
81
- @property
82
- def ensemblenames(self) -> List[str]:
83
- return [self.get_object(uuid).ensemblename for uuid in self._hits]
84
-
85
- @property
86
- async def ensemblenames_async(self) -> List[str]:
87
- return [
88
- (await self.get_object_async(uuid)).ensemblename
89
- for uuid in self._hits
90
- ]
@@ -1,99 +0,0 @@
1
- """Module for (pseudo) iteration 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 Iteration(Document, SearchContext):
12
- """Class for representing an iteration 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.iteration.uuid.keyword": self.uuid}}],
23
- )
24
- pass
25
-
26
- def __str__(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
- def __repr__(self):
34
- return self.__str__()
35
-
36
- @property
37
- def field(self) -> str:
38
- """Case field"""
39
- return self.get_property("masterdata.smda.field[0].identifier")
40
-
41
- @property
42
- def asset(self) -> str:
43
- """Case asset"""
44
- return self.get_property("access.asset.name")
45
-
46
- @property
47
- def user(self) -> str:
48
- """Name of user who uploaded iteration."""
49
- return self.get_property("fmu.case.user.id")
50
-
51
- @property
52
- def caseuuid(self) -> str:
53
- """FMU case uuid"""
54
- return self.get_property("fmu.case.uuid")
55
-
56
- @property
57
- def casename(self) -> str:
58
- """FMU case name"""
59
- return self.get_property("fmu.case.name")
60
-
61
- @property
62
- def iterationuuid(self) -> str:
63
- """FMU iteration uuid"""
64
- return self.get_property("fmu.iteration.uuid")
65
-
66
- @property
67
- def iterationname(self) -> str:
68
- """FMU iteration name"""
69
- return self.get_property("fmu.iteration.name")
70
-
71
- @property
72
- def name(self) -> str:
73
- """FMU iteration name"""
74
- return self.get_property("fmu.iteration.name")
75
-
76
- @property
77
- def uuid(self) -> str:
78
- """FMU iteration uuid"""
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,31 +0,0 @@
1
- """Module for searchcontext for collection of iterations."""
2
-
3
- from typing import List
4
-
5
- from ._search_context import SearchContext
6
-
7
-
8
- class Iterations(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 ["iteration"]
17
-
18
- @property
19
- async def classes_async(self) -> List[str]:
20
- return ["iteration"]
21
-
22
- def _maybe_prefetch(self, index):
23
- return
24
-
25
- async def _maybe_prefetch_async(self, index):
26
- return
27
-
28
- def filter(self, **kwargs):
29
- sc = super().filter(**kwargs)
30
- uuids = sc.get_field_values("fmu.iteration.uuid.keyword")
31
- return Iterations(sc, uuids)
@@ -1,96 +0,0 @@
1
- """Module for searchcontext for collection of realizations."""
2
-
3
- from copy import deepcopy
4
- from typing import List
5
-
6
- from fmu.sumo.explorer.objects.realization import Realization
7
-
8
- from ._search_context import SearchContext
9
-
10
-
11
- class Realizations(SearchContext):
12
- def __init__(self, sc, uuids):
13
- super().__init__(sc._sumo, must=[{"ids": {"values": uuids}}])
14
- self._hits = uuids
15
- self._prototype = None
16
- self._map = {}
17
- return
18
-
19
- def _maybe_prefetch(self, index):
20
- return
21
-
22
- async def _maybe_prefetch_async(self, index):
23
- return
24
-
25
- def filter(self, **kwargs):
26
- sc = super().filter(**kwargs)
27
- uuids = sc.get_field_values("fmu.realization.uuid.keyword")
28
- return Realizations(self, uuids)
29
-
30
- def get_object(self, uuid):
31
- if self._prototype is None:
32
- obj = super().get_object(uuid)
33
- if len(self.get_field_values("fmu.realization.uuid.keyword")) == 1:
34
- return obj
35
- # ELSE
36
- self._prototype = obj.metadata
37
- buckets = self.get_composite_agg(
38
- {
39
- "uuid": "fmu.realization.uuid.keyword",
40
- "name": "fmu.realization.name.keyword",
41
- "id": "fmu.realization.id",
42
- }
43
- )
44
- self._map = {b["uuid"]: b for b in buckets}
45
- pass
46
- metadata = deepcopy(self._prototype)
47
- b = self._map[uuid]
48
- metadata["fmu"]["realization"] = b
49
- return Realization(self._sumo, {"_id": uuid, "_source": metadata})
50
-
51
- async def get_object_async(self, uuid):
52
- if self._prototype is None:
53
- obj = await super().get_object_async(uuid)
54
- if (
55
- len(
56
- await self.get_field_values_async(
57
- "fmu.realization.uuid.keyword"
58
- )
59
- )
60
- == 1
61
- ):
62
- return obj
63
- # ELSE
64
- self._prototype = obj.metadata
65
- buckets = await self.get_composite_agg_async(
66
- {
67
- "uuid": "fmu.realization.uuid.keyword",
68
- "name": "fmu.realization.name.keyword",
69
- "id": "fmu.realization.id",
70
- }
71
- )
72
- self._map = {b["uuid"]: b for b in buckets}
73
- pass
74
- metadata = deepcopy(self._prototype)
75
- b = self._map[uuid]
76
- metadata["fmu"]["realization"] = b
77
- return Realization(self._sumo, {"_id": uuid, "_source": metadata})
78
-
79
- @property
80
- def classes(self) -> List[str]:
81
- return ["realization"]
82
-
83
- @property
84
- async def classes_async(self) -> List[str]:
85
- return ["realization"]
86
-
87
- @property
88
- def realizationids(self) -> List[int]:
89
- return [self.get_object(uuid).realizationid for uuid in self._hits]
90
-
91
- @property
92
- async def realizationids_async(self) -> List[int]:
93
- return [
94
- (await self.get_object_async(uuid)).realizationid
95
- for uuid in self._hits
96
- ]
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes