pixeltable 0.2.18__py3-none-any.whl → 0.2.19__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.
Potentially problematic release.
This version of pixeltable might be problematic. Click here for more details.
- pixeltable/__init__.py +1 -1
- pixeltable/__version__.py +2 -2
- pixeltable/catalog/table.py +0 -1
- pixeltable/catalog/table_version.py +1 -1
- pixeltable/catalog/view.py +1 -1
- pixeltable/dataframe.py +1 -1
- pixeltable/env.py +34 -5
- pixeltable/exceptions.py +5 -1
- pixeltable/exec/component_iteration_node.py +1 -1
- pixeltable/exprs/__init__.py +1 -2
- pixeltable/exprs/expr.py +5 -6
- pixeltable/exprs/function_call.py +8 -10
- pixeltable/exprs/inline_expr.py +200 -0
- pixeltable/ext/functions/whisperx.py +2 -0
- pixeltable/ext/functions/yolox.py +5 -3
- pixeltable/functions/huggingface.py +89 -12
- pixeltable/functions/image.py +3 -3
- pixeltable/functions/together.py +15 -8
- pixeltable/functions/vision.py +43 -21
- pixeltable/functions/whisper.py +3 -0
- pixeltable/globals.py +5 -1
- pixeltable/metadata/__init__.py +1 -1
- pixeltable/metadata/converters/convert_18.py +1 -1
- pixeltable/metadata/converters/convert_20.py +56 -0
- pixeltable/metadata/converters/util.py +29 -4
- pixeltable/metadata/notes.py +1 -0
- pixeltable/tool/create_test_db_dump.py +14 -3
- pixeltable/type_system.py +3 -1
- pixeltable-0.2.19.dist-info/LICENSE +201 -0
- {pixeltable-0.2.18.dist-info → pixeltable-0.2.19.dist-info}/METADATA +6 -4
- {pixeltable-0.2.18.dist-info → pixeltable-0.2.19.dist-info}/RECORD +33 -33
- pixeltable/exprs/inline_array.py +0 -117
- pixeltable/exprs/inline_dict.py +0 -104
- pixeltable-0.2.18.dist-info/LICENSE +0 -18
- {pixeltable-0.2.18.dist-info → pixeltable-0.2.19.dist-info}/WHEEL +0 -0
- {pixeltable-0.2.18.dist-info → pixeltable-0.2.19.dist-info}/entry_points.txt +0 -0
pixeltable/functions/together.py
CHANGED
|
@@ -7,10 +7,11 @@ the [Working with Together AI](https://pixeltable.readme.io/docs/together-ai) tu
|
|
|
7
7
|
|
|
8
8
|
import base64
|
|
9
9
|
import io
|
|
10
|
-
from typing import TYPE_CHECKING, Optional
|
|
10
|
+
from typing import TYPE_CHECKING, Callable, Optional
|
|
11
11
|
|
|
12
12
|
import numpy as np
|
|
13
13
|
import PIL.Image
|
|
14
|
+
import tenacity
|
|
14
15
|
|
|
15
16
|
import pixeltable as pxt
|
|
16
17
|
from pixeltable import env
|
|
@@ -24,7 +25,6 @@ if TYPE_CHECKING:
|
|
|
24
25
|
@env.register_client('together')
|
|
25
26
|
def _(api_key: str) -> 'together.Together':
|
|
26
27
|
import together
|
|
27
|
-
|
|
28
28
|
return together.Together(api_key=api_key)
|
|
29
29
|
|
|
30
30
|
|
|
@@ -32,6 +32,15 @@ def _together_client() -> 'together.Together':
|
|
|
32
32
|
return env.Env.get().get_client('together')
|
|
33
33
|
|
|
34
34
|
|
|
35
|
+
def _retry(fn: Callable) -> Callable:
|
|
36
|
+
import together
|
|
37
|
+
return tenacity.retry(
|
|
38
|
+
retry=tenacity.retry_if_exception_type(together.error.RateLimitError),
|
|
39
|
+
wait=tenacity.wait_random_exponential(multiplier=1, max=60),
|
|
40
|
+
stop=tenacity.stop_after_attempt(20),
|
|
41
|
+
)(fn)
|
|
42
|
+
|
|
43
|
+
|
|
35
44
|
@pxt.udf
|
|
36
45
|
def completions(
|
|
37
46
|
prompt: str,
|
|
@@ -74,8 +83,7 @@ def completions(
|
|
|
74
83
|
>>> tbl['response'] = completions(tbl.prompt, model='mistralai/Mixtral-8x7B-v0.1')
|
|
75
84
|
"""
|
|
76
85
|
return (
|
|
77
|
-
_together_client()
|
|
78
|
-
.completions.create(
|
|
86
|
+
_retry(_together_client().completions.create)(
|
|
79
87
|
prompt=prompt,
|
|
80
88
|
model=model,
|
|
81
89
|
max_tokens=max_tokens,
|
|
@@ -139,8 +147,7 @@ def chat_completions(
|
|
|
139
147
|
... tbl['response'] = chat_completions(messages, model='mistralai/Mixtral-8x7B-v0.1')
|
|
140
148
|
"""
|
|
141
149
|
return (
|
|
142
|
-
_together_client()
|
|
143
|
-
.chat.completions.create(
|
|
150
|
+
_retry(_together_client().chat.completions.create)(
|
|
144
151
|
messages=messages,
|
|
145
152
|
model=model,
|
|
146
153
|
max_tokens=max_tokens,
|
|
@@ -198,7 +205,7 @@ def embeddings(input: Batch[str], *, model: str) -> Batch[np.ndarray]:
|
|
|
198
205
|
|
|
199
206
|
>>> tbl['response'] = embeddings(tbl.text, model='togethercomputer/m2-bert-80M-8k-retrieval')
|
|
200
207
|
"""
|
|
201
|
-
result = _together_client().embeddings.create(input=input, model=model)
|
|
208
|
+
result = _retry(_together_client().embeddings.create)(input=input, model=model)
|
|
202
209
|
return [np.array(data.embedding, dtype=np.float64) for data in result.data]
|
|
203
210
|
|
|
204
211
|
|
|
@@ -248,7 +255,7 @@ def image_generations(
|
|
|
248
255
|
>>> tbl['response'] = image_generations(tbl.prompt, model='runwayml/stable-diffusion-v1-5')
|
|
249
256
|
"""
|
|
250
257
|
# TODO(aaron-siegel): Decompose CPU/GPU ops into separate functions
|
|
251
|
-
result = _together_client().images.generate(
|
|
258
|
+
result = _retry(_together_client().images.generate)(
|
|
252
259
|
prompt=prompt, model=model, steps=steps, seed=seed, height=height, width=width, negative_prompt=negative_prompt
|
|
253
260
|
)
|
|
254
261
|
b64_str = result.data[0].b64_json
|
pixeltable/functions/vision.py
CHANGED
|
@@ -19,12 +19,9 @@ from typing import Any, Optional, Union
|
|
|
19
19
|
import numpy as np
|
|
20
20
|
import PIL.Image
|
|
21
21
|
|
|
22
|
-
import pixeltable
|
|
23
|
-
import pixeltable.type_system as ts
|
|
22
|
+
import pixeltable as pxt
|
|
24
23
|
from pixeltable.utils.code import local_public_names
|
|
25
24
|
|
|
26
|
-
# TODO: figure out a better submodule structure
|
|
27
|
-
|
|
28
25
|
|
|
29
26
|
# the following function has been adapted from MMEval
|
|
30
27
|
# (sources at https://github.com/open-mmlab/mmeval)
|
|
@@ -161,25 +158,41 @@ def __calculate_image_tpfp(
|
|
|
161
158
|
return tp, fp
|
|
162
159
|
|
|
163
160
|
|
|
164
|
-
@
|
|
165
|
-
return_type=ts.JsonType(nullable=False),
|
|
166
|
-
param_types=[
|
|
167
|
-
ts.JsonType(nullable=False),
|
|
168
|
-
ts.JsonType(nullable=False),
|
|
169
|
-
ts.JsonType(nullable=False),
|
|
170
|
-
ts.JsonType(nullable=False),
|
|
171
|
-
ts.JsonType(nullable=False),
|
|
172
|
-
],
|
|
173
|
-
)
|
|
161
|
+
@pxt.udf
|
|
174
162
|
def eval_detections(
|
|
175
163
|
pred_bboxes: list[list[int]],
|
|
176
164
|
pred_labels: list[int],
|
|
177
165
|
pred_scores: list[float],
|
|
178
166
|
gt_bboxes: list[list[int]],
|
|
179
167
|
gt_labels: list[int],
|
|
168
|
+
min_iou: float = 0.5,
|
|
180
169
|
) -> list[dict]:
|
|
181
170
|
"""
|
|
182
171
|
Evaluates the performance of a set of predicted bounding boxes against a set of ground truth bounding boxes.
|
|
172
|
+
|
|
173
|
+
Args:
|
|
174
|
+
pred_bboxes: List of predicted bounding boxes, each represented as [xmin, ymin, xmax, ymax].
|
|
175
|
+
pred_labels: List of predicted labels.
|
|
176
|
+
pred_scores: List of predicted scores.
|
|
177
|
+
gt_bboxes: List of ground truth bounding boxes, each represented as [xmin, ymin, xmax, ymax].
|
|
178
|
+
gt_labels: List of ground truth labels.
|
|
179
|
+
min_iou: Minimum intersection-over-union (IoU) threshold for a predicted bounding box to be
|
|
180
|
+
considered a true positive.
|
|
181
|
+
|
|
182
|
+
Returns:
|
|
183
|
+
A list of dictionaries, one per label class, with the following structure:
|
|
184
|
+
```python
|
|
185
|
+
{
|
|
186
|
+
'min_iou': float, # The value of `min_iou` used for the detections
|
|
187
|
+
'class': int, # The label class
|
|
188
|
+
'tp': list[int], # List of 1's and 0's indicating true positives for each
|
|
189
|
+
# predicted bounding box of this class
|
|
190
|
+
'fp': list[int], # List of 1's and 0's indicating false positives for each
|
|
191
|
+
# predicted bounding box of this class; `fp[n] == 1 - tp[n]`
|
|
192
|
+
'scores': list[float], # List of predicted scores for each bounding box of this class
|
|
193
|
+
'num_gts': int, # Number of ground truth bounding boxes of this class
|
|
194
|
+
}
|
|
195
|
+
```
|
|
183
196
|
"""
|
|
184
197
|
class_idxs = list(set(pred_labels + gt_labels))
|
|
185
198
|
result: list[dict] = []
|
|
@@ -192,11 +205,11 @@ def eval_detections(
|
|
|
192
205
|
pred_filter = pred_classes_arr == class_idx
|
|
193
206
|
gt_filter = gt_classes_arr == class_idx
|
|
194
207
|
class_pred_scores = pred_scores_arr[pred_filter]
|
|
195
|
-
tp, fp = __calculate_image_tpfp(pred_bboxes_arr[pred_filter], class_pred_scores, gt_bboxes_arr[gt_filter],
|
|
208
|
+
tp, fp = __calculate_image_tpfp(pred_bboxes_arr[pred_filter], class_pred_scores, gt_bboxes_arr[gt_filter], min_iou)
|
|
196
209
|
ordered_class_pred_scores = -np.sort(-class_pred_scores)
|
|
197
210
|
result.append(
|
|
198
211
|
{
|
|
199
|
-
'min_iou':
|
|
212
|
+
'min_iou': min_iou,
|
|
200
213
|
'class': class_idx,
|
|
201
214
|
'tp': tp.tolist(),
|
|
202
215
|
'fp': fp.tolist(),
|
|
@@ -207,11 +220,20 @@ def eval_detections(
|
|
|
207
220
|
return result
|
|
208
221
|
|
|
209
222
|
|
|
210
|
-
@
|
|
211
|
-
class mean_ap(
|
|
223
|
+
@pxt.uda(update_types=[pxt.JsonType()], value_type=pxt.JsonType(), allows_std_agg=True, allows_window=False)
|
|
224
|
+
class mean_ap(pxt.Aggregator):
|
|
212
225
|
"""
|
|
213
226
|
Calculates the mean average precision (mAP) over
|
|
214
227
|
[`eval_detections()`][pixeltable.functions.vision.eval_detections] results.
|
|
228
|
+
|
|
229
|
+
__Parameters:__
|
|
230
|
+
|
|
231
|
+
- `eval_dicts` (list[dict]): List of dictionaries as returned by
|
|
232
|
+
[`eval_detections()`][pixeltable.functions.vision.eval_detections].
|
|
233
|
+
|
|
234
|
+
__Returns:__
|
|
235
|
+
|
|
236
|
+
- A `dict[int, float]` mapping each label class to an average precision (AP) value for that class.
|
|
215
237
|
"""
|
|
216
238
|
def __init__(self):
|
|
217
239
|
self.class_tpfp: dict[int, list[dict]] = defaultdict(list)
|
|
@@ -246,7 +268,7 @@ class mean_ap(func.Aggregator):
|
|
|
246
268
|
return result
|
|
247
269
|
|
|
248
270
|
|
|
249
|
-
def
|
|
271
|
+
def __create_label_colors(labels: list[Any]) -> dict[Any, str]:
|
|
250
272
|
"""
|
|
251
273
|
Create random colors for labels such that a particular label always gets the same color.
|
|
252
274
|
|
|
@@ -265,7 +287,7 @@ def _create_label_colors(labels: list[Any]) -> dict[Any, str]:
|
|
|
265
287
|
return result
|
|
266
288
|
|
|
267
289
|
|
|
268
|
-
@
|
|
290
|
+
@pxt.udf
|
|
269
291
|
def draw_bounding_boxes(
|
|
270
292
|
img: PIL.Image.Image,
|
|
271
293
|
boxes: list[list[int]],
|
|
@@ -324,7 +346,7 @@ def draw_bounding_boxes(
|
|
|
324
346
|
if color is not None:
|
|
325
347
|
box_colors = [color] * num_boxes
|
|
326
348
|
else:
|
|
327
|
-
label_colors =
|
|
349
|
+
label_colors = __create_label_colors(labels)
|
|
328
350
|
box_colors = [label_colors[label] for label in labels]
|
|
329
351
|
|
|
330
352
|
from PIL import ImageColor, ImageDraw, ImageFont
|
pixeltable/functions/whisper.py
CHANGED
|
@@ -9,6 +9,7 @@ first `pip install openai-whisper`.
|
|
|
9
9
|
from typing import TYPE_CHECKING, Optional
|
|
10
10
|
|
|
11
11
|
import pixeltable as pxt
|
|
12
|
+
from pixeltable.env import Env
|
|
12
13
|
|
|
13
14
|
if TYPE_CHECKING:
|
|
14
15
|
from whisper import Whisper # type: ignore[import-untyped]
|
|
@@ -71,6 +72,8 @@ def transcribe(
|
|
|
71
72
|
|
|
72
73
|
>>> tbl['result'] = transcribe(tbl.audio, model='base.en')
|
|
73
74
|
"""
|
|
75
|
+
Env.get().require_package('whisper')
|
|
76
|
+
Env.get().require_package('torch')
|
|
74
77
|
import torch
|
|
75
78
|
|
|
76
79
|
if decode_options is None:
|
pixeltable/globals.py
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import dataclasses
|
|
2
2
|
import logging
|
|
3
|
-
from typing import Any, Optional, Union
|
|
3
|
+
from typing import Any, Iterable, Optional, Union
|
|
4
4
|
from uuid import UUID
|
|
5
5
|
|
|
6
6
|
import pandas as pd
|
|
@@ -487,3 +487,7 @@ def configure_logging(
|
|
|
487
487
|
remove: comma-separated list of module names
|
|
488
488
|
"""
|
|
489
489
|
return Env.get().configure_logging(to_stdout=to_stdout, level=level, add=add, remove=remove)
|
|
490
|
+
|
|
491
|
+
|
|
492
|
+
def array(elements: Iterable) -> exprs.Expr:
|
|
493
|
+
return exprs.InlineArray(elements)
|
pixeltable/metadata/__init__.py
CHANGED
|
@@ -10,7 +10,7 @@ import sqlalchemy.orm as orm
|
|
|
10
10
|
from .schema import SystemInfo, SystemInfoMd
|
|
11
11
|
|
|
12
12
|
# current version of the metadata; this is incremented whenever the metadata schema changes
|
|
13
|
-
VERSION =
|
|
13
|
+
VERSION = 21
|
|
14
14
|
|
|
15
15
|
|
|
16
16
|
def create_system_info(engine: sql.engine.Engine) -> None:
|
|
@@ -13,7 +13,7 @@ def _(engine: sql.engine.Engine) -> None:
|
|
|
13
13
|
)
|
|
14
14
|
|
|
15
15
|
|
|
16
|
-
def __substitute_md(k:
|
|
16
|
+
def __substitute_md(k: Optional[str], v: Any) -> Optional[tuple[Optional[str], Any]]:
|
|
17
17
|
# Migrate a few changed function names
|
|
18
18
|
if k == 'path' and v == 'pixeltable.functions.string.str_format':
|
|
19
19
|
return 'path', 'pixeltable.functions.string.format'
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
from typing import Any, Optional
|
|
2
|
+
|
|
3
|
+
import sqlalchemy as sql
|
|
4
|
+
|
|
5
|
+
from pixeltable.metadata import register_converter
|
|
6
|
+
from pixeltable.metadata.converters.util import convert_table_md
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
@register_converter(version=20)
|
|
10
|
+
def _(engine: sql.engine.Engine) -> None:
|
|
11
|
+
convert_table_md(
|
|
12
|
+
engine,
|
|
13
|
+
substitution_fn=__substitute_md
|
|
14
|
+
)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def __substitute_md(k: Optional[str], v: Any) -> Optional[tuple[Optional[str], Any]]:
|
|
18
|
+
if isinstance(v, dict) and '_classname' in v:
|
|
19
|
+
# The way InlineArray is represented changed in v20. Previously, literal values were stored
|
|
20
|
+
# directly in the Inline expr; now we store them in Literal sub-exprs. This converter
|
|
21
|
+
# constructs new Literal exprs for the literal values in InlineArray, interleaving them
|
|
22
|
+
# with non-literal exprs into the correct sequence.
|
|
23
|
+
if v['_classname'] == 'InlineArray':
|
|
24
|
+
components = v.get('components') # Might be None, but that's ok
|
|
25
|
+
updated_components = []
|
|
26
|
+
for idx, val in v['elements']:
|
|
27
|
+
# idx >= 0, then this is a non-literal sub-expr. Otherwise, idx could be either
|
|
28
|
+
# None or -1, for legacy reasons (which are now obviated).
|
|
29
|
+
if idx is not None and idx >= 0:
|
|
30
|
+
updated_components.append(components[idx])
|
|
31
|
+
else:
|
|
32
|
+
updated_components.append({'val': val, '_classname': 'Literal'})
|
|
33
|
+
# InlineList was split out from InlineArray in v20. If is_json=True, then this is
|
|
34
|
+
# actually an InlineList. If is_json=False, then we assume it's an InlineArray for now,
|
|
35
|
+
# but it might actually be transformed into an InlineList when it is instantiated
|
|
36
|
+
# (unfortunately, there is no way to disambiguate at this stage; see comments in
|
|
37
|
+
# InlineArray._from_dict() for more details).
|
|
38
|
+
updated_v = {'_classname': 'InlineList' if v.get('is_json') else 'InlineArray'}
|
|
39
|
+
if len(updated_components) > 0:
|
|
40
|
+
updated_v['components'] = updated_components
|
|
41
|
+
return k, updated_v
|
|
42
|
+
if v['_classname'] == 'InlineDict':
|
|
43
|
+
components = v.get('components')
|
|
44
|
+
keys = []
|
|
45
|
+
updated_components = []
|
|
46
|
+
for key, idx, val in v['dict_items']:
|
|
47
|
+
keys.append(key)
|
|
48
|
+
if idx is not None and idx >= 0:
|
|
49
|
+
updated_components.append(components[idx])
|
|
50
|
+
else:
|
|
51
|
+
updated_components.append({'val': val, '_classname': 'Literal'})
|
|
52
|
+
updated_v = {'keys': keys, '_classname': 'InlineDict'}
|
|
53
|
+
if len(updated_components) > 0:
|
|
54
|
+
updated_v['components'] = updated_components
|
|
55
|
+
return k, updated_v
|
|
56
|
+
return None
|
|
@@ -14,8 +14,22 @@ def convert_table_md(
|
|
|
14
14
|
table_md_updater: Optional[Callable[[dict], None]] = None,
|
|
15
15
|
column_md_updater: Optional[Callable[[dict], None]] = None,
|
|
16
16
|
external_store_md_updater: Optional[Callable[[dict], None]] = None,
|
|
17
|
-
substitution_fn: Optional[Callable[[
|
|
17
|
+
substitution_fn: Optional[Callable[[Optional[str], Any], Optional[tuple[Optional[str], Any]]]] = None
|
|
18
18
|
) -> None:
|
|
19
|
+
"""
|
|
20
|
+
Converts table metadata based on the specified conversion functions.
|
|
21
|
+
|
|
22
|
+
Args:
|
|
23
|
+
engine: The SQLAlchemy engine.
|
|
24
|
+
table_md_updater: A function that updates the table metadata in place.
|
|
25
|
+
column_md_updater: A function that updates the column metadata in place.
|
|
26
|
+
external_store_md_updater: A function that updates the external store metadata in place.
|
|
27
|
+
substitution_fn: A function that substitutes metadata values. If specified, all metadata will be traversed
|
|
28
|
+
recursively, and `substitution_fn` will be called once for each metadata entry. If the entry appears in
|
|
29
|
+
a dict as a `(k, v)` pair, then `substitution_fn(k, v)` will be called. If the entry appears in a list,
|
|
30
|
+
then `substitution_fn(None, v)` will be called. If `substitution_fn` returns a tuple `(k', v')`, then
|
|
31
|
+
the original entry will be replaced, and the traversal will continue with `v'`.
|
|
32
|
+
"""
|
|
19
33
|
with engine.begin() as conn:
|
|
20
34
|
for row in conn.execute(sql.select(Table)):
|
|
21
35
|
id = row[0]
|
|
@@ -49,18 +63,29 @@ def __update_external_store_md(table_md: dict, external_store_md_updater: Callab
|
|
|
49
63
|
external_store_md_updater(store_md)
|
|
50
64
|
|
|
51
65
|
|
|
52
|
-
def __substitute_md_rec(
|
|
66
|
+
def __substitute_md_rec(
|
|
67
|
+
md: Any,
|
|
68
|
+
substitution_fn: Callable[[Optional[str], Any], Optional[tuple[Optional[str], Any]]]
|
|
69
|
+
) -> Any:
|
|
53
70
|
if isinstance(md, dict):
|
|
54
71
|
updated_md = {}
|
|
55
72
|
for k, v in md.items():
|
|
56
73
|
substitute = substitution_fn(k, v)
|
|
57
74
|
if substitute is not None:
|
|
58
75
|
updated_k, updated_v = substitute
|
|
59
|
-
updated_md[updated_k] = updated_v
|
|
76
|
+
updated_md[updated_k] = __substitute_md_rec(updated_v, substitution_fn)
|
|
60
77
|
else:
|
|
61
78
|
updated_md[k] = __substitute_md_rec(v, substitution_fn)
|
|
62
79
|
return updated_md
|
|
63
80
|
elif isinstance(md, list):
|
|
64
|
-
|
|
81
|
+
updated_md = []
|
|
82
|
+
for v in md:
|
|
83
|
+
substitute = substitution_fn(None, v)
|
|
84
|
+
if substitute is not None:
|
|
85
|
+
_, updated_v = substitute
|
|
86
|
+
updated_md.append(__substitute_md_rec(updated_v, substitution_fn))
|
|
87
|
+
else:
|
|
88
|
+
updated_md.append(__substitute_md_rec(v, substitution_fn))
|
|
89
|
+
return updated_md
|
|
65
90
|
else:
|
|
66
91
|
return md
|
pixeltable/metadata/notes.py
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
# rather than as a comment, so that the existence of a description can be enforced by
|
|
3
3
|
# the unit tests when new versions are added.
|
|
4
4
|
VERSION_NOTES = {
|
|
5
|
+
21: 'Separate InlineArray and InlineList',
|
|
5
6
|
20: 'Store DB timestamps in UTC',
|
|
6
7
|
19: 'UDF renames; ImageMemberAccess removal',
|
|
7
8
|
18: 'Restructured index metadata',
|
|
@@ -4,6 +4,7 @@ import logging
|
|
|
4
4
|
import os
|
|
5
5
|
import pathlib
|
|
6
6
|
import subprocess
|
|
7
|
+
import sys
|
|
7
8
|
from typing import Any
|
|
8
9
|
from zoneinfo import ZoneInfo
|
|
9
10
|
|
|
@@ -24,6 +25,12 @@ _logger = logging.getLogger('pixeltable')
|
|
|
24
25
|
class Dumper:
|
|
25
26
|
|
|
26
27
|
def __init__(self, output_dir='target', db_name='pxtdump') -> None:
|
|
28
|
+
if sys.version_info >= (3, 10):
|
|
29
|
+
raise RuntimeError(
|
|
30
|
+
'This script must be run on Python 3.9. '
|
|
31
|
+
'DB dumps are incompatible across versions due to issues with pickling anonymous UDFs.'
|
|
32
|
+
)
|
|
33
|
+
|
|
27
34
|
self.output_dir = pathlib.Path(output_dir)
|
|
28
35
|
shared_home = pathlib.Path(os.environ.get('PIXELTABLE_HOME', '~/.pixeltable')).expanduser()
|
|
29
36
|
mock_home_dir = self.output_dir / '.pixeltable'
|
|
@@ -226,9 +233,13 @@ class Dumper:
|
|
|
226
233
|
add_column('isin_2', t.c2.isin([1, 2, 3, 4, 5]))
|
|
227
234
|
add_column('isin_3', t.c2.isin(t.c6.f5))
|
|
228
235
|
|
|
229
|
-
# inline_array
|
|
230
|
-
add_column('inline_array_1', [[1, 2, 3], [4, 5, 6]])
|
|
231
|
-
add_column('inline_array_2', [['a', 'b', 'c'], ['d', 'e', 'f']])
|
|
236
|
+
# inline_array, inline_list, inline_dict
|
|
237
|
+
add_column('inline_array_1', pxt.array([[1, 2, 3], [4, 5, 6]]))
|
|
238
|
+
add_column('inline_array_2', pxt.array([['a', 'b', 'c'], ['d', 'e', 'f']]))
|
|
239
|
+
add_column('inline_array_exprs', pxt.array([[t.c2, t.c2 + 1], [t.c2 + 2, t.c2]]))
|
|
240
|
+
add_column('inline_array_mixed', pxt.array([[1, t.c2], [3, t.c2]]))
|
|
241
|
+
add_column('inline_list_1', [[1, 2, 3], [4, 5, 6]])
|
|
242
|
+
add_column('inline_list_2', [['a', 'b', 'c'], ['d', 'e', 'f']])
|
|
232
243
|
add_column('inline_list_exprs', [t.c1, [t.c1n, t.c2]])
|
|
233
244
|
add_column('inline_list_mixed', [1, 'a', t.c1, [1, 'a', t.c1n], 1, 'a'])
|
|
234
245
|
add_column('inline_dict', {'int': 22, 'dict': {'key': 'val'}, 'expr': t.c1})
|
pixeltable/type_system.py
CHANGED
|
@@ -204,6 +204,8 @@ class ColumnType:
|
|
|
204
204
|
|
|
205
205
|
@classmethod
|
|
206
206
|
def infer_literal_type(cls, val: Any, nullable: bool = False) -> Optional[ColumnType]:
|
|
207
|
+
if val is None:
|
|
208
|
+
return InvalidType(nullable=True)
|
|
207
209
|
if isinstance(val, str):
|
|
208
210
|
return StringType(nullable=nullable)
|
|
209
211
|
if isinstance(val, bool):
|
|
@@ -395,7 +397,7 @@ class InvalidType(ColumnType):
|
|
|
395
397
|
assert False
|
|
396
398
|
|
|
397
399
|
def print_value(self, val: Any) -> str:
|
|
398
|
-
|
|
400
|
+
return str(val)
|
|
399
401
|
|
|
400
402
|
def _validate_literal(self, val: Any) -> None:
|
|
401
403
|
assert False
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: pixeltable
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.19
|
|
4
4
|
Summary: Pixeltable: The Multimodal AI Data Plane
|
|
5
5
|
Author: Pixeltable, Inc.
|
|
6
6
|
Author-email: contact@pixeltable.com
|
|
@@ -17,7 +17,7 @@ Requires-Dist: ftfy (>=6.2.0,<7.0.0)
|
|
|
17
17
|
Requires-Dist: jinja2 (>=3.1.3,<4.0.0)
|
|
18
18
|
Requires-Dist: jmespath (>=1.0.1,<2.0.0)
|
|
19
19
|
Requires-Dist: more-itertools (>=10.2,<11.0)
|
|
20
|
-
Requires-Dist: numpy (>=1.25)
|
|
20
|
+
Requires-Dist: numpy (>=1.25,<2.0)
|
|
21
21
|
Requires-Dist: opencv-python-headless (>=4.7.0.68,<5.0.0.0)
|
|
22
22
|
Requires-Dist: pandas (>=2.0,<3.0)
|
|
23
23
|
Requires-Dist: pgvector (>=0.2.1,<0.3.0)
|
|
@@ -40,8 +40,10 @@ Description-Content-Type: text/markdown
|
|
|
40
40
|
|
|
41
41
|
[](https://opensource.org/licenses/Apache-2.0)
|
|
42
42
|

|
|
43
|
-
|
|
44
|
-
|
|
43
|
+

|
|
44
|
+
<br>
|
|
45
|
+
[](https://github.com/pixeltable/pixeltable/actions/workflows/pytest.yml)
|
|
46
|
+
[](https://github.com/pixeltable/pixeltable/actions/workflows/nightly.yml)
|
|
45
47
|
[](https://pypi.org/project/pixeltable/)
|
|
46
48
|
|
|
47
49
|
[Installation](https://pixeltable.github.io/pixeltable/getting-started/) | [Documentation](https://pixeltable.readme.io/) | [API Reference](https://pixeltable.github.io/pixeltable/) | [Code Samples](https://pixeltable.readme.io/recipes) | [Examples](https://github.com/pixeltable/pixeltable/tree/release/docs/release/tutorials)
|