fmu-sumo 2.8.2__py3-none-any.whl → 2.10.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.
@@ -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.2'
32
- __version_tuple__ = version_tuple = (2, 8, 2)
31
+ __version__ = version = '2.10.0'
32
+ __version_tuple__ = version_tuple = (2, 10, 0)
33
33
 
34
34
  __commit_id__ = commit_id = None
@@ -22,7 +22,7 @@ class Filters:
22
22
  observations = {
23
23
  "bool": {
24
24
  "must_not": [
25
- {"exists": {"field": "fmu.iteration.name.keyword"}},
25
+ {"exists": {"field": "fmu.ensemble.name.keyword"}},
26
26
  {"exists": {"field": "fmu.realization.id"}},
27
27
  ]
28
28
  }
@@ -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
@@ -33,7 +33,7 @@ class Child(Document):
33
33
  return (
34
34
  f"<{self.__class__.__name__}: {self.name} {self.uuid}(uuid) "
35
35
  f"in realization {self.realization} "
36
- f"in iteration {self.iteration} "
36
+ f"in ensemble {self.ensemble} "
37
37
  f"in case {self.casename} "
38
38
  f"in asset {self.asset}>"
39
39
  )
@@ -41,7 +41,7 @@ class Child(Document):
41
41
  return (
42
42
  f"<{self.__class__.__name__}: {self.name} {self.uuid}(uuid) "
43
43
  f"in operation {self.operationname} "
44
- f"in iteration {self.iteration} "
44
+ f"in ensemble {self.ensemble} "
45
45
  f"in case {self.casename} "
46
46
  f"in asset {self.asset}>"
47
47
  )
@@ -94,8 +94,7 @@ class Child(Document):
94
94
  @property
95
95
  def template_path(self) -> str:
96
96
  return "/".join(
97
- ["{realization}", "{iteration}"]
98
- + self.relative_path.split("/")[2:]
97
+ ["{realization}", "{ensemble}"] + self.relative_path.split("/")[2:]
99
98
  )
100
99
 
101
100
  @property
@@ -138,11 +137,6 @@ class Child(Document):
138
137
  """Object realization"""
139
138
  return self.get_property("fmu.realization.id")
140
139
 
141
- @property
142
- def iteration(self) -> str:
143
- """Object iteration"""
144
- return self.get_property("fmu.iteration.name")
145
-
146
140
  @property
147
141
  def ensemble(self) -> str:
148
142
  """Object ensemble"""
@@ -64,19 +64,16 @@ def _gen_filter_gen(attr):
64
64
  def _gen_filter_stage(attr):
65
65
  """Match property against either single value or list of values.
66
66
  If the value given is a boolean, tests for existence or not of the property.
67
- In addition, if the value is or includes either "iteration" or "ensemble",
68
- expand to include both values.
67
+ In addition, if the value is or includes "ensemble" expand to include it.
69
68
  """
70
69
 
71
70
  _inner = _gen_filter_gen(attr)
72
71
 
73
72
  def _fn(value):
74
- if value == "iteration" or value == "ensemble":
75
- return _inner(["iteration", "ensemble"])
76
- elif isinstance(value, list) and set(value).intersection(
77
- {"iteration", "ensemble"}
78
- ):
79
- return _inner(list(set(value).union({"iteration", "ensemble"})))
73
+ if value == "ensemble":
74
+ return _inner(["ensemble"])
75
+ elif isinstance(value, list) and set(value).intersection({"ensemble"}):
76
+ return _inner(list(set(value).union({"ensemble"})))
80
77
  else:
81
78
  return _inner(value)
82
79
 
@@ -156,10 +153,6 @@ _filterspec = {
156
153
  "relative_path": [_gen_filter_gen, "file.relative_path.keyword"],
157
154
  "tagname": [_gen_filter_gen, "data.tagname.keyword"],
158
155
  "dataformat": [_gen_filter_gen, "data.format.keyword"],
159
- "iteration": [
160
- _gen_filter_gen,
161
- "fmu.iteration.name.keyword",
162
- ], # FIXME: to be removed
163
156
  "ensemble": [_gen_filter_gen, "fmu.ensemble.name.keyword"],
164
157
  "realization": [_gen_filter_gen, "fmu.realization.id"],
165
158
  "aggregation": [_gen_filter_gen, "fmu.aggregation.operation.keyword"],
@@ -368,7 +361,6 @@ class SearchContext:
368
361
  "table": objects.Table,
369
362
  "cpgrid": objects.CPGrid,
370
363
  "cpgrid_property": objects.CPGridProperty,
371
- "iteration": objects.Iteration, # FIXME: to be removed
372
364
  "ensemble": objects.Ensemble,
373
365
  "realization": objects.Realization,
374
366
  }.get(cls)
@@ -481,16 +473,22 @@ class SearchContext:
481
473
  query=self._query, size=1000, select=select
482
474
  )
