evo-objects 0.4.1__tar.gz → 0.4.3__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.
- {evo_objects-0.4.1 → evo_objects-0.4.3}/PKG-INFO +1 -1
- {evo_objects-0.4.1 → evo_objects-0.4.3}/pyproject.toml +1 -1
- {evo_objects-0.4.1 → evo_objects-0.4.3}/src/evo/objects/utils/data.py +33 -6
- {evo_objects-0.4.1 → evo_objects-0.4.3}/src/evo/objects/utils/tables.py +2 -2
- {evo_objects-0.4.1 → evo_objects-0.4.3}/.gitignore +0 -0
- {evo_objects-0.4.1 → evo_objects-0.4.3}/LICENSE.md +0 -0
- {evo_objects-0.4.1 → evo_objects-0.4.3}/src/evo/objects/__init__.py +0 -0
- {evo_objects-0.4.1 → evo_objects-0.4.3}/src/evo/objects/_model_config.py +0 -0
- {evo_objects-0.4.1 → evo_objects-0.4.3}/src/evo/objects/client/__init__.py +0 -0
- {evo_objects-0.4.1 → evo_objects-0.4.3}/src/evo/objects/client/api_client.py +0 -0
- {evo_objects-0.4.1 → evo_objects-0.4.3}/src/evo/objects/client/object_client.py +0 -0
- {evo_objects-0.4.1 → evo_objects-0.4.3}/src/evo/objects/client/parse.py +0 -0
- {evo_objects-0.4.1 → evo_objects-0.4.3}/src/evo/objects/data.py +0 -0
- {evo_objects-0.4.1 → evo_objects-0.4.3}/src/evo/objects/endpoints/__init__.py +0 -0
- {evo_objects-0.4.1 → evo_objects-0.4.3}/src/evo/objects/endpoints/api/__init__.py +0 -0
- {evo_objects-0.4.1 → evo_objects-0.4.3}/src/evo/objects/endpoints/api/data_api.py +0 -0
- {evo_objects-0.4.1 → evo_objects-0.4.3}/src/evo/objects/endpoints/api/metadata_api.py +0 -0
- {evo_objects-0.4.1 → evo_objects-0.4.3}/src/evo/objects/endpoints/api/objects_api.py +0 -0
- {evo_objects-0.4.1 → evo_objects-0.4.3}/src/evo/objects/endpoints/api/stages_api.py +0 -0
- {evo_objects-0.4.1 → evo_objects-0.4.3}/src/evo/objects/endpoints/models.py +0 -0
- {evo_objects-0.4.1 → evo_objects-0.4.3}/src/evo/objects/exceptions.py +0 -0
- {evo_objects-0.4.1 → evo_objects-0.4.3}/src/evo/objects/io.py +0 -0
- {evo_objects-0.4.1 → evo_objects-0.4.3}/src/evo/objects/parquet/__init__.py +0 -0
- {evo_objects-0.4.1 → evo_objects-0.4.3}/src/evo/objects/parquet/loader.py +0 -0
- {evo_objects-0.4.1 → evo_objects-0.4.3}/src/evo/objects/py.typed +0 -0
- {evo_objects-0.4.1 → evo_objects-0.4.3}/src/evo/objects/typed/__init__.py +0 -0
- {evo_objects-0.4.1 → evo_objects-0.4.3}/src/evo/objects/typed/_data.py +0 -0
- {evo_objects-0.4.1 → evo_objects-0.4.3}/src/evo/objects/typed/_grid.py +0 -0
- {evo_objects-0.4.1 → evo_objects-0.4.3}/src/evo/objects/typed/_model.py +0 -0
- {evo_objects-0.4.1 → evo_objects-0.4.3}/src/evo/objects/typed/_utils.py +0 -0
- {evo_objects-0.4.1 → evo_objects-0.4.3}/src/evo/objects/typed/attributes.py +0 -0
- {evo_objects-0.4.1 → evo_objects-0.4.3}/src/evo/objects/typed/base.py +0 -0
- {evo_objects-0.4.1 → evo_objects-0.4.3}/src/evo/objects/typed/block_model_ref.py +0 -0
- {evo_objects-0.4.1 → evo_objects-0.4.3}/src/evo/objects/typed/exceptions.py +0 -0
- {evo_objects-0.4.1 → evo_objects-0.4.3}/src/evo/objects/typed/pointset.py +0 -0
- {evo_objects-0.4.1 → evo_objects-0.4.3}/src/evo/objects/typed/regular_grid.py +0 -0
- {evo_objects-0.4.1 → evo_objects-0.4.3}/src/evo/objects/typed/regular_masked_grid.py +0 -0
- {evo_objects-0.4.1 → evo_objects-0.4.3}/src/evo/objects/typed/spatial.py +0 -0
- {evo_objects-0.4.1 → evo_objects-0.4.3}/src/evo/objects/typed/tensor_grid.py +0 -0
- {evo_objects-0.4.1 → evo_objects-0.4.3}/src/evo/objects/typed/types.py +0 -0
- {evo_objects-0.4.1 → evo_objects-0.4.3}/src/evo/objects/typed/variogram.py +0 -0
- {evo_objects-0.4.1 → evo_objects-0.4.3}/src/evo/objects/utils/__init__.py +0 -0
- {evo_objects-0.4.1 → evo_objects-0.4.3}/src/evo/objects/utils/table_formats.py +0 -0
- {evo_objects-0.4.1 → evo_objects-0.4.3}/src/evo/objects/utils/types.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: evo-objects
|
|
3
|
-
Version: 0.4.
|
|
3
|
+
Version: 0.4.3
|
|
4
4
|
Summary: Python SDK for using the Seequent Evo Geoscience Object API
|
|
5
5
|
Project-URL: Source, https://github.com/SeequentEvo/evo-python-sdk
|
|
6
6
|
Project-URL: Tracker, https://github.com/SeequentEvo/evo-python-sdk/issues
|
|
@@ -67,6 +67,29 @@ def _iter_refs(target: Any, _key: str | None = None) -> Iterator[str]:
|
|
|
67
67
|
yield str(value)
|
|
68
68
|
|
|
69
69
|
|
|
70
|
+
def _get_schema_from_dataframe(dataframe: "pd.DataFrame") -> pa.Schema:
|
|
71
|
+
"""Get a normalized pyarrow schema from a pandas dataframe.
|
|
72
|
+
|
|
73
|
+
This hook centralizes dataframe-to-Arrow schema adjustments before the
|
|
74
|
+
dataframe is converted to a table. It currently performs these conversions:
|
|
75
|
+
- large_string -> string
|
|
76
|
+
- dictionary<*, large_string> -> dictionary<*, string>
|
|
77
|
+
|
|
78
|
+
:param dataframe: The pandas dataframe to get the schema from.
|
|
79
|
+
:return: A pyarrow schema with any configured type conversions applied.
|
|
80
|
+
"""
|
|
81
|
+
schema = pa.Schema.from_pandas(dataframe)
|
|
82
|
+
fields = []
|
|
83
|
+
for field in schema:
|
|
84
|
+
if pa.types.is_large_string(field.type):
|
|
85
|
+
fields.append(field.with_type(pa.string()))
|
|
86
|
+
elif pa.types.is_dictionary(field.type) and pa.types.is_large_string(field.type.value_type):
|
|
87
|
+
fields.append(field.with_type(pa.dictionary(field.type.index_type, pa.string())))
|
|
88
|
+
else:
|
|
89
|
+
fields.append(field)
|
|
90
|
+
return pa.schema(fields)
|
|
91
|
+
|
|
92
|
+
|
|
70
93
|
class ObjectDataClient:
|
|
71
94
|
"""An optional wrapper around data upload and download functionality for geoscience objects.
|
|
72
95
|
|
|
@@ -203,7 +226,7 @@ class ObjectDataClient:
|
|
|
203
226
|
columns_chunk_range = []
|
|
204
227
|
for column in table.itercolumns():
|
|
205
228
|
column = column.dictionary_encode()
|
|
206
|
-
if not
|
|
229
|
+
if not pa.types.is_string(column.type.value_type):
|
|
207
230
|
raise TableFormatError("Category columns must be of type string")
|
|
208
231
|
if not pa.types.is_int32(column.type.index_type):
|
|
209
232
|
# Currently, we only support int32 indices
|
|
@@ -231,8 +254,6 @@ class ObjectDataClient:
|
|
|
231
254
|
)
|
|
232
255
|
|
|
233
256
|
dictionary_values = all_chunks[0].dictionary
|
|
234
|
-
if pa.types.is_large_string(dictionary_values.type):
|
|
235
|
-
dictionary_values = pc.cast(dictionary_values, pa.string())
|
|
236
257
|
lookup = pa.Table.from_arrays(
|
|
237
258
|
[np.arange(len(dictionary_values), dtype=np.int32), dictionary_values], names=["key", "value"]
|
|
238
259
|
)
|
|
@@ -300,7 +321,9 @@ class ObjectDataClient:
|
|
|
300
321
|
no table formats are specified, raised when the table does not match any known format.
|
|
301
322
|
:raises StorageFileNotFoundError: If the destination does not exist or is not a directory.
|
|
302
323
|
"""
|
|
303
|
-
|
|
324
|
+
schema = _get_schema_from_dataframe(dataframe)
|
|
325
|
+
table = pa.Table.from_pandas(dataframe, schema)
|
|
326
|
+
return self.save_table(table, table_format=table_format)
|
|
304
327
|
|
|
305
328
|
async def upload_dataframe(
|
|
306
329
|
self,
|
|
@@ -322,7 +345,9 @@ class ObjectDataClient:
|
|
|
322
345
|
:raises TableFormatError: If the provided table does not match any of the specified formats. If
|
|
323
346
|
no table formats are specified, raised when the table does not match any known format.
|
|
324
347
|
"""
|
|
325
|
-
|
|
348
|
+
schema = _get_schema_from_dataframe(dataframe)
|
|
349
|
+
table = pa.Table.from_pandas(dataframe, schema)
|
|
350
|
+
table_info = await self.upload_table(table, table_format=table_format, fb=fb)
|
|
326
351
|
return table_info
|
|
327
352
|
|
|
328
353
|
async def upload_category_dataframe(self, dataframe: pd.DataFrame, fb: IFeedback = NoFeedback) -> CategoryInfo:
|
|
@@ -342,7 +367,9 @@ class ObjectDataClient:
|
|
|
342
367
|
:raises TableFormatError: If the table isn't a valid category table, or if the number of categories exceeds
|
|
343
368
|
what int32 type can represent.
|
|
344
369
|
"""
|
|
345
|
-
|
|
370
|
+
schema = _get_schema_from_dataframe(dataframe)
|
|
371
|
+
table = pa.Table.from_pandas(dataframe, schema)
|
|
372
|
+
category_info = await self.upload_category_table(table, fb=fb)
|
|
346
373
|
return category_info
|
|
347
374
|
|
|
348
375
|
async def download_dataframe(
|
|
@@ -64,7 +64,7 @@ class _ColumnFormat:
|
|
|
64
64
|
return pa.int64()
|
|
65
65
|
case "bool":
|
|
66
66
|
return pa.bool_()
|
|
67
|
-
case "string"
|
|
67
|
+
case "string":
|
|
68
68
|
return pa.string()
|
|
69
69
|
case "timestamp":
|
|
70
70
|
return pa.timestamp("us", tz="UTC")
|
|
@@ -88,7 +88,7 @@ class _ColumnFormat:
|
|
|
88
88
|
return "int64"
|
|
89
89
|
case "bool":
|
|
90
90
|
return "bool"
|
|
91
|
-
case "string"
|
|
91
|
+
case "string":
|
|
92
92
|
return "string"
|
|
93
93
|
case "timestamp[us, tz=UTC]":
|
|
94
94
|
return "timestamp"
|
|
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
|
|
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
|
|
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
|