pixeltable 0.2.24__py3-none-any.whl → 0.3.0__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 +2 -2
- pixeltable/__version__.py +2 -2
- pixeltable/catalog/__init__.py +1 -1
- pixeltable/catalog/dir.py +6 -0
- pixeltable/catalog/globals.py +25 -0
- pixeltable/catalog/named_function.py +4 -0
- pixeltable/catalog/path_dict.py +37 -11
- pixeltable/catalog/schema_object.py +6 -0
- pixeltable/catalog/table.py +531 -251
- pixeltable/catalog/table_version.py +22 -8
- pixeltable/catalog/view.py +8 -7
- pixeltable/dataframe.py +439 -105
- pixeltable/env.py +19 -5
- pixeltable/exec/__init__.py +1 -1
- pixeltable/exec/exec_node.py +6 -7
- pixeltable/exec/expr_eval_node.py +1 -1
- pixeltable/exec/sql_node.py +92 -45
- pixeltable/exprs/__init__.py +1 -0
- pixeltable/exprs/arithmetic_expr.py +1 -1
- pixeltable/exprs/array_slice.py +1 -1
- pixeltable/exprs/column_property_ref.py +1 -1
- pixeltable/exprs/column_ref.py +29 -2
- pixeltable/exprs/comparison.py +1 -1
- pixeltable/exprs/compound_predicate.py +1 -1
- pixeltable/exprs/expr.py +12 -5
- pixeltable/exprs/expr_set.py +8 -0
- pixeltable/exprs/function_call.py +147 -39
- pixeltable/exprs/in_predicate.py +1 -1
- pixeltable/exprs/inline_expr.py +25 -5
- pixeltable/exprs/is_null.py +1 -1
- pixeltable/exprs/json_mapper.py +1 -1
- pixeltable/exprs/json_path.py +1 -1
- pixeltable/exprs/method_ref.py +1 -1
- pixeltable/exprs/row_builder.py +1 -1
- pixeltable/exprs/rowid_ref.py +1 -1
- pixeltable/exprs/similarity_expr.py +17 -7
- pixeltable/exprs/sql_element_cache.py +4 -0
- pixeltable/exprs/type_cast.py +2 -2
- pixeltable/exprs/variable.py +3 -0
- pixeltable/func/__init__.py +5 -4
- pixeltable/func/aggregate_function.py +151 -68
- pixeltable/func/callable_function.py +48 -16
- pixeltable/func/expr_template_function.py +64 -23
- pixeltable/func/function.py +227 -23
- pixeltable/func/function_registry.py +2 -1
- pixeltable/func/query_template_function.py +51 -9
- pixeltable/func/signature.py +65 -7
- pixeltable/func/tools.py +153 -0
- pixeltable/func/udf.py +57 -35
- pixeltable/functions/__init__.py +2 -2
- pixeltable/functions/anthropic.py +51 -4
- pixeltable/functions/gemini.py +85 -0
- pixeltable/functions/globals.py +54 -34
- pixeltable/functions/huggingface.py +10 -28
- pixeltable/functions/json.py +3 -8
- pixeltable/functions/math.py +67 -0
- pixeltable/functions/mistralai.py +0 -2
- pixeltable/functions/ollama.py +8 -8
- pixeltable/functions/openai.py +51 -4
- pixeltable/functions/timestamp.py +1 -1
- pixeltable/functions/video.py +3 -9
- pixeltable/functions/vision.py +1 -1
- pixeltable/globals.py +374 -89
- pixeltable/index/embedding_index.py +106 -29
- pixeltable/io/__init__.py +1 -1
- pixeltable/io/label_studio.py +1 -1
- pixeltable/io/parquet.py +39 -19
- pixeltable/iterators/__init__.py +1 -0
- pixeltable/iterators/document.py +12 -0
- pixeltable/iterators/image.py +100 -0
- pixeltable/iterators/video.py +7 -8
- pixeltable/metadata/__init__.py +1 -1
- pixeltable/metadata/converters/convert_16.py +2 -1
- pixeltable/metadata/converters/convert_17.py +2 -1
- pixeltable/metadata/converters/convert_22.py +17 -0
- pixeltable/metadata/converters/convert_23.py +35 -0
- pixeltable/metadata/converters/convert_24.py +56 -0
- pixeltable/metadata/converters/convert_25.py +19 -0
- pixeltable/metadata/converters/util.py +4 -2
- pixeltable/metadata/notes.py +4 -0
- pixeltable/metadata/schema.py +1 -0
- pixeltable/plan.py +129 -51
- pixeltable/store.py +1 -1
- pixeltable/type_system.py +196 -54
- pixeltable/utils/arrow.py +8 -3
- pixeltable/utils/description_helper.py +89 -0
- pixeltable/utils/documents.py +14 -0
- {pixeltable-0.2.24.dist-info → pixeltable-0.3.0.dist-info}/METADATA +32 -22
- pixeltable-0.3.0.dist-info/RECORD +155 -0
- {pixeltable-0.2.24.dist-info → pixeltable-0.3.0.dist-info}/WHEEL +1 -1
- pixeltable-0.3.0.dist-info/entry_points.txt +3 -0
- pixeltable/tool/create_test_db_dump.py +0 -308
- pixeltable/tool/create_test_video.py +0 -81
- pixeltable/tool/doc_plugins/griffe.py +0 -50
- pixeltable/tool/doc_plugins/mkdocstrings.py +0 -6
- pixeltable/tool/doc_plugins/templates/material/udf.html.jinja +0 -135
- pixeltable/tool/embed_udf.py +0 -9
- pixeltable/tool/mypy_plugin.py +0 -55
- pixeltable-0.2.24.dist-info/RECORD +0 -153
- pixeltable-0.2.24.dist-info/entry_points.txt +0 -3
- {pixeltable-0.2.24.dist-info → pixeltable-0.3.0.dist-info}/LICENSE +0 -0
pixeltable/__init__.py
CHANGED
|
@@ -2,9 +2,9 @@ from .catalog import Column, InsertableTable, Table, UpdateStatus, View
|
|
|
2
2
|
from .dataframe import DataFrame
|
|
3
3
|
from .exceptions import Error
|
|
4
4
|
from .exprs import RELATIVE_PATH_ROOT
|
|
5
|
-
from .func import Aggregator, Function, expr_udf, uda, udf
|
|
5
|
+
from .func import Aggregator, Function, expr_udf, query, uda, udf
|
|
6
6
|
from .globals import (array, configure_logging, create_dir, create_snapshot, create_table, create_view, drop_dir,
|
|
7
|
-
drop_table, get_table, init, list_dirs, list_functions, list_tables, move)
|
|
7
|
+
drop_table, get_table, init, list_dirs, list_functions, list_tables, move, tool, tools)
|
|
8
8
|
from .type_system import (Array, ArrayType, Audio, AudioType, Bool, BoolType, ColumnType, Document, DocumentType, Float,
|
|
9
9
|
FloatType, Image, ImageType, Int, IntType, Json, JsonType, Required, String, StringType,
|
|
10
10
|
Timestamp, TimestampType, Video, VideoType)
|
pixeltable/__version__.py
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
# These version placeholders will be replaced during build.
|
|
2
|
-
__version__ = "0.
|
|
3
|
-
__version_tuple__ = (0,
|
|
2
|
+
__version__ = "0.3.0"
|
|
3
|
+
__version_tuple__ = (0, 3, 0)
|
pixeltable/catalog/__init__.py
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
from .catalog import Catalog
|
|
2
2
|
from .column import Column
|
|
3
3
|
from .dir import Dir
|
|
4
|
-
from .globals import UpdateStatus, is_valid_identifier, is_valid_path, MediaValidation
|
|
4
|
+
from .globals import UpdateStatus, is_valid_identifier, is_valid_path, MediaValidation, IfExistsParam, IfNotExistsParam
|
|
5
5
|
from .insertable_table import InsertableTable
|
|
6
6
|
from .named_function import NamedFunction
|
|
7
7
|
from .path import Path
|
pixeltable/catalog/dir.py
CHANGED
|
@@ -21,6 +21,12 @@ class Dir(SchemaObject):
|
|
|
21
21
|
def _display_name(cls) -> str:
|
|
22
22
|
return 'directory'
|
|
23
23
|
|
|
24
|
+
@property
|
|
25
|
+
def _has_dependents(self) -> bool:
|
|
26
|
+
""" Returns True if this directory has any children. """
|
|
27
|
+
from pixeltable.catalog import Catalog, Path
|
|
28
|
+
return len(Catalog.get().paths.get_children(Path(self._path), child_type=None, recursive=False)) > 0
|
|
29
|
+
|
|
24
30
|
def _move(self, new_name: str, new_dir_id: UUID) -> None:
|
|
25
31
|
super()._move(new_name, new_dir_id)
|
|
26
32
|
with Env.get().engine.begin() as conn:
|
pixeltable/catalog/globals.py
CHANGED
|
@@ -51,6 +51,31 @@ class MediaValidation(enum.Enum):
|
|
|
51
51
|
val_strs = ', '.join(f'{s.lower()!r}' for s in cls.__members__.keys())
|
|
52
52
|
raise excs.Error(f'{error_prefix} must be one of: [{val_strs}]')
|
|
53
53
|
|
|
54
|
+
class IfExistsParam(enum.Enum):
|
|
55
|
+
ERROR = 0
|
|
56
|
+
IGNORE = 1
|
|
57
|
+
REPLACE = 2
|
|
58
|
+
REPLACE_FORCE = 3
|
|
59
|
+
|
|
60
|
+
@classmethod
|
|
61
|
+
def validated(cls, param_val: str, param_name: str) -> IfExistsParam:
|
|
62
|
+
try:
|
|
63
|
+
return cls[param_val.upper()]
|
|
64
|
+
except KeyError:
|
|
65
|
+
val_strs = ', '.join(f'{s.lower()!r}' for s in cls.__members__.keys())
|
|
66
|
+
raise excs.Error(f'{param_name} must be one of: [{val_strs}]')
|
|
67
|
+
|
|
68
|
+
class IfNotExistsParam(enum.Enum):
|
|
69
|
+
ERROR = 0
|
|
70
|
+
IGNORE = 1
|
|
71
|
+
|
|
72
|
+
@classmethod
|
|
73
|
+
def validated(cls, param_val: str, param_name: str) -> IfNotExistsParam:
|
|
74
|
+
try:
|
|
75
|
+
return cls[param_val.upper()]
|
|
76
|
+
except KeyError:
|
|
77
|
+
val_strs = ', '.join(f'{s.lower()!r}' for s in cls.__members__.keys())
|
|
78
|
+
raise excs.Error(f'{param_name} must be one of: [{val_strs}]')
|
|
54
79
|
|
|
55
80
|
def is_valid_identifier(name: str) -> bool:
|
|
56
81
|
return name.isidentifier() and not name.startswith('_')
|
|
@@ -25,6 +25,10 @@ class NamedFunction(SchemaObject):
|
|
|
25
25
|
def _display_name(cls) -> str:
|
|
26
26
|
return 'function'
|
|
27
27
|
|
|
28
|
+
@property
|
|
29
|
+
def _has_dependents(self) -> bool:
|
|
30
|
+
return False
|
|
31
|
+
|
|
28
32
|
def _move(self, new_name: str, new_dir_id: UUID) -> None:
|
|
29
33
|
super()._move(new_name, new_dir_id)
|
|
30
34
|
with Env.get().engine.begin() as conn:
|
pixeltable/catalog/path_dict.py
CHANGED
|
@@ -51,11 +51,41 @@ class PathDict:
|
|
|
51
51
|
record_dir(dir)
|
|
52
52
|
|
|
53
53
|
def _resolve_path(self, path: Path) -> SchemaObject:
|
|
54
|
+
"""Resolve the path to a SchemaObject.
|
|
55
|
+
|
|
56
|
+
Args:
|
|
57
|
+
path: path to resolve
|
|
58
|
+
|
|
59
|
+
Returns:
|
|
60
|
+
SchemaObject at the path.
|
|
61
|
+
|
|
62
|
+
Raises:
|
|
63
|
+
Error if path is invalid or does not exist.
|
|
64
|
+
"""
|
|
65
|
+
schema_obj = self.get_object(path)
|
|
66
|
+
if schema_obj is None:
|
|
67
|
+
raise excs.Error(f"No such path: {str(path)}")
|
|
68
|
+
return schema_obj
|
|
69
|
+
|
|
70
|
+
def get_object(self, path: Path) -> Optional[SchemaObject]:
|
|
71
|
+
"""Get the object at the given path, if any.
|
|
72
|
+
|
|
73
|
+
Args:
|
|
74
|
+
path: path to object
|
|
75
|
+
|
|
76
|
+
Returns:
|
|
77
|
+
SchemaObject at the path if it exists, None otherwise.
|
|
78
|
+
|
|
79
|
+
Raises:
|
|
80
|
+
Error if path is invalid.
|
|
81
|
+
"""
|
|
54
82
|
if path.is_root:
|
|
55
83
|
return self.root_dir
|
|
56
84
|
dir = self.root_dir
|
|
57
85
|
for i, component in enumerate(path.components):
|
|
58
86
|
if component not in self.dir_contents[dir._id]:
|
|
87
|
+
if i == len(path.components) - 1:
|
|
88
|
+
return None
|
|
59
89
|
raise excs.Error(f'No such path: {".".join(path.components[:i + 1])}')
|
|
60
90
|
schema_obj = self.dir_contents[dir._id][component]
|
|
61
91
|
if i < len(path.components) - 1:
|
|
@@ -112,19 +142,15 @@ class PathDict:
|
|
|
112
142
|
Error if path is invalid or object at path has wrong type
|
|
113
143
|
"""
|
|
114
144
|
# check for existence
|
|
145
|
+
obj = self.get_object(path)
|
|
115
146
|
if expected is not None:
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
f'{str(path)} needs to be a {expected._display_name()} but is a {type(schema_obj)._display_name()}')
|
|
120
|
-
if expected is None:
|
|
121
|
-
parent_obj = self._resolve_path(path.parent)
|
|
122
|
-
if not isinstance(parent_obj, Dir):
|
|
147
|
+
if obj is None:
|
|
148
|
+
raise excs.Error(f"No such path: {str(path)}")
|
|
149
|
+
if not isinstance(obj, expected):
|
|
123
150
|
raise excs.Error(
|
|
124
|
-
f'{str(path
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
raise excs.Error(f"{type(obj)._display_name()} '{str(path)}' already exists")
|
|
151
|
+
f'{str(path)} needs to be a {expected._display_name()} but is a {type(obj)._display_name()}')
|
|
152
|
+
if expected is None and obj is not None:
|
|
153
|
+
raise excs.Error(f"{type(obj)._display_name()} '{str(path)}' already exists")
|
|
128
154
|
|
|
129
155
|
def get_children(self, parent: Path, child_type: Optional[type[SchemaObject]], recursive: bool) -> list[Path]:
|
|
130
156
|
dir = self._resolve_path(parent)
|
|
@@ -66,7 +66,13 @@ class SchemaObject:
|
|
|
66
66
|
"""
|
|
67
67
|
pass
|
|
68
68
|
|
|
69
|
+
@property
|
|
70
|
+
@abstractmethod
|
|
71
|
+
def _has_dependents(self) -> bool:
|
|
72
|
+
"""Returns True if this object has dependents (e.g., children, views)"""
|
|
73
|
+
|
|
69
74
|
def _move(self, new_name: str, new_dir_id: UUID) -> None:
|
|
70
75
|
"""Subclasses need to override this to make the change persistent"""
|
|
71
76
|
self.__name = new_name
|
|
72
77
|
self.__dir_id = new_dir_id
|
|
78
|
+
|