483
475
 
476
+ def _getuuids(self):
477
+ return self._search_all()
478
+
479
+ async def _getuuids_async(self):
480
+ return await self._search_all_async()
481
+
484
482
  @property
485
483
  def uuids(self):
486
484
  if self._hits is None:
487
- self._hits = self._search_all()
485
+ self._hits = self._getuuids()
488
486
  return self._hits
489
487
 
490
488
  @property
491
489
  async def uuids_async(self):
492
490
  if self._hits is None:
493
- self._hits = await self._search_all_async()
491
+ self._hits = await self._getuuids_async()
494
492
  return self._hits
495
493
 
496
494
  def __iter__(self):
@@ -527,15 +525,17 @@ class SearchContext:
527
525
 
528
526
  def __getitem__(self, index):
529
527
  if self._hits is None:
530
- self._hits = self._search_all()
528
+ self._hits = self._getuuids()
531
529
  pass
530
+ self._maybe_prefetch(index)
532
531
  uuid = self._hits[index]
533
532
  return self.get_object(uuid)
534
533
 
535
534
  async def getitem_async(self, index):
536
535
  if self._hits is None:
537
- self._hits = await self._search_all_async()
536
+ self._hits = await self._getuuids_async()
538
537
  pass
538
+ await self._maybe_prefetch_async(index)
539
539
  uuid = self._hits[index]
540
540
  return await self.get_object_async(uuid)
541
541
 
@@ -599,66 +599,6 @@ class SearchContext:
599
599
  self._cache.clear()
600
600
  return self
601
601
 
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
602
  def get_object(self, uuid: str) -> objects.Document:
663
603
  """Get metadata object by uuid
664
604
 
@@ -679,12 +619,6 @@ class SearchContext:
679
619
 
680
620
  res = self._sumo.post("/search", json=query)
681
621
  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
622
  obj = hits[0]
689
623
  self._cache.put(uuid, obj)
690
624
 
@@ -712,11 +646,6 @@ class SearchContext:
712
646
  res = await self._sumo.post_async("/search", json=query)
713
647
  hits = res.json()["hits"]["hits"]
714
648
 
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
649
  obj = hits[0]
721
650
  self._cache.put(uuid, obj)
722
651
 
@@ -1142,22 +1071,6 @@ class SearchContext:
1142
1071
  uuids = await self.get_field_values_async("fmu.case.uuid.keyword")
1143
1072
  return objects.Cases(self, uuids)
1144
1073
 
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
1074
  @property
1162
1075
  def ensembles(self):
1163
1076
  """Ensembles from current selection."""
@@ -1424,32 +1337,6 @@ class SearchContext:
1424
1337
  """
1425
1338
  return await self._get_object_by_class_and_uuid_async("case", uuid)
1426
1339
 
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
1340
  def get_ensemble_by_uuid(self, uuid: str) -> objects.Ensemble:
1454
1341
  """Get ensemble object by uuid
1455
1342
 
@@ -1656,7 +1543,6 @@ class SearchContext:
1656
1543
  "class": classname,
1657
1544
  "entity_uuid": entityuuid,
1658
1545
  "ensemble_name": ensemblename,
1659
- "iteration_name": ensemblename,
1660
1546
  "operations": [operation],
1661
1547
  }
1662
1548
  if columns is not None:
@@ -12,19 +12,19 @@ def _make_overview_query(id) -> Dict:
12
12
  return {
13
13
  "query": {"term": {"fmu.case.uuid.keyword": id}},
14
14
  "aggs": {
15
- "iteration_uuids": {
16
- "terms": {"field": "fmu.iteration.uuid.keyword", "size": 100}
15
+ "ensemble_uuids": {
16
+ "terms": {"field": "fmu.ensemble.uuid.keyword", "size": 100}
17
17
  },
18
- "iteration_names": {
19
- "terms": {"field": "fmu.iteration.name.keyword", "size": 100}
18
+ "ensemble_names": {
19
+ "terms": {"field": "fmu.ensemble.name.keyword", "size": 100}
20
20
  },
21
21
  "data_types": {"terms": {"field": "class.keyword", "size": 100}},
22
- "iterations": {
23
- "terms": {"field": "fmu.iteration.uuid.keyword", "size": 100},
22
+ "ensembles": {
23
+ "terms": {"field": "fmu.ensemble.uuid.keyword", "size": 100},
24
24
  "aggs": {
25
- "iteration_name": {
25
+ "ensemble_name": {
26
26
  "terms": {
27
- "field": "fmu.iteration.name.keyword",
27
+ "field": "fmu.ensemble.name.keyword",
28
28
  "size": 100,
29
29
  }
30
30
  },
@@ -49,7 +49,7 @@ class Case(Document, SearchContext):
49
49
  self, sumo, must=[{"term": {"fmu.case.uuid.keyword": self.uuid}}]
50
50
  )
51
51
  self._overview = None
52
- self._iterations = None
52
+ self._ensembles = None
53
53
 
54
54
  @property
55
55
  def overview(self) -> Dict:
@@ -63,27 +63,27 @@ class Case(Document, SearchContext):
63
63
  res = self._sumo.post("/search", json=query)
64
64
  data = res.json()
65
65
  aggs = data["aggregations"]
66
- iteration_names = extract_bucket_keys(aggs, "iteration_names")
67
- iteration_uuids = extract_bucket_keys(aggs, "iteration_uuids")
66
+ ensemble_names = extract_bucket_keys(aggs, "ensemble_names")
67
+ ensemble_uuids = extract_bucket_keys(aggs, "ensemble_uuids")
68
68
  data_types = extract_bucket_keys(aggs, "data_types")
69
- iterations = {}
70
- for bucket in aggs["iterations"]["buckets"]:
69
+ ensembles = {}
70
+ for bucket in aggs["ensembles"]["buckets"]:
71
71
  iterid = bucket["key"]
72
- itername = extract_bucket_keys(bucket, "iteration_name")
72
+ itername = extract_bucket_keys(bucket, "ensemble_name")
73
73
  minreal = bucket["minreal"]["value"]
74
74
  maxreal = bucket["maxreal"]["value"]
75
75
  numreal = bucket["numreal"]["value"]
76
- iterations[iterid] = {
76
+ ensembles[iterid] = {
77
77
  "name": itername,
78
78
  "minreal": minreal,
79
79
  "maxreal": maxreal,
80
80
  "numreal": numreal,
81
81
  }
82
82
  self._overview = {
83
- "iteration_names": iteration_names,
84
- "iteration_uuids": iteration_uuids,
83
+ "ensemble_names": ensemble_names,
84
+ "ensemble_uuids": ensemble_uuids,
85
85
  "data_types": data_types,
86
- "iterations": iterations,
86
+ "ensembles": ensembles,
87
87
  }
88
88
 
89
89
  return self._overview
@@ -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):
@@ -61,7 +61,7 @@ class CPGrid(Child):
61
61
  """
