fmu-sumo 2.3.7__py3-none-any.whl → 2.3.9__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.7'
21
- __version_tuple__ = version_tuple = (2, 3, 7)
20
+ __version__ = version = '2.3.9'
21
+ __version_tuple__ = version_tuple = (2, 3, 9)
@@ -1,11 +1,13 @@
1
1
  """Module containing class for exploring results from sumo"""
2
2
 
3
3
  import warnings
4
+ from typing import Optional
4
5
 
5
6
  import httpx
6
7
  from sumo.wrapper import SumoClient
7
8
 
8
- from fmu.sumo.explorer.objects._search_context import SearchContext
9
+ from .objects._search_context import SearchContext
10
+ from .objects.cases import Cases
9
11
 
10
12
 
11
13
  class Explorer(SearchContext):
@@ -25,9 +27,9 @@ class Explorer(SearchContext):
25
27
  def __init__(
26
28
  self,
27
29
  env: str = "prod",
28
- token: str = None,
30
+ token: Optional[str] = None,
29
31
  interactive: bool = True,
30
- keep_alive: str = None,
32
+ keep_alive: Optional[str] = None,
31
33
  http_client=None,
32
34
  async_http_client=None,
33
35
  ):
@@ -56,9 +58,10 @@ class Explorer(SearchContext):
56
58
 
57
59
  @property
58
60
  def cases(self):
59
- return self._context_for_class("case")
61
+ uuids = self._context_for_class("case").uuids
62
+ return Cases(self, uuids)
60
63
 
61
- def get_permissions(self, asset: str = None):
64
+ def get_permissions(self, asset: Optional[str] = None):
62
65
  """Get permissions
63
66
 
64
67
  Args:
@@ -74,7 +77,7 @@ class Explorer(SearchContext):
74
77
 
75
78
  return res
76
79
 
77
- async def get_permissions_async(self, asset: str = None):
80
+ async def get_permissions_async(self, asset: Optional[str] = None):
78
81
  """Get permissions
79
82
 
80
83
  Args:
@@ -1,3 +1,8 @@
1
+ """
2
+ Complex(ish) filters for use with fmu-sumo Explorer.
3
+ """
4
+
5
+
1
6
  class Filters:
2
7
  # Filter that matches 4d-seismic objects.
3
8
  seismic4d = {
@@ -1,18 +1,21 @@
1
1
  """Sumo cases and child objects"""
2
2
 
3
- from fmu.sumo.explorer.objects._child import Child
4
- from fmu.sumo.explorer.objects._metrics import Metrics
5
- from fmu.sumo.explorer.objects._search_context import SearchContext
6
- from fmu.sumo.explorer.objects.case import Case
7
- from fmu.sumo.explorer.objects.cases import Cases
8
- from fmu.sumo.explorer.objects.cpgrid import CPGrid
9
- from fmu.sumo.explorer.objects.cpgrid_property import CPGridProperty
10
- from fmu.sumo.explorer.objects.cube import Cube
11
- from fmu.sumo.explorer.objects.dictionary import Dictionary
12
- from fmu.sumo.explorer.objects.iteration import Iteration
13
- from fmu.sumo.explorer.objects.iterations import Iterations
14
- from fmu.sumo.explorer.objects.polygons import Polygons
15
- from fmu.sumo.explorer.objects.realization import Realization
16
- from fmu.sumo.explorer.objects.realizations import Realizations
17
- from fmu.sumo.explorer.objects.surface import Surface
18
- from fmu.sumo.explorer.objects.table import Table
3
+ from ._child import Child
4
+ from ._document import Document
5
+ from ._metrics import Metrics
6
+ from ._search_context import SearchContext
7
+ from .case import Case
8
+ from .cases import Cases
9
+ from .cpgrid import CPGrid
10
+ from .cpgrid_property import CPGridProperty
11
+ from .cube import Cube
12
+ from .dictionary import Dictionary
13
+ from .ensemble import Ensemble
14
+ from .ensembles import Ensembles
15
+ from .iteration import Iteration
16
+ from .iterations import Iterations
17
+ from .polygons import Polygons
18
+ from .realization import Realization
19
+ from .realizations import Realizations
20
+ from .surface import Surface
21
+ from .table import Table
@@ -1,11 +1,11 @@
1
1
  """module containing class for child object"""
2
2
 
3
3
  from io import BytesIO
4
- from typing import Dict, List
4
+ from typing import Dict, List, Tuple, Union
5
5
 
6
6
  from sumo.wrapper import SumoClient
7
7
 
8
- from fmu.sumo.explorer.objects._document import Document
8
+ from ._document import Document
9
9
 
10
10
 
11
11
  class Child(Document):
@@ -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"""
@@ -40,7 +67,7 @@ class Child(Document):
40
67
  return self._blob
41
68
 
42
69
  @property
43
- def timestamp(self) -> str:
70
+ def timestamp(self) -> Union[str, None]:
44
71
  """Object timestmap data"""
45
72
  t0 = self._get_property(["data", "time", "t0", "value"])
46
73
  t1 = self._get_property(["data", "time", "t1", "value"])
@@ -51,7 +78,7 @@ class Child(Document):
51
78
  return None
52
79
 
53
80
  @property
54
- def interval(self) -> str:
81
+ def interval(self) -> Union[str, Tuple[str, str], None]:
55
82
  """Object interval data"""
56
83
  t0 = self._get_property(["data", "time", "t0", "value"])
57
84
  t1 = self._get_property(["data", "time", "t1", "value"])
@@ -62,7 +89,7 @@ class Child(Document):
62
89
  return None
63
90
 
64
91
  @property
65
- def template_path(self):
92
+ def template_path(self) -> str:
66
93
  return "/".join(
67
94
  ["{realization}", "{iteration}"]
68
95
  + self.relative_path.split("/")[2:]
@@ -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
@@ -40,7 +50,11 @@ class Document:
40
50
  curr = self._metadata
41
51
 
42
52
  for key in path:
43
- if (isinstance(curr, list) and key < len(curr)) or key in curr:
53
+ if (
54
+ isinstance(curr, list)
55
+ and isinstance(key, int)
56
+ and key < len(curr)
57
+ ) or key in curr:
44
58
  curr = curr[key]
45
59
  else:
46
60
  return None
@@ -52,3 +66,15 @@ class Document:
52
66
 
53
67
  def __getitem__(self, key: str):
54
68
  return self._metadata[key]
69
+
70
+ @property
71
+ def template_path(self) -> str:
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")