fmu-sumo 2.4.1__py3-none-any.whl → 2.4.2__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.4.1'
21
- __version_tuple__ = version_tuple = (2, 4, 1)
20
+ __version__ = version = '2.4.2'
21
+ __version_tuple__ = version_tuple = (2, 4, 2)
@@ -11,6 +11,16 @@ class Metrics:
11
11
  res = self._search_context._sumo.post("/search", json=qdoc).json()
12
12
  return res["aggregations"]["agg"]
13
13
 
14
+ async def _aggregate_async(self, op, **kwargs):
15
+ aggs = {
16
+ "agg": {op: {k: v for k, v in kwargs.items() if v is not None}}
17
+ }
18
+ qdoc = {"query": self._search_context._query, "aggs": aggs, "size": 0}
19
+ res = (
20
+ await self._search_context._sumo.post_async("/search", json=qdoc)
21
+ ).json()
22
+ return res["aggregations"]["agg"]
23
+
14
24
  def min(self, field):
15
25
  """Find the minimum value for the specified property across the
16
26
  current set of objects.
@@ -24,6 +34,19 @@ class Metrics:
24
34
  """
25
35
  return self._aggregate("min", field=field)["value"]
26
36
 
37
+ async def min_async(self, field):
38
+ """Find the minimum value for the specified property across the
39
+ current set of objects.
40
+
41
+ Arguments:
42
+ - field (str): the name of a property in the metadata.
43
+
44
+ Returns:
45
+ The minimum value.
46
+
47
+ """
48
+ return (await self._aggregate_async("min", field=field))["value"]
49
+
27
50
  def max(self, field):
28
51
  """Find the maximum value for the specified property across the
29
52
  current set of objects.
@@ -37,6 +60,19 @@ class Metrics:
37
60
  """
38
61
  return self._aggregate("max", field=field)["value"]
39
62
 
63
+ async def max_async(self, field):
64
+ """Find the maximum value for the specified property across the
65
+ current set of objects.
66
+
67
+ Arguments:
68
+ - field (str): the name of a property in the metadata.
69
+
70
+ Returns:
71
+ The maximum value.
72
+
73
+ """
74
+ return (await self._aggregate_async("max", field=field))["value"]
75
+
40
76
  def avg(self, field):
41
77
  """Find the average value for the specified property across the
42
78
  current set of objects.
@@ -50,6 +86,19 @@ class Metrics:
50
86
  """
51
87
  return self._aggregate("avg", field=field)["value"]
52
88
 
89
+ async def avg_async(self, field):
90
+ """Find the average value for the specified property across the
91
+ current set of objects.
92
+
93
+ Arguments:
94
+ - field (str): the name of a property in the metadata.
95
+
96
+ Returns:
97
+ The average value.
98
+
99
+ """
100
+ return (await self._aggregate_async("avg", field=field))["value"]
101
+
53
102
  def sum(self, field):
54
103
  """Find the sumo of all values for the specified property across
55
104
  the current set of objects.
@@ -63,6 +112,19 @@ class Metrics:
63
112
  """
64
113
  return self._aggregate("sum", field=field)["value"]
65
114
 
115
+ async def sum_async(self, field):
116
+ """Find the sumo of all values for the specified property across
117
+ the current set of objects.
118
+
119
+ Arguments:
120
+ - field (str): the name of a property in the metadata.
121
+
122
+ Returns:
123
+ The sum of all values.
124
+
125
+ """
126
+ return (await self._aggregate_async("sum", field=field))["value"]
127
+
66
128
  def value_count(self, field):
67
129
  """Find the count of values for the specified property across the
68
130
  current set of objects.
@@ -76,6 +138,21 @@ class Metrics:
76
138
  """
77
139
  return self._aggregate("value_count", field=field)["value"]
78
140
 
141
+ async def value_count_async(self, field):
142
+ """Find the count of values for the specified property across the
143
+ current set of objects.
144
+
145
+ Arguments:
146
+ - field (str): the name of a property in the metadata.
147
+
148
+ Returns:
149
+ The total number of values.
150
+
151
+ """
152
+ return (await self._aggregate_async("value_count", field=field))[
153
+ "value"
154
+ ]
155
+
79
156
  def cardinality(self, field):
80
157
  """Find the count of distinct values for the specified property
81
158
  across the current set of objects.
@@ -91,6 +168,23 @@ class Metrics:
91
168
  """
92
169
  return self._aggregate("cardinality", field=field)["value"]
93
170
 
