pixeltable 0.3.2__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.

Files changed (147) hide show
  1. pixeltable/__init__.py +64 -11
  2. pixeltable/__version__.py +2 -2
  3. pixeltable/catalog/__init__.py +1 -1
  4. pixeltable/catalog/catalog.py +50 -27
  5. pixeltable/catalog/column.py +27 -11
  6. pixeltable/catalog/dir.py +6 -4
  7. pixeltable/catalog/globals.py +8 -1
  8. pixeltable/catalog/insertable_table.py +22 -12
  9. pixeltable/catalog/named_function.py +10 -6
  10. pixeltable/catalog/path.py +3 -2
  11. pixeltable/catalog/path_dict.py +8 -6
  12. pixeltable/catalog/schema_object.py +2 -1
  13. pixeltable/catalog/table.py +121 -101
  14. pixeltable/catalog/table_version.py +291 -142
  15. pixeltable/catalog/table_version_path.py +8 -5
  16. pixeltable/catalog/view.py +67 -26
  17. pixeltable/dataframe.py +102 -72
  18. pixeltable/env.py +20 -21
  19. pixeltable/exec/__init__.py +2 -2
  20. pixeltable/exec/aggregation_node.py +10 -4
  21. pixeltable/exec/cache_prefetch_node.py +5 -3
  22. pixeltable/exec/component_iteration_node.py +9 -8
  23. pixeltable/exec/data_row_batch.py +21 -10
  24. pixeltable/exec/exec_context.py +10 -3
  25. pixeltable/exec/exec_node.py +23 -12
  26. pixeltable/exec/expr_eval/evaluators.py +13 -7
  27. pixeltable/exec/expr_eval/expr_eval_node.py +24 -15
  28. pixeltable/exec/expr_eval/globals.py +30 -7
  29. pixeltable/exec/expr_eval/row_buffer.py +5 -6
  30. pixeltable/exec/expr_eval/schedulers.py +151 -31
  31. pixeltable/exec/in_memory_data_node.py +8 -7
  32. pixeltable/exec/row_update_node.py +15 -5
  33. pixeltable/exec/sql_node.py +56 -27
  34. pixeltable/exprs/__init__.py +2 -2
  35. pixeltable/exprs/arithmetic_expr.py +57 -26
  36. pixeltable/exprs/array_slice.py +1 -1
  37. pixeltable/exprs/column_property_ref.py +2 -1
  38. pixeltable/exprs/column_ref.py +20 -15
  39. pixeltable/exprs/comparison.py +6 -2
  40. pixeltable/exprs/compound_predicate.py +1 -3
  41. pixeltable/exprs/data_row.py +2 -2
  42. pixeltable/exprs/expr.py +101 -72
  43. pixeltable/exprs/expr_dict.py +2 -1
  44. pixeltable/exprs/expr_set.py +3 -1
  45. pixeltable/exprs/function_call.py +39 -41
  46. pixeltable/exprs/globals.py +1 -0
  47. pixeltable/exprs/in_predicate.py +2 -2
  48. pixeltable/exprs/inline_expr.py +20 -17
  49. pixeltable/exprs/json_mapper.py +4 -2
  50. pixeltable/exprs/json_path.py +12 -18
  51. pixeltable/exprs/literal.py +5 -9
  52. pixeltable/exprs/method_ref.py +1 -0
  53. pixeltable/exprs/object_ref.py +1 -1
  54. pixeltable/exprs/row_builder.py +32 -17
  55. pixeltable/exprs/rowid_ref.py +14 -5
  56. pixeltable/exprs/similarity_expr.py +11 -6
  57. pixeltable/exprs/sql_element_cache.py +1 -1
  58. pixeltable/exprs/type_cast.py +24 -9
  59. pixeltable/ext/__init__.py +1 -0
  60. pixeltable/ext/functions/__init__.py +1 -0
  61. pixeltable/ext/functions/whisperx.py +2 -2
  62. pixeltable/ext/functions/yolox.py +11 -11
  63. pixeltable/func/aggregate_function.py +17 -13
  64. pixeltable/func/callable_function.py +6 -6
  65. pixeltable/func/expr_template_function.py +15 -14
  66. pixeltable/func/function.py +16 -16
  67. pixeltable/func/function_registry.py +11 -8
  68. pixeltable/func/globals.py +4 -2
  69. pixeltable/func/query_template_function.py +12 -13
  70. pixeltable/func/signature.py +18 -9
  71. pixeltable/func/tools.py +10 -17
  72. pixeltable/func/udf.py +106 -11
  73. pixeltable/functions/__init__.py +21 -2
  74. pixeltable/functions/anthropic.py +16 -12
  75. pixeltable/functions/fireworks.py +63 -5
  76. pixeltable/functions/gemini.py +13 -3
  77. pixeltable/functions/globals.py +18 -6
  78. pixeltable/functions/huggingface.py +20 -38
  79. pixeltable/functions/image.py +7 -3
  80. pixeltable/functions/json.py +1 -0
  81. pixeltable/functions/llama_cpp.py +1 -4
  82. pixeltable/functions/mistralai.py +31 -20
  83. pixeltable/functions/ollama.py +4 -18
  84. pixeltable/functions/openai.py +201 -108
  85. pixeltable/functions/replicate.py +11 -10
  86. pixeltable/functions/string.py +70 -7
  87. pixeltable/functions/timestamp.py +21 -8
  88. pixeltable/functions/together.py +66 -52
  89. pixeltable/functions/video.py +1 -0
  90. pixeltable/functions/vision.py +14 -11
  91. pixeltable/functions/whisper.py +2 -1
  92. pixeltable/globals.py +60 -26
  93. pixeltable/index/__init__.py +1 -1
  94. pixeltable/index/btree.py +5 -3
  95. pixeltable/index/embedding_index.py +15 -14
  96. pixeltable/io/__init__.py +1 -1
  97. pixeltable/io/external_store.py +30 -25
  98. pixeltable/io/fiftyone.py +6 -14
  99. pixeltable/io/globals.py +33 -27
  100. pixeltable/io/hf_datasets.py +2 -1
  101. pixeltable/io/label_studio.py +77 -68
  102. pixeltable/io/pandas.py +33 -9
  103. pixeltable/io/parquet.py +9 -12
  104. pixeltable/iterators/__init__.py +1 -0
  105. pixeltable/iterators/audio.py +205 -0
  106. pixeltable/iterators/document.py +19 -8
  107. pixeltable/iterators/image.py +6 -24
  108. pixeltable/iterators/string.py +3 -6
  109. pixeltable/iterators/video.py +1 -7
  110. pixeltable/metadata/__init__.py +7 -1
  111. pixeltable/metadata/converters/convert_10.py +2 -2
  112. pixeltable/metadata/converters/convert_15.py +1 -5
  113. pixeltable/metadata/converters/convert_16.py +2 -4
  114. pixeltable/metadata/converters/convert_17.py +2 -4
  115. pixeltable/metadata/converters/convert_18.py +2 -4
  116. pixeltable/metadata/converters/convert_19.py +2 -5
  117. pixeltable/metadata/converters/convert_20.py +1 -4
  118. pixeltable/metadata/converters/convert_21.py +4 -6
  119. pixeltable/metadata/converters/convert_22.py +1 -0
  120. pixeltable/metadata/converters/convert_23.py +5 -5
  121. pixeltable/metadata/converters/convert_24.py +12 -13
  122. pixeltable/metadata/converters/convert_26.py +23 -0
  123. pixeltable/metadata/converters/util.py +3 -4
  124. pixeltable/metadata/notes.py +1 -0
  125. pixeltable/metadata/schema.py +13 -2
  126. pixeltable/plan.py +173 -98
  127. pixeltable/store.py +42 -26
  128. pixeltable/type_system.py +62 -54
  129. pixeltable/utils/arrow.py +1 -2
  130. pixeltable/utils/coco.py +16 -17
  131. pixeltable/utils/code.py +1 -1
  132. pixeltable/utils/console_output.py +6 -3
  133. pixeltable/utils/description_helper.py +7 -7
  134. pixeltable/utils/documents.py +3 -1
  135. pixeltable/utils/filecache.py +12 -7
  136. pixeltable/utils/http_server.py +9 -8
  137. pixeltable/utils/media_store.py +2 -1
  138. pixeltable/utils/pytorch.py +11 -14
  139. pixeltable/utils/s3.py +1 -0
  140. pixeltable/utils/sql.py +1 -0
  141. pixeltable/utils/transactional_directory.py +2 -2
  142. {pixeltable-0.3.2.dist-info → pixeltable-0.3.3.dist-info}/METADATA +6 -8
  143. pixeltable-0.3.3.dist-info/RECORD +163 -0
  144. pixeltable-0.3.2.dist-info/RECORD +0 -161
  145. {pixeltable-0.3.2.dist-info → pixeltable-0.3.3.dist-info}/LICENSE +0 -0
  146. {pixeltable-0.3.2.dist-info → pixeltable-0.3.3.dist-info}/WHEEL +0 -0
  147. {pixeltable-0.3.2.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 convert_table_schema_version_md, convert_table_md
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,4 +1,5 @@
1
1
  from typing import Any, Optional
2
+
2
3
  import sqlalchemy as sql
3
4
 
4
5
  from pixeltable.metadata import register_converter
@@ -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
- engine,
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 (isinstance(v, dict) and
19
- '_classpath' in v and
20
- v['_classpath'] in ['pixeltable.func.callable_function.CallableFunction',
21
- 'pixeltable.func.aggregate_function.AggregateFunction',
22
- 'pixeltable.func.expr_template_function.ExprTemplateFunction']):
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
- (None, arg) if idx == -1 else (idx, arg)
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.
@@ -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',
@@ -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(UUID(as_uuid=True), primary_key=True, default=uuid.uuid4, nullable=False)
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)