pixeltable 0.3.1__py3-none-any.whl → 0.3.3__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 +64 -11
- pixeltable/__version__.py +2 -2
- pixeltable/catalog/__init__.py +1 -1
- pixeltable/catalog/catalog.py +50 -27
- pixeltable/catalog/column.py +27 -11
- pixeltable/catalog/dir.py +6 -4
- pixeltable/catalog/globals.py +8 -1
- pixeltable/catalog/insertable_table.py +25 -15
- pixeltable/catalog/named_function.py +10 -6
- pixeltable/catalog/path.py +3 -2
- pixeltable/catalog/path_dict.py +8 -6
- pixeltable/catalog/schema_object.py +2 -1
- pixeltable/catalog/table.py +123 -103
- pixeltable/catalog/table_version.py +292 -143
- pixeltable/catalog/table_version_path.py +8 -5
- pixeltable/catalog/view.py +68 -27
- pixeltable/dataframe.py +102 -72
- pixeltable/env.py +39 -23
- pixeltable/exec/__init__.py +2 -2
- pixeltable/exec/aggregation_node.py +10 -4
- pixeltable/exec/cache_prefetch_node.py +5 -3
- pixeltable/exec/component_iteration_node.py +9 -8
- pixeltable/exec/data_row_batch.py +21 -10
- pixeltable/exec/exec_context.py +10 -3
- pixeltable/exec/exec_node.py +23 -12
- pixeltable/exec/expr_eval/evaluators.py +18 -17
- pixeltable/exec/expr_eval/expr_eval_node.py +29 -16
- pixeltable/exec/expr_eval/globals.py +33 -11
- pixeltable/exec/expr_eval/row_buffer.py +5 -6
- pixeltable/exec/expr_eval/schedulers.py +170 -42
- pixeltable/exec/in_memory_data_node.py +8 -7
- pixeltable/exec/row_update_node.py +15 -5
- pixeltable/exec/sql_node.py +56 -27
- pixeltable/exprs/__init__.py +2 -2
- pixeltable/exprs/arithmetic_expr.py +57 -26
- pixeltable/exprs/array_slice.py +1 -1
- pixeltable/exprs/column_property_ref.py +2 -1
- pixeltable/exprs/column_ref.py +20 -15
- pixeltable/exprs/comparison.py +6 -2
- pixeltable/exprs/compound_predicate.py +1 -3
- pixeltable/exprs/data_row.py +2 -2
- pixeltable/exprs/expr.py +101 -72
- pixeltable/exprs/expr_dict.py +2 -1
- pixeltable/exprs/expr_set.py +3 -1
- pixeltable/exprs/function_call.py +39 -41
- pixeltable/exprs/globals.py +1 -0
- pixeltable/exprs/in_predicate.py +2 -2
- pixeltable/exprs/inline_expr.py +20 -17
- pixeltable/exprs/json_mapper.py +4 -2
- pixeltable/exprs/json_path.py +12 -18
- pixeltable/exprs/literal.py +5 -9
- pixeltable/exprs/method_ref.py +1 -0
- pixeltable/exprs/object_ref.py +1 -1
- pixeltable/exprs/row_builder.py +31 -16
- pixeltable/exprs/rowid_ref.py +14 -5
- pixeltable/exprs/similarity_expr.py +11 -6
- pixeltable/exprs/sql_element_cache.py +1 -1
- pixeltable/exprs/type_cast.py +24 -9
- pixeltable/ext/__init__.py +1 -0
- pixeltable/ext/functions/__init__.py +1 -0
- pixeltable/ext/functions/whisperx.py +2 -2
- pixeltable/ext/functions/yolox.py +11 -11
- pixeltable/func/aggregate_function.py +17 -13
- pixeltable/func/callable_function.py +6 -6
- pixeltable/func/expr_template_function.py +15 -14
- pixeltable/func/function.py +16 -16
- pixeltable/func/function_registry.py +11 -8
- pixeltable/func/globals.py +4 -2
- pixeltable/func/query_template_function.py +12 -13
- pixeltable/func/signature.py +18 -9
- pixeltable/func/tools.py +10 -17
- pixeltable/func/udf.py +106 -11
- pixeltable/functions/__init__.py +21 -2
- pixeltable/functions/anthropic.py +21 -15
- pixeltable/functions/fireworks.py +63 -5
- pixeltable/functions/gemini.py +13 -3
- pixeltable/functions/globals.py +18 -6
- pixeltable/functions/huggingface.py +20 -38
- pixeltable/functions/image.py +7 -3
- pixeltable/functions/json.py +1 -0
- pixeltable/functions/llama_cpp.py +1 -4
- pixeltable/functions/mistralai.py +31 -20
- pixeltable/functions/ollama.py +4 -18
- pixeltable/functions/openai.py +214 -109
- pixeltable/functions/replicate.py +11 -10
- pixeltable/functions/string.py +70 -7
- pixeltable/functions/timestamp.py +21 -8
- pixeltable/functions/together.py +66 -52
- pixeltable/functions/video.py +1 -0
- pixeltable/functions/vision.py +14 -11
- pixeltable/functions/whisper.py +2 -1
- pixeltable/globals.py +61 -28
- pixeltable/index/__init__.py +1 -1
- pixeltable/index/btree.py +5 -3
- pixeltable/index/embedding_index.py +15 -14
- pixeltable/io/__init__.py +1 -1
- pixeltable/io/external_store.py +30 -25
- pixeltable/io/fiftyone.py +6 -14
- pixeltable/io/globals.py +33 -27
- pixeltable/io/hf_datasets.py +3 -2
- pixeltable/io/label_studio.py +80 -71
- pixeltable/io/pandas.py +33 -9
- pixeltable/io/parquet.py +10 -13
- pixeltable/iterators/__init__.py +1 -0
- pixeltable/iterators/audio.py +205 -0
- pixeltable/iterators/document.py +19 -8
- pixeltable/iterators/image.py +6 -24
- pixeltable/iterators/string.py +3 -6
- pixeltable/iterators/video.py +1 -7
- pixeltable/metadata/__init__.py +9 -2
- pixeltable/metadata/converters/convert_10.py +2 -2
- pixeltable/metadata/converters/convert_15.py +1 -5
- pixeltable/metadata/converters/convert_16.py +2 -4
- pixeltable/metadata/converters/convert_17.py +2 -4
- pixeltable/metadata/converters/convert_18.py +2 -4
- pixeltable/metadata/converters/convert_19.py +2 -5
- pixeltable/metadata/converters/convert_20.py +1 -4
- pixeltable/metadata/converters/convert_21.py +4 -6
- pixeltable/metadata/converters/convert_22.py +1 -0
- pixeltable/metadata/converters/convert_23.py +5 -5
- pixeltable/metadata/converters/convert_24.py +12 -13
- pixeltable/metadata/converters/convert_26.py +23 -0
- pixeltable/metadata/converters/util.py +3 -4
- pixeltable/metadata/notes.py +1 -0
- pixeltable/metadata/schema.py +13 -2
- pixeltable/plan.py +173 -98
- pixeltable/store.py +42 -26
- pixeltable/type_system.py +130 -85
- pixeltable/utils/arrow.py +1 -7
- pixeltable/utils/coco.py +16 -17
- pixeltable/utils/code.py +1 -1
- pixeltable/utils/console_output.py +44 -0
- pixeltable/utils/description_helper.py +7 -7
- pixeltable/utils/documents.py +3 -1
- pixeltable/utils/filecache.py +13 -8
- pixeltable/utils/http_server.py +9 -8
- pixeltable/utils/media_store.py +2 -1
- pixeltable/utils/pytorch.py +11 -14
- pixeltable/utils/s3.py +1 -0
- pixeltable/utils/sql.py +1 -0
- pixeltable/utils/transactional_directory.py +2 -2
- {pixeltable-0.3.1.dist-info → pixeltable-0.3.3.dist-info}/METADATA +7 -8
- pixeltable-0.3.3.dist-info/RECORD +163 -0
- pixeltable-0.3.1.dist-info/RECORD +0 -160
- {pixeltable-0.3.1.dist-info → pixeltable-0.3.3.dist-info}/LICENSE +0 -0
- {pixeltable-0.3.1.dist-info → pixeltable-0.3.3.dist-info}/WHEEL +0 -0
- {pixeltable-0.3.1.dist-info → pixeltable-0.3.3.dist-info}/entry_points.txt +0 -0
|
@@ -22,13 +22,10 @@ def _(engine: sql.engine.Engine) -> None:
|
|
|
22
22
|
store_name = f'{store_prefix}_{id.hex}'
|
|
23
23
|
column_md = md['column_md']
|
|
24
24
|
timestamp_cols = [
|
|
25
|
-
col_id for col_id, col in column_md.items()
|
|
26
|
-
if col['col_type']['_classname'] == 'TimestampType'
|
|
25
|
+
col_id for col_id, col in column_md.items() if col['col_type']['_classname'] == 'TimestampType'
|
|
27
26
|
]
|
|
28
27
|
for col_id in timestamp_cols:
|
|
29
|
-
conn.execute(
|
|
30
|
-
sql.text(f'ALTER TABLE {store_name} ALTER COLUMN col_{col_id} TYPE TIMESTAMPTZ')
|
|
31
|
-
)
|
|
28
|
+
conn.execute(sql.text(f'ALTER TABLE {store_name} ALTER COLUMN col_{col_id} TYPE TIMESTAMPTZ'))
|
|
32
29
|
|
|
33
30
|
|
|
34
31
|
def __update_timestamp_literals(k: Any, v: Any) -> Optional[tuple[Any, Any]]:
|
|
@@ -8,10 +8,7 @@ from pixeltable.metadata.converters.util import convert_table_md
|
|
|
8
8
|
|
|
9
9
|
@register_converter(version=20)
|
|
10
10
|
def _(engine: sql.engine.Engine) -> None:
|
|
11
|
-
convert_table_md(
|
|
12
|
-
engine,
|
|
13
|
-
substitution_fn=__substitute_md
|
|
14
|
-
)
|
|
11
|
+
convert_table_md(engine, substitution_fn=__substitute_md)
|
|
15
12
|
|
|
16
13
|
|
|
17
14
|
def __substitute_md(k: Optional[str], v: Any) -> Optional[tuple[Optional[str], Any]]:
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
from typing import Any, Optional
|
|
2
|
+
|
|
2
3
|
import sqlalchemy as sql
|
|
3
4
|
|
|
4
5
|
from pixeltable.metadata import register_converter
|
|
5
|
-
from pixeltable.metadata.converters.util import
|
|
6
|
+
from pixeltable.metadata.converters.util import convert_table_md, convert_table_schema_version_md
|
|
6
7
|
|
|
7
8
|
|
|
8
9
|
@register_converter(version=21)
|
|
@@ -10,12 +11,9 @@ def _(engine: sql.engine.Engine) -> None:
|
|
|
10
11
|
convert_table_schema_version_md(
|
|
11
12
|
engine,
|
|
12
13
|
table_schema_version_md_updater=__update_table_schema_version,
|
|
13
|
-
schema_column_updater=__update_schema_column
|
|
14
|
-
)
|
|
15
|
-
convert_table_md(
|
|
16
|
-
engine,
|
|
17
|
-
substitution_fn=__substitute_md
|
|
14
|
+
schema_column_updater=__update_schema_column,
|
|
18
15
|
)
|
|
16
|
+
convert_table_md(engine, substitution_fn=__substitute_md)
|
|
19
17
|
|
|
20
18
|
|
|
21
19
|
def __update_table_schema_version(table_schema_version_md: dict) -> None:
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import logging
|
|
2
2
|
from typing import Any, Optional
|
|
3
3
|
from uuid import UUID
|
|
4
|
+
|
|
4
5
|
import sqlalchemy as sql
|
|
5
6
|
|
|
6
7
|
from pixeltable.metadata import register_converter
|
|
@@ -9,12 +10,11 @@ from pixeltable.metadata.schema import Table
|
|
|
9
10
|
|
|
10
11
|
_logger = logging.getLogger('pixeltable')
|
|
11
12
|
|
|
13
|
+
|
|
12
14
|
@register_converter(version=23)
|
|
13
15
|
def _(engine: sql.engine.Engine) -> None:
|
|
14
|
-
convert_table_md(
|
|
15
|
-
|
|
16
|
-
table_md_updater=__update_table_md
|
|
17
|
-
)
|
|
16
|
+
convert_table_md(engine, table_md_updater=__update_table_md)
|
|
17
|
+
|
|
18
18
|
|
|
19
19
|
def __update_table_md(table_md: dict, table_id: UUID) -> None:
|
|
20
20
|
"""update the index metadata to add indexed_col_tbl_id column if it is missing
|
|
@@ -32,4 +32,4 @@ def __update_table_md(table_md: dict, table_id: UUID) -> None:
|
|
|
32
32
|
# assume that the indexed column is in the same table
|
|
33
33
|
# and update the index metadata.
|
|
34
34
|
_logger.info(f'Updating index metadata for table: {table_id} index: {idx_md["id"]}')
|
|
35
|
-
idx_md['indexed_col_tbl_id'] = str(table_id)
|
|
35
|
+
idx_md['indexed_col_tbl_id'] = str(table_id)
|
|
@@ -15,11 +15,16 @@ def __substitute_md(k: Optional[str], v: Any) -> Optional[tuple[Optional[str], A
|
|
|
15
15
|
from pixeltable import func
|
|
16
16
|
from pixeltable.func.globals import resolve_symbol
|
|
17
17
|
|
|
18
|
-
if (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
18
|
+
if (
|
|
19
|
+
isinstance(v, dict)
|
|
20
|
+
and '_classpath' in v
|
|
21
|
+
and v['_classpath']
|
|
22
|
+
in [
|
|
23
|
+
'pixeltable.func.callable_function.CallableFunction',
|
|
24
|
+
'pixeltable.func.aggregate_function.AggregateFunction',
|
|
25
|
+
'pixeltable.func.expr_template_function.ExprTemplateFunction',
|
|
26
|
+
]
|
|
27
|
+
):
|
|
23
28
|
if 'path' in v:
|
|
24
29
|
assert 'signature' not in v
|
|
25
30
|
f = resolve_symbol(__substitute_path(v['path']))
|
|
@@ -33,14 +38,8 @@ def __substitute_md(k: Optional[str], v: Any) -> Optional[tuple[Optional[str], A
|
|
|
33
38
|
# and InlineDict back in convert_20, but not for FunctionCall.
|
|
34
39
|
assert 'args' in v and isinstance(v['args'], list)
|
|
35
40
|
assert 'kwargs' in v and isinstance(v['kwargs'], dict)
|
|
36
|
-
v['args'] = [
|
|
37
|
-
|
|
38
|
-
for idx, arg in v['args']
|
|
39
|
-
]
|
|
40
|
-
v['kwargs'] = {
|
|
41
|
-
k: (None, arg) if idx == -1 else (idx, arg)
|
|
42
|
-
for k, (idx, arg) in v['kwargs'].items()
|
|
43
|
-
}
|
|
41
|
+
v['args'] = [(None, arg) if idx == -1 else (idx, arg) for idx, arg in v['args']]
|
|
42
|
+
v['kwargs'] = {k: (None, arg) if idx == -1 else (idx, arg) for k, (idx, arg) in v['kwargs'].items()}
|
|
44
43
|
return k, v
|
|
45
44
|
|
|
46
45
|
return None
|
|
@@ -0,0 +1,23 @@
|
|
|
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=26)
|
|
10
|
+
def _(engine: sql.engine.Engine) -> None:
|
|
11
|
+
convert_table_md(engine, substitution_fn=__substitute_md)
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def __substitute_md(k: Optional[str], v: Any) -> Optional[tuple[Optional[str], Any]]:
|
|
15
|
+
import pixeltable.type_system as ts
|
|
16
|
+
from pixeltable.exprs.literal import Literal
|
|
17
|
+
|
|
18
|
+
if k == 'limit_val' and v is not None:
|
|
19
|
+
assert isinstance(v, int)
|
|
20
|
+
newv = Literal(v, ts.IntType(nullable=False)).as_dict()
|
|
21
|
+
return k, newv
|
|
22
|
+
|
|
23
|
+
return None
|
|
@@ -15,7 +15,7 @@ def convert_table_md(
|
|
|
15
15
|
table_md_updater: Optional[Callable[[dict, UUID], None]] = None,
|
|
16
16
|
column_md_updater: Optional[Callable[[dict], None]] = None,
|
|
17
17
|
external_store_md_updater: Optional[Callable[[dict], None]] = None,
|
|
18
|
-
substitution_fn: Optional[Callable[[Optional[str], Any], Optional[tuple[Optional[str], Any]]]] = None
|
|
18
|
+
substitution_fn: Optional[Callable[[Optional[str], Any], Optional[tuple[Optional[str], Any]]]] = None,
|
|
19
19
|
) -> None:
|
|
20
20
|
"""
|
|
21
21
|
Converts schema.TableMd dicts based on the specified conversion functions.
|
|
@@ -66,8 +66,7 @@ def __update_external_store_md(table_md: dict, external_store_md_updater: Callab
|
|
|
66
66
|
|
|
67
67
|
|
|
68
68
|
def __substitute_md_rec(
|
|
69
|
-
md: Any,
|
|
70
|
-
substitution_fn: Callable[[Optional[str], Any], Optional[tuple[Optional[str], Any]]]
|
|
69
|
+
md: Any, substitution_fn: Callable[[Optional[str], Any], Optional[tuple[Optional[str], Any]]]
|
|
71
70
|
) -> Any:
|
|
72
71
|
if isinstance(md, dict):
|
|
73
72
|
updated_dict: dict[str, Any] = {}
|
|
@@ -97,7 +96,7 @@ def __substitute_md_rec(
|
|
|
97
96
|
def convert_table_schema_version_md(
|
|
98
97
|
engine: sql.engine.Engine,
|
|
99
98
|
table_schema_version_md_updater: Optional[Callable[[dict], None]] = None,
|
|
100
|
-
schema_column_updater: Optional[Callable[[dict], None]] = None
|
|
99
|
+
schema_column_updater: Optional[Callable[[dict], None]] = None,
|
|
101
100
|
) -> None:
|
|
102
101
|
"""
|
|
103
102
|
Converts schema.TableSchemaVersionMd dicts based on the specified conversion functions.
|
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
|
+
27: 'Enable pxt.query parameterization of limit clauses',
|
|
5
6
|
26: 'Rename clip_text and clip_image to clip',
|
|
6
7
|
25: 'Functions with multiple signatures',
|
|
7
8
|
24: 'Added TableMd/IndexMd.indexed_col_tbl_id',
|
pixeltable/metadata/schema.py
CHANGED
|
@@ -19,6 +19,7 @@ base_metadata = Base.metadata
|
|
|
19
19
|
|
|
20
20
|
T = TypeVar('T')
|
|
21
21
|
|
|
22
|
+
|
|
22
23
|
def md_from_dict(data_class_type: type[T], data: Any) -> T:
|
|
23
24
|
"""Re-instantiate a dataclass instance that contains nested dataclasses from a dict."""
|
|
24
25
|
if dataclasses.is_dataclass(data_class_type):
|
|
@@ -56,6 +57,7 @@ def md_from_dict(data_class_type: type[T], data: Any) -> T:
|
|
|
56
57
|
# schema easier (the goal is not to have to rely on some schema migration framework; if that breaks for some user,
|
|
57
58
|
# it would be very difficult to patch up)
|
|
58
59
|
|
|
60
|
+
|
|
59
61
|
@dataclasses.dataclass
|
|
60
62
|
class SystemInfoMd:
|
|
61
63
|
schema_version: int
|
|
@@ -63,6 +65,7 @@ class SystemInfoMd:
|
|
|
63
65
|
|
|
64
66
|
class SystemInfo(Base):
|
|
65
67
|
"""A single-row table that contains system-wide metadata."""
|
|
68
|
+
|
|
66
69
|
__tablename__ = 'systeminfo'
|
|
67
70
|
dummy = sql.Column(Integer, primary_key=True, default=0, nullable=False)
|
|
68
71
|
md = sql.Column(JSONB, nullable=False) # SystemInfoMd
|
|
@@ -76,7 +79,9 @@ class DirMd:
|
|
|
76
79
|
class Dir(Base):
|
|
77
80
|
__tablename__ = 'dirs'
|
|
78
81
|
|
|
79
|
-
id: orm.Mapped[uuid.UUID] = orm.mapped_column(
|
|
82
|
+
id: orm.Mapped[uuid.UUID] = orm.mapped_column(
|
|
83
|
+
UUID(as_uuid=True), primary_key=True, default=uuid.uuid4, nullable=False
|
|
84
|
+
)
|
|
80
85
|
parent_id: orm.Mapped[uuid.UUID] = orm.mapped_column(UUID(as_uuid=True), ForeignKey('dirs.id'), nullable=True)
|
|
81
86
|
md = sql.Column(JSONB, nullable=False)
|
|
82
87
|
|
|
@@ -89,7 +94,8 @@ class ColumnMd:
|
|
|
89
94
|
- when a column was added/dropped, which is needed to GC unreachable storage columns
|
|
90
95
|
(a column that was added after table snapshot n and dropped before table snapshot n+1 can be removed
|
|
91
96
|
from the stored table).
|
|
92
|
-
|
|
97
|
+
"""
|
|
98
|
+
|
|
93
99
|
id: int
|
|
94
100
|
schema_version_add: int
|
|
95
101
|
schema_version_drop: Optional[int]
|
|
@@ -110,6 +116,7 @@ class IndexMd:
|
|
|
110
116
|
"""
|
|
111
117
|
Metadata needed to instantiate an EmbeddingIndex
|
|
112
118
|
"""
|
|
119
|
+
|
|
113
120
|
id: int
|
|
114
121
|
name: str
|
|
115
122
|
indexed_col_tbl_id: str # UUID of the table (as string) that contains column being indexed
|
|
@@ -172,6 +179,7 @@ class Table(Base):
|
|
|
172
179
|
- views have a base, which is either a (live) table or a snapshot
|
|
173
180
|
- views can have a filter predicate
|
|
174
181
|
"""
|
|
182
|
+
|
|
175
183
|
__tablename__ = 'tables'
|
|
176
184
|
|
|
177
185
|
MAX_VERSION = 9223372036854775807 # 2^63 - 1
|
|
@@ -200,6 +208,7 @@ class SchemaColumn:
|
|
|
200
208
|
"""
|
|
201
209
|
Records the versioned metadata of a column.
|
|
202
210
|
"""
|
|
211
|
+
|
|
203
212
|
pos: int
|
|
204
213
|
name: str
|
|
205
214
|
|
|
@@ -213,6 +222,7 @@ class TableSchemaVersionMd:
|
|
|
213
222
|
"""
|
|
214
223
|
Records all versioned table metadata.
|
|
215
224
|
"""
|
|
225
|
+
|
|
216
226
|
schema_version: int
|
|
217
227
|
preceding_schema_version: Optional[int]
|
|
218
228
|
columns: dict[int, SchemaColumn] # col_id -> SchemaColumn
|
|
@@ -250,6 +260,7 @@ class Function(Base):
|
|
|
250
260
|
We store the Python version under which a Function was created (and the callable pickled) in order to warn
|
|
251
261
|
against version mismatches.
|
|
252
262
|
"""
|
|
263
|
+
|
|
253
264
|
__tablename__ = 'functions'
|
|
254
265
|
|
|
255
266
|
id = sql.Column(UUID(as_uuid=True), primary_key=True, default=uuid.uuid4, nullable=False)
|