171
+ async def cardinality_async(self, field):
172
+ """Find the count of distinct values for the specified property
173
+ across the current set of objects.
174
+
175
+ Arguments:
176
+ - field (str): the name of a property in the metadata.
177
+
178
+ Returns:
179
+ The number of distinct values.
180
+
181
+ Note: The value returned is approximate.
182
+
183
+ """
184
+ return (await self._aggregate_async("cardinality", field=field))[
185
+ "value"
186
+ ]
187
+
94
188
  def stats(self, field):
95
189
  """Compute a basic set of statistics of the values for the specified
96
190
  property across the current set of objects.
@@ -104,6 +198,19 @@ class Metrics:
104
198
  """
105
199
  return self._aggregate("stats", field=field)
106
200
 
201
+ async def stats_async(self, field):
202
+ """Compute a basic set of statistics of the values for the specified
203
+ property across the current set of objects.
204
+
205
+ Arguments:
206
+ - field (str): the name of a property in the metadata.
207
+
208
+ Returns:
209
+ A dictionary of statistical metrics.
210
+
211
+ """
212
+ return await self._aggregate_async("stats", field=field)
213
+
107
214
  def extended_stats(self, field):
108
215
  """Compute an extended set of statistics of the values for the
109
216
  specified property across the current set of objects.
@@ -117,6 +224,19 @@ class Metrics:
117
224
  """
118
225
  return self._aggregate("extended_stats", field=field)
119
226
 
227
+ async def extended_stats_async(self, field):
228
+ """Compute an extended set of statistics of the values for the
229
+ specified property across the current set of objects.
230
+
231
+ Arguments:
232
+ - field (str): the name of a property in the metadata.
233
+
234
+ Returns:
235
+ A dictionary of statistical metrics.
236
+
237
+ """
238
+ return await self._aggregate_async("extended_stats", field=field)
239
+
120
240
  def percentiles(self, field, percents=None):
121
241
  """Find the values at specific percentiles for the specified
122
242
  property across the current set of objects.
@@ -133,3 +253,22 @@ class Metrics:
133
253
  return self._aggregate("percentiles", field=field, percents=percents)[
134
254
  "values"
135
255
  ]
256
+
257
+ async def percentiles_async(self, field, percents=None):
258
+ """Find the values at specific percentiles for the specified
259
+ property across the current set of objects.
260
+
261
+ Arguments:
262
+ - field (str): the name of a property in the metadata.
263
+ - percents ([number]): list of percent values. If omitted, uses
264
+ a default set of values.
265
+
266
+ Returns:
267
+ A dictionary of percentiles.
268
+
269
+ """
270
+ return (
271
+ await self._aggregate_async(
272
+ "percentiles", field=field, percents=percents
273
+ )
274
+ )["values"]
@@ -64,6 +64,28 @@ def _gen_filter_gen(attr):
64
64
  return _fn
65
65
 
66
66
 
67
+ def _gen_filter_stage(attr):
68
+ """Match property against either single value or list of values.
69
+ If the value given is a boolean, tests for existence or not of the property.
70
+ In addition, if the value is or includes either "iteration" or "ensemble",
71
+ expand to include both values.
72
+ """
73
+
74
+ _inner = _gen_filter_gen(attr)
75
+
76
+ def _fn(value):
77
+ if value == "iteration" or value == "ensemble":
78
+ return _inner(["iteration", "ensemble"])
79
+ elif isinstance(value, list) and set(value).intersection(
80
+ {"iteration", "ensemble"}
81
+ ):
82
+ return _inner(list(set(value).union({"iteration", "ensemble"})))
83
+ else:
84
+ return _inner(value)
85
+
86
+ return _fn
87
+
88
+
67
89
  def _gen_filter_name():
68
90
  """Match against \"data.name\", or \"case.name\" for case objects."""
69
91
 
@@ -144,7 +166,7 @@ _filterspec = {
144
166
  "ensemble": [_gen_filter_gen, "fmu.ensemble.name.keyword"],
145
167
  "realization": [_gen_filter_gen, "fmu.realization.id"],
146
168
  "aggregation": [_gen_filter_gen, "fmu.aggregation.operation.keyword"],
147
- "stage": [_gen_filter_gen, "fmu.context.stage.keyword"],
169
+ "stage": [_gen_filter_stage, "fmu.context.stage.keyword"],
148
170
  "column": [_gen_filter_gen, "data.spec.columns.keyword"],
149
171
  "vertical_domain": [_gen_filter_gen, "data.vertical_domain.keyword"],
150
172
  "content": [_gen_filter_gen, "data.content.keyword"],
@@ -156,6 +178,7 @@ _filterspec = {
156
178
  "is_observation": [_gen_filter_bool, "data.is_observation"],
157
179
  "is_prediction": [_gen_filter_bool, "data.is_prediction"],
158
180
  "standard_result": [_gen_filter_gen, "data.standard_result.name.keyword"],
181
+ "entity": [_gen_filter_gen, "fmu.entity.uuid.keyword"],
159
182
  "complex": [_gen_filter_complex, None],
160
183
  "has": [_gen_filter_none, None],
161
184
  }
@@ -1931,6 +1954,16 @@ class SearchContext:
1931
1954
  "data.standard_result.name.keyword"
1932
1955
  )