62
62
  sc = SearchContext(self._sumo).grid_properties.filter(
63
63
  uuid=self.caseuuid,
64
- iteration=self.iteration,
64
+ ensemble=self.ensemble,
65
65
  realization=self.realization,
66
66
  )
67
67
  return sc.filter(
@@ -61,7 +61,7 @@ class CPGridProperty(Child):
61
61
  """
62
62
  sc = SearchContext(self._sumo).grids.filter(
63
63
  uuid=self.caseuuid,
64
- iteration=self.iteration,
64
+ ensemble=self.ensemble,
65
65
  realization=self.realization,
66
66
  )
67
67
  should = [
@@ -1,74 +1,21 @@
1
1
  """Module for searchcontext for collection of ensembles."""
2
2
 
3
- from copy import deepcopy
4
3
  from typing import List
5
4
 
6
- from fmu.sumo.explorer.objects.ensemble import Ensemble
7
-
8
5
  from ._search_context import SearchContext
9
6
 
10
7
 
11
8
  class Ensembles(SearchContext):
12
9
  def __init__(self, sc, uuids):
13
- super().__init__(sc._sumo, must=sc._must, must_not=sc._must_not)
10
+ super().__init__(sc._sumo, must=[{"ids": {"values": uuids}}])
14
11
  self._hits = uuids
15
- self._prototype = None
16
- self._map = {}
17
- return
18
-
19
- def _maybe_prefetch(self, index):
20
12
  return
21
13
 
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})
14
+ def __len__(self):
15
+ return len(self.uuids)
49
16
 
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})
17
+ async def length_async(self):
18
+ return len(await self.uuids_async)
72
19
 
73
20
  @property
74
21
  def classes(self) -> List[str]:
@@ -80,11 +27,8 @@ class Ensembles(SearchContext):
80
27
 
81
28
  @property
82
29
  def ensemblenames(self) -> List[str]:
83
- return [self.get_object(uuid).ensemblename for uuid in self._hits]
30
+ return self.get_field_values("fmu.ensemble.name.keyword")
84
31
 
85
32
  @property
86
33
  async def ensemblenames_async(self) -> List[str]:
87
- return [
88
- (await self.get_object_async(uuid)).ensemblename
89
- for uuid in self._hits
90
- ]
34
+ return await self.get_field_values_async("fmu.ensemble.name.keyword")
@@ -26,7 +26,7 @@ class Realization(Document, SearchContext):
26
26
  def __str__(self):
27
27
  return (
28
28
  f"<{self.__class__.__name__}: {self.realizationid} {self.uuid}(uuid) "
29
- f"in iteration {self.iterationname} "
29
+ f"in ensemble {self.ensemblename} "
30
30
  f"in case {self.casename} "
31
31
  f"in asset {self.asset}>"
32
32
  )
@@ -46,7 +46,7 @@ class Realization(Document, SearchContext):
46
46
 
47
47
  @property
48
48
  def user(self) -> str:
49
- """Name of user who uploaded iteration."""
49
+ """Name of user who uploaded ensemble."""
50
50
  return self.get_property("fmu.case.user.id")
51
51
 
52
52
  @property
@@ -60,14 +60,14 @@ class Realization(Document, SearchContext):
60
60
  return self.get_property("fmu.case.name")
61
61
 
62
62
  @property
63
- def iterationuuid(self) -> str:
64
- """FMU iteration uuid"""
65
- return self.get_property("fmu.iteration.uuid")
63
+ def ensembleuuid(self) -> str:
64
+ """FMU ensemble uuid"""
65
+ return self.get_property("fmu.ensemble.uuid")
66
66
 
67
67
  @property
68
- def iterationname(self) -> str:
69
- """FMU iteration name"""
70
- return self.get_property("fmu.iteration.name")
68
+ def ensemblename(self) -> str:
69
+ """FMU ensemble name"""
70
+ return self.get_property("fmu.ensemble.name")
71
71
 
72
72
  @property
73
73
  def realizationuuid(self) -> str:
@@ -1,80 +1,21 @@
1
1
  """Module for searchcontext for collection of realizations."""
2
2
 
3
- from copy import deepcopy
4
3
  from typing import List
5
4
 
6
- from fmu.sumo.explorer.objects.realization import Realization
7
-
8
5
  from ._search_context import SearchContext
9
6
 
10
7
 
11
8
  class Realizations(SearchContext):
12
9
  def __init__(self, sc, uuids):
13
- super().__init__(sc._sumo, must=sc._must, must_not=sc._must_not)
10
+ super().__init__(sc._sumo, must=[{"ids": {"values": uuids}}])
14
11
  self._hits = uuids
15
- self._prototype = None
16
- self._map = {}
17
- return
18
-
19
- def _maybe_prefetch(self, index):
20
12
  return
21
13
 
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})
14
+ def __len__(self):
15
+ return len(self.uuids)
50
16
 
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})
17
+ async def length_async(self):
18
+ return len(await self.uuids_async)
78
19
 
79
20
  @property
80
21
  def classes(self) -> List[str]:
@@ -86,11 +27,8 @@ class Realizations(SearchContext):
86
27
 
87
28
  @property
88
29
  def realizationids(self) -> List[int]:
89
- return [self.get_object(uuid).realizationid for uuid in self._hits]
30
+ return self.get_field_values("fmu.realization.id")
90
31
 
91
32
  @property
92
33
  async def realizationids_async(self) -> List[int]:
93
- return [
94
- (await self.get_object_async(uuid)).realizationid
95
- for uuid in self._hits
96
- ]
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.2
3
+ Version: 2.10.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,31 @@
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=2cFLkHY3I9n23ToIWm38PohvvIEYjdsebREPVvOKAiU,706
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=Es4JiSvHfCNiN5GXxfaBIBp-1BeFRgNzUeGOTXknK7s,874
8
+ fmu/sumo/explorer/timefilter.py,sha256=AQHa18vkCz2BzH7X9GR1ypmNxfvI4gExh_jxAVYrDjc,6260
9
+ fmu/sumo/explorer/objects/__init__.py,sha256=KoZ-Wo1YUIkWN1aGKu-xbQDkQlZQTP5oUwTRUyVoV9U,569
10
+ fmu/sumo/explorer/objects/_child.py,sha256=gV4dtXSGqGSg5R1Xkh7el0SAsRzD-cdLvu8PtNYqi90,6072
11
+ fmu/sumo/explorer/objects/_document.py,sha256=UR607n9N33vYaTSsYQoMmJUgnmS3To_uVyRSf7Vxulo,1797
12
+ fmu/sumo/explorer/objects/_metrics.py,sha256=Z7iJ8qmvH3iY5dsSf6At_AFIzITyM0rDfum_oGmUFG8,9989
13
+ fmu/sumo/explorer/objects/_search_context.py,sha256=cCmy5toYsIyqDCYG02ud33KSDC_UeNLmsw4MGfo06AM,64911
14
+ fmu/sumo/explorer/objects/case.py,sha256=9ptXE1XTkAGbw_R4Nh9KgCktoq2Ahu-YoLhc2wJAKOE,3790
15
+ fmu/sumo/explorer/objects/cases.py,sha256=6Hj9ORj4Zta-C8Q9wpFYNsOqR8q-KCXrX-mlsc1hg0o,695
16
+ fmu/sumo/explorer/objects/cpgrid.py,sha256=3dQBiKJCbjrwIc9-Fm3dcg_kCLPXst37NI5Sl_Hk1uQ,2546
17
+ fmu/sumo/explorer/objects/cpgrid_property.py,sha256=-URqq6I0UX4fvqi8LO2gQUF6zUoFCTvQBp_ukJR2Bdo,2692
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=MoGiXrtyVL8_cQt5vjh0rIA5bMMGRahPb284teQEqfs,2767
21
+ fmu/sumo/explorer/objects/ensembles.py,sha256=ZTM74xMY8EjQjaSOgIcEMXhnJB7LDoqqdjIXXkmGZvQ,883
22
+ fmu/sumo/explorer/objects/polygons.py,sha256=0N6sKTOGkYO6augIbBObzdovCAIF5VtA_XDzbWvd3YY,1523
23
+ fmu/sumo/explorer/objects/realization.py,sha256=1ZvPGjoCZ_xNEHJ5Lp6-TYLuq0UHG2IymHBo9BV6koI,2474
24
+ fmu/sumo/explorer/objects/realizations.py,sha256=KIvr6gA-rDAUfcPmsLZQ7jN83-u3SQD0Jk2j9usH-So,883
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-2.10.0.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
28
+ fmu_sumo-2.10.0.dist-info/METADATA,sha256=FI4p5r1aza3Hs2c_3GkAo13RgYwBtenpwyPbxX3CToY,14782
29
+ fmu_sumo-2.10.0.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
30
+ fmu_sumo-2.10.0.dist-info/top_level.txt,sha256=Z-FIY3pxn0UK2Wxi9IJ7fKoLSraaxuNGi1eokiE0ShM,4
31
+ fmu_sumo-2.10.0.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (80.9.0)
2
+ Generator: setuptools (80.10.2)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -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,33 +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=K2e_IVECOS4JNwYcS4GZillyIK8on3GFXEEwBIw49VU,704
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=7CJiBGfmtK7zNDUv6NLWphHMMtC8M386VyrGhuHq4dk,6222
11
- fmu/sumo/explorer/objects/_document.py,sha256=UR607n9N33vYaTSsYQoMmJUgnmS3To_uVyRSf7Vxulo,1797
12
- fmu/sumo/explorer/objects/_metrics.py,sha256=Z7iJ8qmvH3iY5dsSf6At_AFIzITyM0rDfum_oGmUFG8,9989
13
- fmu/sumo/explorer/objects/_search_context.py,sha256=2JP1Y7T6na5kUFfIj7UMlKlVT5waLrGMx5zkIr_PnB8,68939
14
- fmu/sumo/explorer/objects/case.py,sha256=fKp7X43ETLE1RaH3rMYxZiIuduRmf0JSnJ5gRoUgNPE,3813
15
- fmu/sumo/explorer/objects/cases.py,sha256=_6q8rXWUeJgHGF1b3X9rt3VQmH_HE7uPU0Id4Fmtq_E,659
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=MoGiXrtyVL8_cQt5vjh0rIA5bMMGRahPb284teQEqfs,2767
21
- fmu/sumo/explorer/objects/ensembles.py,sha256=O9Nfjl8-SMf1tJQKWf0pTEHeN5vfLWlPRXegkwkboKE,2814
22
- fmu/sumo/explorer/objects/iteration.py,sha256=vXaH6G93pNPvufgliqRSs4fpqgNvgxa7QI0G0ucgr_U,2784
23
- fmu/sumo/explorer/objects/iterations.py,sha256=ZRQOxPl6MpX7JV7lfvtXp8mGLHl37pl3-F9YAXYfRgc,778
24
- fmu/sumo/explorer/objects/polygons.py,sha256=0N6sKTOGkYO6augIbBObzdovCAIF5VtA_XDzbWvd3YY,1523
25
- fmu/sumo/explorer/objects/realization.py,sha256=HK47WyX6kwe6ZoHaGHeTWEno86Wkh9THLOtEzOt1FGE,2483
26
- fmu/sumo/explorer/objects/realizations.py,sha256=OdaNVEZ29Fnr3i8SP2oWn01st3aMTN6U0ph-BsPXmbA,3064
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.8.2.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
30
- fmu_sumo-2.8.2.dist-info/METADATA,sha256=z0Hb_SuYDUNinBMw-yJeVNaqqCRr9clVZ3sL2XAyack,14781
31
- fmu_sumo-2.8.2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
32
- fmu_sumo-2.8.2.dist-info/top_level.txt,sha256=Z-FIY3pxn0UK2Wxi9IJ7fKoLSraaxuNGi1eokiE0ShM,4
33
- fmu_sumo-2.8.2.dist-info/RECORD,,