-
Notifications
You must be signed in to change notification settings - Fork 200
Expand file tree
/
Copy path__init__.py
More file actions
230 lines (217 loc) · 5.44 KB
/
Copy path__init__.py
File metadata and controls
230 lines (217 loc) · 5.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright the Vortex contributors
import importlib
import importlib.metadata
import importlib.util
from . import _lib, arrays, dataset, expr, file, io, ray, registry, scan
from ._lib.arrays import ( # pyright: ignore[reportMissingModuleSource]
AlpArray,
AlpRdArray,
BoolArray,
ByteBoolArray,
ChunkedArray,
ConstantArray,
DateTimePartsArray,
# DecimalArray # TODO(connor): Is this missing a `DecimalArray`?
DictArray,
ExtensionArray,
FastLanesBitPackedArray,
FastLanesDeltaArray,
FastLanesFoRArray,
FixedSizeListArray,
FsstArray,
ListArray,
NullArray,
PrimitiveArray,
RunEndArray,
SequenceArray,
SparseArray,
StructArray,
VarBinArray,
VarBinViewArray,
ZigZagArray,
)
from ._lib.compress import compress # pyright: ignore[reportMissingModuleSource]
from ._lib.dtype import ( # pyright: ignore[reportMissingModuleSource]
BinaryDType,
BoolDType,
DecimalDType,
DType,
ExtensionDType,
FixedSizeListDType,
ListDType,
NullDType,
PrimitiveDType,
PType,
StructDType,
Utf8DType,
binary,
bool_,
date,
decimal,
fixed_size_list,
float_,
int_,
list_,
null,
struct,
time,
timestamp,
uint,
utf8,
)
from ._lib.iter import ArrayIterator # pyright: ignore[reportMissingModuleSource]
from ._lib.runtime import ( # pyright: ignore[reportMissingModuleSource]
set_worker_threads,
worker_threads,
)
from ._lib.scalar import ( # pyright: ignore[reportMissingModuleSource]
BinaryScalar,
BoolScalar,
# TODO(connor): Is this missing a `DecimalScalar`?
ExtensionScalar,
ListScalar,
NullScalar,
PrimitiveScalar,
Scalar,
StructScalar,
Utf8Scalar,
scalar,
)
from ._lib.serde import ArrayContext, SerializedArray # pyright: ignore[reportMissingModuleSource]
from .arrays import (
Array,
PyArray,
_unpickle_array, # pyright: ignore[reportPrivateUsage]
array,
)
from .file import VortexFile, open
from .scan import RepeatedScan
assert _lib, "Ensure we eagerly import the Vortex native library"
# Resolve the installed distribution version so it is available as vortex.__version__.
__version__ = "unknown"
try:
# Try to read the installed distribution version for the Python package name.
__version__ = importlib.metadata.version("vortex-data")
except importlib.metadata.PackageNotFoundError:
# If the distribution is not installed, keep the unknown fallback.
pass
def cuda_extension_installed() -> bool:
"""Return whether the optional Vortex CUDA extension package is importable.
The base ``vortex-data`` wheel is CPU-only. Optional CUDA functionality is
provided by the separate ``vortex-data-cuda`` extension package. This returns
``True`` when the ``vortex_cuda`` import package can be found in the current
environment, which is what ``vortex-data[cuda]`` installs.
This does not probe the CUDA driver or attached devices, and it does not
imply that any particular GPU interop API is available. After installing the
extension package, use ``vortex_cuda.cuda_available()`` to check whether CUDA
is usable at runtime.
"""
return importlib.util.find_spec("vortex_cuda") is not None
def __getattr__(name: str):
# `datasets` is exposed lazily and deliberately kept out of __all__: importing it pulls in the
# optional `vortex-data[hf]` dependencies, so it must not be imported by `from vortex import *`
# or by merely importing `vortex`.
if name == "datasets":
module = importlib.import_module(".datasets", __name__)
globals()[name] = module
return module
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
__all__ = [
# --- Modules ---
"arrays",
"dataset",
"expr",
"file",
"scan",
"io",
"registry",
"ray",
# --- Objects and Functions ---
"array",
"compress",
"cuda_extension_installed",
# Arrays
"Array",
"PyArray",
# DTypes
"DType",
"PType",
"NullDType",
"BoolDType",
"DecimalDType",
"PrimitiveDType",
"Utf8DType",
"BinaryDType",
"StructDType",
"ListDType",
"FixedSizeListDType",
"ExtensionDType",
"null",
"bool_",
"decimal",
"int_",
"uint",
"float_",
"utf8",
"binary",
"struct",
"list_",
"fixed_size_list",
"date",
"time",
"timestamp",
# Encodings
"ConstantArray",
"ChunkedArray",
"NullArray",
"BoolArray",
"ByteBoolArray",
"PrimitiveArray",
"VarBinArray",
"VarBinViewArray",
"StructArray",
"ListArray",
"FixedSizeListArray",
"ExtensionArray",
"AlpArray",
"AlpRdArray",
"DateTimePartsArray",
"DictArray",
"FsstArray",
"RunEndArray",
"SequenceArray",
"SparseArray",
"ZigZagArray",
"FastLanesBitPackedArray",
"FastLanesDeltaArray",
"FastLanesFoRArray",
# Scalars
"scalar",
"Scalar",
"NullScalar",
"BoolScalar",
"PrimitiveScalar",
"Utf8Scalar",
"BinaryScalar",
"StructScalar",
"ListScalar",
"ExtensionScalar",
# Serde
"ArrayContext",
"SerializedArray",
# Pickle support
"_unpickle_array",
# File
"VortexFile",
"open",
# Iterator
"ArrayIterator",
# Scan
"RepeatedScan",
# Runtime
"set_worker_threads",
"worker_threads",
# Version
"__version__",
]