1933
1956
 
1957
+ @property
1958
+ def entities(self) -> List[str]:
1959
+ """List of entity uuids."""
1960
+ return self.get_field_values("fmu.entity.uuid.keyword")
1961
+
1962
+ @property
1963
+ async def entities_async(self) -> List[str]:
1964
+ """List of entity uuids."""
1965
+ return await self.get_field_values_async("fmu.entity.uuid.keyword")
1966
+
1934
1967
 
1935
1968
  def _gen_filter_doc(spec):
1936
1969
  fmap = {
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: fmu-sumo
3
- Version: 2.4.1
3
+ Version: 2.4.2
4
4
  Summary: Python package for interacting with Sumo in an FMU setting
5
5
  Author: Equinor
6
6
  License: Apache License
@@ -1,7 +1,7 @@
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=H3hbvip-BJTNbNG0ITRXctaII3Vc2949yckZEGuAGg8,511
4
+ fmu/sumo/explorer/_version.py,sha256=RUYmq8GFeP2I_XyABp0HnMjSBqGntVVhgCtP72xF2Nk,511
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
@@ -9,8 +9,8 @@ fmu/sumo/explorer/timefilter.py,sha256=AQHa18vkCz2BzH7X9GR1ypmNxfvI4gExh_jxAVYrD
9
9
  fmu/sumo/explorer/objects/__init__.py,sha256=72G0yfWWMTXA-oZw5GMRkrWvQqAYfadjerEwsyndCzc,637
10
10
  fmu/sumo/explorer/objects/_child.py,sha256=Cq2jmjRjJDjh0hwy_lKWhPdvkuoMqx6UoHFIcmAJ7OA,5905
11
11
  fmu/sumo/explorer/objects/_document.py,sha256=uPAkNzcOk8U4LCtXthWkm7kfU9W4HYHrrqV9HERDhe8,1835
12
- fmu/sumo/explorer/objects/_metrics.py,sha256=q6CSeCjiN1SjNx4G32Lod7Slnflsu3aoJIpwm_VMIhQ,3954
13
- fmu/sumo/explorer/objects/_search_context.py,sha256=V5O3q3sM9QnFjRuwzWaJrvdGtDwUh3xGYlswYKzc6A4,62726
12
+ fmu/sumo/explorer/objects/_metrics.py,sha256=WITAFAV-3VRd-AqTg0tUwWpOChW4YFfF8ffT2fvOrAo,8144
13
+ fmu/sumo/explorer/objects/_search_context.py,sha256=a8RTE9mlNvHVdXbMMCsv6RF9PzYn4d4JnJZQONkuFKE,63840
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
@@ -26,8 +26,8 @@ fmu/sumo/explorer/objects/realization.py,sha256=Th3zr_nT2I1HYHkBojOAKnf_RSIPc-Ti
26
26
  fmu/sumo/explorer/objects/realizations.py,sha256=4agtQFJ5pxLyWMeIzdJbkBMc8__Md-tZOj8Un4ol22c,1562
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.1.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
30
- fmu_sumo-2.4.1.dist-info/METADATA,sha256=M8zKipDl1zfpmcJYulUNpQAGssQzKxtsURnpwxYFFkg,14780
31
- fmu_sumo-2.4.1.dist-info/WHEEL,sha256=zaaOINJESkSfm_4HQVc5ssNzHCPXhJm0kEUakpsEHaU,91
32
- fmu_sumo-2.4.1.dist-info/top_level.txt,sha256=Z-FIY3pxn0UK2Wxi9IJ7fKoLSraaxuNGi1eokiE0ShM,4
33
- fmu_sumo-2.4.1.dist-info/RECORD,,
29
+ fmu_sumo-2.4.2.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
30
+ fmu_sumo-2.4.2.dist-info/METADATA,sha256=z6Zm-yb_u2nBsS8WxunvbyaNEglVsNhKU155I2VHGIc,14780
31
+ fmu_sumo-2.4.2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
32
+ fmu_sumo-2.4.2.dist-info/top_level.txt,sha256=Z-FIY3pxn0UK2Wxi9IJ7fKoLSraaxuNGi1eokiE0ShM,4
33
+ fmu_sumo-2.4.2.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (80.8.0)
2
+ Generator: setuptools (80.9.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5