evo-blockmodels 0.0.1__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.
@@ -0,0 +1,24 @@
1
+ # IDE Settings
2
+ .idea/
3
+ .project
4
+ .pydevproject
5
+ .vscode/
6
+
7
+ # Distribution / Packaging
8
+ *.egg*
9
+ *.whl
10
+ __pycache__/
11
+ site/
12
+ build/
13
+
14
+ # Reporting
15
+ .coverage
16
+
17
+ # Environmnents
18
+ venv/
19
+ venv*/
20
+ .venv/
21
+ .env
22
+ .tox/
23
+
24
+ .DS_store
@@ -0,0 +1,190 @@
1
+ Copyright © 2025 Bentley Systems, Incorporated.
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+
7
+ http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ Unless required by applicable law or agreed to in writing, software
10
+ distributed under the License is distributed on an "AS IS" BASIS,
11
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ See the License for the specific language governing permissions and
13
+ limitations under the License.
14
+
15
+ Apache License
16
+ Version 2.0, January 2004
17
+ http://www.apache.org/licenses/
18
+
19
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
20
+
21
+ 1. Definitions.
22
+
23
+ "License" shall mean the terms and conditions for use, reproduction,
24
+ and distribution as defined by Sections 1 through 9 of this document.
25
+
26
+ "Licensor" shall mean the copyright owner or entity authorized by
27
+ the copyright owner that is granting the License.
28
+
29
+ "Legal Entity" shall mean the union of the acting entity and all
30
+ other entities that control, are controlled by, or are under common
31
+ control with that entity. For the purposes of this definition,
32
+ "control" means (i) the power, direct or indirect, to cause the
33
+ direction or management of such entity, whether by contract or
34
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
35
+ outstanding shares, or (iii) beneficial ownership of such entity.
36
+
37
+ "You" (or "Your") shall mean an individual or Legal Entity
38
+ exercising permissions granted by this License.
39
+
40
+ "Source" form shall mean the preferred form for making modifications,
41
+ including but not limited to software source code, documentation
42
+ source, and configuration files.
43
+
44
+ "Object" form shall mean any form resulting from mechanical
45
+ transformation or translation of a Source form, including but
46
+ not limited to compiled object code, generated documentation,
47
+ and conversions to other media types.
48
+
49
+ "Work" shall mean the work of authorship, whether in Source or
50
+ Object form, made available under the License, as indicated by a
51
+ copyright notice that is included in or attached to the work
52
+ (an example is provided in the Appendix below).
53
+
54
+ "Derivative Works" shall mean any work, whether in Source or Object
55
+ form, that is based on (or derived from) the Work and for which the
56
+ editorial revisions, annotations, elaborations, or other modifications
57
+ represent, as a whole, an original work of authorship. For the purposes
58
+ of this License, Derivative Works shall not include works that remain
59
+ separable from, or merely link (or bind by name) to the interfaces of,
60
+ the Work and Derivative Works thereof.
61
+
62
+ "Contribution" shall mean any work of authorship, including
63
+ the original version of the Work and any modifications or additions
64
+ to that Work or Derivative Works thereof, that is intentionally
65
+ submitted to Licensor for inclusion in the Work by the copyright owner
66
+ or by an individual or Legal Entity authorized to submit on behalf of
67
+ the copyright owner. For the purposes of this definition, "submitted"
68
+ means any form of electronic, verbal, or written communication sent
69
+ to the Licensor or its representatives, including but not limited to
70
+ communication on electronic mailing lists, source code control systems,
71
+ and issue tracking systems that are managed by, or on behalf of, the
72
+ Licensor for the purpose of discussing and improving the Work, but
73
+ excluding communication that is conspicuously marked or otherwise
74
+ designated in writing by the copyright owner as "Not a Contribution."
75
+
76
+ "Contributor" shall mean Licensor and any individual or Legal Entity
77
+ on behalf of whom a Contribution has been received by Licensor and
78
+ subsequently incorporated within the Work.
79
+
80
+ 2. Grant of Copyright License. Subject to the terms and conditions of
81
+ this License, each Contributor hereby grants to You a perpetual,
82
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
83
+ copyright license to reproduce, prepare Derivative Works of,
84
+ publicly display, publicly perform, sublicense, and distribute the
85
+ Work and such Derivative Works in Source or Object form.
86
+
87
+ 3. Grant of Patent License. Subject to the terms and conditions of
88
+ this License, each Contributor hereby grants to You a perpetual,
89
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
90
+ (except as stated in this section) patent license to make, have made,
91
+ use, offer to sell, sell, import, and otherwise transfer the Work,
92
+ where such license applies only to those patent claims licensable
93
+ by such Contributor that are necessarily infringed by their
94
+ Contribution(s) alone or by combination of their Contribution(s)
95
+ with the Work to which such Contribution(s) was submitted. If You
96
+ institute patent litigation against any entity (including a
97
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
98
+ or a Contribution incorporated within the Work constitutes direct
99
+ or contributory patent infringement, then any patent licenses
100
+ granted to You under this License for that Work shall terminate
101
+ as of the date such litigation is filed.
102
+
103
+ 4. Redistribution. You may reproduce and distribute copies of the
104
+ Work or Derivative Works thereof in any medium, with or without
105
+ modifications, and in Source or Object form, provided that You
106
+ meet the following conditions:
107
+
108
+ (a) You must give any other recipients of the Work or
109
+ Derivative Works a copy of this License; and
110
+
111
+ (b) You must cause any modified files to carry prominent notices
112
+ stating that You changed the files; and
113
+
114
+ (c) You must retain, in the Source form of any Derivative Works
115
+ that You distribute, all copyright, patent, trademark, and
116
+ attribution notices from the Source form of the Work,
117
+ excluding those notices that do not pertain to any part of
118
+ the Derivative Works; and
119
+
120
+ (d) If the Work includes a "NOTICE" text file as part of its
121
+ distribution, then any Derivative Works that You distribute must
122
+ include a readable copy of the attribution notices contained
123
+ within such NOTICE file, excluding those notices that do not
124
+ pertain to any part of the Derivative Works, in at least one
125
+ of the following places: within a NOTICE text file distributed
126
+ as part of the Derivative Works; within the Source form or
127
+ documentation, if provided along with the Derivative Works; or,
128
+ within a display generated by the Derivative Works, if and
129
+ wherever such third-party notices normally appear. The contents
130
+ of the NOTICE file are for informational purposes only and
131
+ do not modify the License. You may add Your own attribution
132
+ notices within Derivative Works that You distribute, alongside
133
+ or as an addendum to the NOTICE text from the Work, provided
134
+ that such additional attribution notices cannot be construed
135
+ as modifying the License.
136
+
137
+ You may add Your own copyright statement to Your modifications and
138
+ may provide additional or different license terms and conditions
139
+ for use, reproduction, or distribution of Your modifications, or
140
+ for any such Derivative Works as a whole, provided Your use,
141
+ reproduction, and distribution of the Work otherwise complies with
142
+ the conditions stated in this License.
143
+
144
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
145
+ any Contribution intentionally submitted for inclusion in the Work
146
+ by You to the Licensor shall be under the terms and conditions of
147
+ this License, without any additional terms or conditions.
148
+ Notwithstanding the above, nothing herein shall supersede or modify
149
+ the terms of any separate license agreement you may have executed
150
+ with Licensor regarding such Contributions.
151
+
152
+ 6. Trademarks. This License does not grant permission to use the trade
153
+ names, trademarks, service marks, or product names of the Licensor,
154
+ except as required for reasonable and customary use in describing the
155
+ origin of the Work and reproducing the content of the NOTICE file.
156
+
157
+ 7. Disclaimer of Warranty. Unless required by applicable law or
158
+ agreed to in writing, Licensor provides the Work (and each
159
+ Contributor provides its Contributions) on an "AS IS" BASIS,
160
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
161
+ implied, including, without limitation, any warranties or conditions
162
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
163
+ PARTICULAR PURPOSE. You are solely responsible for determining the
164
+ appropriateness of using or redistributing the Work and assume any
165
+ risks associated with Your exercise of permissions under this License.
166
+
167
+ 8. Limitation of Liability. In no event and under no legal theory,
168
+ whether in tort (including negligence), contract, or otherwise,
169
+ unless required by applicable law (such as deliberate and grossly
170
+ negligent acts) or agreed to in writing, shall any Contributor be
171
+ liable to You for damages, including any direct, indirect, special,
172
+ incidental, or consequential damages of any character arising as a
173
+ result of this License or out of the use or inability to use the
174
+ Work (including but not limited to damages for loss of goodwill,
175
+ work stoppage, computer failure or malfunction, or any and all
176
+ other commercial damages or losses), even if such Contributor
177
+ has been advised of the possibility of such damages.
178
+
179
+ 9. Accepting Warranty or Additional Liability. While redistributing
180
+ the Work or Derivative Works thereof, You may choose to offer,
181
+ and charge a fee for, acceptance of support, warranty, indemnity,
182
+ or other liability obligations and/or rights consistent with this
183
+ License. However, in accepting such obligations, You may act only
184
+ on Your own behalf and on Your sole responsibility, not on behalf
185
+ of any other Contributor, and only if You agree to indemnify,
186
+ defend, and hold each Contributor harmless for any liability
187
+ incurred by, or claims asserted against, such Contributor by reason
188
+ of your accepting any such warranty or additional liability.
189
+
190
+ END OF TERMS AND CONDITIONS
@@ -0,0 +1,93 @@
1
+ Metadata-Version: 2.4
2
+ Name: evo-blockmodels
3
+ Version: 0.0.1
4
+ Summary: Python SDK for using the Seequent Evo Geoscience Block Model API
5
+ Project-URL: Source, https://github.com/SeequentEvo/evo-python-sdk
6
+ Project-URL: Tracker, https://github.com/SeequentEvo/evo-python-sdk/issues
7
+ Project-URL: Homepage, https://www.seequent.com/
8
+ Project-URL: Documentation, https://developer.seequent.com/
9
+ Author-email: Seequent <support@seequent.com>
10
+ License-File: LICENSE.md
11
+ Requires-Python: >=3.10
12
+ Requires-Dist: evo-sdk-common>=0.1.0
13
+ Requires-Dist: pydantic<3,>=2
14
+ Provides-Extra: aiohttp
15
+ Requires-Dist: evo-sdk-common[aiohttp]>=0.1.0; extra == 'aiohttp'
16
+ Provides-Extra: notebooks
17
+ Requires-Dist: evo-sdk-common[notebooks]>=0.1.0; extra == 'notebooks'
18
+ Provides-Extra: pyarrow
19
+ Requires-Dist: pyarrow>=19.0.0; extra == 'pyarrow'
20
+ Description-Content-Type: text/markdown
21
+
22
+ <p align="center"><a href="https://seequent.com" target="_blank"><picture><source media="(prefers-color-scheme: dark)" srcset="https://developer.seequent.com/img/seequent-logo-dark.svg" alt="Seequent logo" width="400" /><img src="https://developer.seequent.com/img/seequent-logo.svg" alt="Seequent logo" width="400" /></picture></a></p>
23
+ <p align="center">
24
+ <a href="https://pypi.org/project/evo-blockmodels/"><img alt="PyPI - Version" src="https://img.shields.io/pypi/v/evo-blockmodels" /></a>
25
+ <a href="https://github.com/SeequentEvo/evo-python-sdk/actions/workflows/run-all-tests.yaml"><img src="https://github.com/SeequentEvo/evo-python-sdk/actions/workflows/run-all-tests.yaml/badge.svg" alt="" /></a>
26
+ </p>
27
+ <p align="center">
28
+ <a href="https://developer.seequent.com/" target="_blank">Seequent Developer Portal</a>
29
+ &bull; <a href="https://community.seequent.com/group/19-evo" target="_blank">Seequent Community</a>
30
+ &bull; <a href="https://seequent.com" target="_blank">Seequent website</a>
31
+ </p>
32
+
33
+ # Evo Block Model API Client
34
+
35
+ The Block Model API provides the ability to manage and report on block models in your Evo workspaces. Enable your
36
+ product with Evo connected workflows by integrating with the Seequent Block Model API.
37
+
38
+ The Block Model API supports a range of sub-blocking options, and both full and partial updates to block models,
39
+ including updates of specified columns and/or sub-volumes. Block models are versioned, and the service supports
40
+ reporting on the material content of current or previous versions, and comparing the content between versions of
41
+ a block model.
42
+
43
+ ## Pre-requisites
44
+
45
+ * Python ^3.10
46
+ * An [application registered in Bentley](https://developer.bentley.com/register/?product=seequent-evo)
47
+
48
+ ## Installation
49
+
50
+ ```shell
51
+ pip install evo-blockmodels
52
+ ```
53
+
54
+ ## Usage
55
+
56
+ See [the evo-sdk-common documentation](https://github.com/SeequentEvo/evo-python-sdk/blob/main/packages/evo-sdk-common/README.md)
57
+ for information on how to authenticate, then select the organisation, hub and workspace that you would like to use.
58
+
59
+ ### Interacting with the Geoscience Block Model API
60
+
61
+ To get up and running quickly with the Evo Block Models SDK, start by configuring your
62
+ [environment and API connector](https://github.com/SeequentEvo/evo-python-sdk/blob/main/packages/evo-sdk-common/docs/quickstart.md).
63
+
64
+ ```python
65
+ from evo.blockmodels import BlockModelAPIClient
66
+
67
+ service_client = BlockModelAPIClient(environment, connector)
68
+ service_health = await service_client.get_service_health()
69
+ service_health.raise_for_status()
70
+ ```
71
+
72
+ For some interactive Jupyter notebook examples, see the [examples folder](https://github.com/SeequentEvo/evo-python-sdk/tree/main/packages/evo-blockmodels/docs/examples).
73
+
74
+ ## Contributing
75
+
76
+ For instructions on contributing to the development of this library, please refer to the [evo-python-sdk documentation](https://github.com/seequentevo/evo-python-sdk).
77
+
78
+ ## License
79
+
80
+ The Python SDK for Evo is open source and licensed under the [Apache 2.0 license.](https://github.com/SeequentEvo/evo-python-sdk/tree/main/packages/evo-blockmodels/./LICENSE.md).
81
+
82
+ Copyright © 2025 Bentley Systems, Incorporated.
83
+
84
+ Licensed under the Apache License, Version 2.0 (the "License").
85
+ You may obtain a copy of the License at
86
+
87
+ http://www.apache.org/licenses/LICENSE-2.0
88
+
89
+ Unless required by applicable law or agreed to in writing, software
90
+ distributed under the License is distributed on an "AS IS" BASIS,
91
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
92
+ See the License for the specific language governing permissions and
93
+ limitations under the License.
@@ -0,0 +1,74 @@
1
+ [project]
2
+ name = "evo-blockmodels"
3
+ description = "Python SDK for using the Seequent Evo Geoscience Block Model API"
4
+ version = "0.0.1"
5
+ requires-python = ">=3.10"
6
+ license-files = ["LICENSE.md"]
7
+ dynamic = ["readme"]
8
+ authors = [
9
+ { name = "Seequent", email = "support@seequent.com" }
10
+ ]
11
+
12
+ dependencies = [
13
+ "evo-sdk-common>=0.1.0",
14
+ "pydantic>=2,<3",
15
+ ]
16
+
17
+ [project.urls]
18
+ Source = "https://github.com/SeequentEvo/evo-python-sdk"
19
+ Tracker = "https://github.com/SeequentEvo/evo-python-sdk/issues"
20
+ Homepage = "https://www.seequent.com/"
21
+ Documentation = "https://developer.seequent.com/"
22
+
23
+ [project.optional-dependencies]
24
+ pyarrow = ["pyarrow>=19.0.0"]
25
+ aiohttp = ["evo-sdk-common[aiohttp]>=0.1.0"]
26
+ notebooks = ["evo-sdk-common[notebooks]>=0.1.0"]
27
+
28
+ [dependency-groups]
29
+ # Dev dependencies. The version is left unspecified so the latest is installed.
30
+ test = [
31
+ "evo-blockmodels[aiohttp,pyarrow]",
32
+ "parameterized==0.9.0",
33
+ "pytest",
34
+ ]
35
+ dev = [
36
+ "evo-blockmodels[notebooks]",
37
+ "bumpver",
38
+ "coverage[toml]",
39
+ "ruff",
40
+ {include-group = "test"}
41
+ ]
42
+ notebooks = [
43
+ "evo-blockmodels[aiohttp,notebooks,pyarrow]",
44
+ "jupyter",
45
+ ]
46
+
47
+ [tool.ruff]
48
+ src = ["src", "tests"]
49
+ line-length = 120
50
+
51
+ [tool.ruff.lint]
52
+ extend-select = ["I", "RUF022"]
53
+
54
+ [build-system]
55
+ requires = ["hatchling", "hatch-fancy-pypi-readme"]
56
+ build-backend = "hatchling.build"
57
+
58
+ [tool.hatch.build.targets.sdist]
59
+ include = ["/src"]
60
+
61
+ [tool.hatch.build.targets.wheel]
62
+ packages = ["src/evo"]
63
+
64
+ [tool.hatch.metadata.hooks.fancy-pypi-readme]
65
+ content-type = "text/markdown"
66
+
67
+ [[tool.hatch.metadata.hooks.fancy-pypi-readme.fragments]]
68
+ path = "README.md"
69
+
70
+ [[tool.hatch.metadata.hooks.fancy-pypi-readme.substitutions]]
71
+ # Literal TOML strings (single quotes) need no escaping of backslashes.
72
+ # Converts relative links to absolute links in PyPI
73
+ pattern = '\[(.+?)\]\(((?!https?://)\S+?)\)'
74
+ replacement = '[\1](https://github.com/SeequentEvo/evo-python-sdk/tree/main/packages/$HFPR_PACKAGE_NAME/\g<2>)'
@@ -0,0 +1,16 @@
1
+ # Copyright © 2025 Bentley Systems, Incorporated
2
+ # Licensed under the Apache License, Version 2.0 (the "License");
3
+ # you may not use this file except in compliance with the License.
4
+ # You may obtain a copy of the License at
5
+ # http://www.apache.org/licenses/LICENSE-2.0
6
+ # Unless required by applicable law or agreed to in writing, software
7
+ # distributed under the License is distributed on an "AS IS" BASIS,
8
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9
+ # See the License for the specific language governing permissions and
10
+ # limitations under the License.
11
+
12
+ from .client import BlockModelAPIClient
13
+
14
+ __all__ = [
15
+ "BlockModelAPIClient",
16
+ ]
@@ -0,0 +1,21 @@
1
+ # Copyright © 2025 Bentley Systems, Incorporated
2
+ # Licensed under the Apache License, Version 2.0 (the "License");
3
+ # you may not use this file except in compliance with the License.
4
+ # You may obtain a copy of the License at
5
+ # http://www.apache.org/licenses/LICENSE-2.0
6
+ # Unless required by applicable law or agreed to in writing, software
7
+ # distributed under the License is distributed on an "AS IS" BASIS,
8
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9
+ # See the License for the specific language governing permissions and
10
+ # limitations under the License.
11
+
12
+ from pydantic import BaseModel, ConfigDict
13
+
14
+
15
+ class CustomBaseModel(BaseModel):
16
+ """Custom base model for providing a global configuration to generated models."""
17
+
18
+ model_config = ConfigDict(
19
+ extra="allow",
20
+ protected_namespaces=(),
21
+ )
@@ -0,0 +1,82 @@
1
+ # Copyright © 2025 Bentley Systems, Incorporated
2
+ # Licensed under the Apache License, Version 2.0 (the "License");
3
+ # you may not use this file except in compliance with the License.
4
+ # You may obtain a copy of the License at
5
+ # http://www.apache.org/licenses/LICENSE-2.0
6
+ # Unless required by applicable law or agreed to in writing, software
7
+ # distributed under the License is distributed on an "AS IS" BASIS,
8
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9
+ # See the License for the specific language governing permissions and
10
+ # limitations under the License.
11
+
12
+ from __future__ import annotations
13
+
14
+ from typing import Protocol
15
+
16
+ # `evo-blockmodels` uses protocols for annotating some pyarrow types, because:
17
+ # - pyarrow is optional, but type annotations are not.
18
+ # - pyarrow has poor type checker support.
19
+ #
20
+ # These protocols should be treated as aliases for the corresponding pyarrow types.
21
+ # Any required interfaces from the corresponding pyarrow types should be added to these protocols as needed.
22
+
23
+
24
+ class DataType(Protocol):
25
+ """Pyarrow data type.
26
+
27
+ https://arrow.apache.org/docs/python/generated/pyarrow.DataType.html
28
+ """
29
+
30
+ ...
31
+
32
+
33
+ class Schema(Protocol):
34
+ """Pyarrow schema.
35
+
36
+ https://arrow.apache.org/docs/python/generated/pyarrow.Schema.html
37
+ """
38
+
39
+ @property
40
+ def names(self) -> list[str]:
41
+ """The schema's field names."""
42
+ ...
43
+
44
+ @property
45
+ def types(self) -> list[DataType]:
46
+ """The schema's field types."""
47
+ ...
48
+
49
+
50
+ class Table(Protocol):
51
+ """Pyarrow table.
52
+
53
+ https://arrow.apache.org/docs/python/generated/pyarrow.Table.html
54
+ """
55
+
56
+ @property
57
+ def schema(self) -> Schema:
58
+ """Schema of the table and its columns."""
59
+ ...
60
+
61
+ @property
62
+ def num_columns(self) -> int:
63
+ """Number of columns in this table."""
64
+ ...
65
+
66
+ @property
67
+ def num_rows(self) -> int:
68
+ """Number of rows in this table.
69
+
70
+ Due to the definition of a table, all columns have the same number of rows.
71
+ """
72
+ ...
73
+
74
+ def to_pandas(self) -> DataFrame:
75
+ """Convert to a pandas-compatible NumPy array or DataFrame, as appropriate"""
76
+
77
+
78
+ class DataFrame(Protocol):
79
+ """Pandas DataFrame.
80
+
81
+ https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.html
82
+ """
@@ -0,0 +1,63 @@
1
+ # Copyright © 2025 Bentley Systems, Incorporated
2
+ # Licensed under the Apache License, Version 2.0 (the "License");
3
+ # you may not use this file except in compliance with the License.
4
+ # You may obtain a copy of the License at
5
+ # http://www.apache.org/licenses/LICENSE-2.0
6
+ # Unless required by applicable law or agreed to in writing, software
7
+ # distributed under the License is distributed on an "AS IS" BASIS,
8
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9
+ # See the License for the specific language governing permissions and
10
+ # limitations under the License.
11
+
12
+ from __future__ import annotations
13
+
14
+ from typing import TypeVar
15
+ from uuid import UUID
16
+
17
+ from ._types import DataType
18
+ from .endpoints import models
19
+ from .endpoints.models import JobResponse
20
+ from .exceptions import UnknownJobPayload
21
+
22
+ T = TypeVar("T")
23
+
24
+
25
+ def extract_payload(job_id: UUID, job_response: JobResponse, payload_type: type[T]) -> T:
26
+ payload = job_response.payload
27
+ if isinstance(payload, payload_type):
28
+ return payload
29
+ else:
30
+ raise UnknownJobPayload(
31
+ job_id, f"Expected {payload_type.__name__} for job payload, got {type(payload).__name__} instead"
32
+ )
33
+
34
+
35
+ try:
36
+ import pyarrow
37
+ except ImportError:
38
+ data_type_mapping = {}
39
+ else:
40
+ data_type_mapping = {
41
+ pyarrow.bool_(): models.DataType.Boolean,
42
+ pyarrow.int8(): models.DataType.Int8,
43
+ pyarrow.int16(): models.DataType.Int16,
44
+ pyarrow.int32(): models.DataType.Int32,
45
+ pyarrow.int64(): models.DataType.Int64,
46
+ pyarrow.uint8(): models.DataType.UInt8,
47
+ pyarrow.uint16(): models.DataType.UInt16,
48
+ pyarrow.uint32(): models.DataType.UInt32,
49
+ pyarrow.uint64(): models.DataType.UInt64,
50
+ pyarrow.float16(): models.DataType.Float16,
51
+ pyarrow.float32(): models.DataType.Float32,
52
+ pyarrow.float64(): models.DataType.Float64,
53
+ pyarrow.utf8(): models.DataType.Utf8,
54
+ pyarrow.date32(): models.DataType.Date32,
55
+ pyarrow.timestamp("us", tz="UTC"): models.DataType.Timestamp,
56
+ }
57
+
58
+
59
+ def convert_dtype(data_type: DataType) -> models.DataType:
60
+ try:
61
+ return data_type_mapping[data_type]
62
+ except KeyError:
63
+ raise ValueError(f"Unsupported data type: {data_type}")