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

Files changed (97) hide show
  1. pixeltable/__init__.py +2 -2
  2. pixeltable/__version__.py +2 -2
  3. pixeltable/catalog/__init__.py +1 -1
  4. pixeltable/catalog/dir.py +6 -0
  5. pixeltable/catalog/globals.py +25 -0
  6. pixeltable/catalog/named_function.py +4 -0
  7. pixeltable/catalog/path_dict.py +37 -11
  8. pixeltable/catalog/schema_object.py +6 -0
  9. pixeltable/catalog/table.py +421 -231
  10. pixeltable/catalog/table_version.py +22 -8
  11. pixeltable/catalog/view.py +5 -7
  12. pixeltable/dataframe.py +439 -105
  13. pixeltable/env.py +19 -5
  14. pixeltable/exec/__init__.py +1 -1
  15. pixeltable/exec/exec_node.py +6 -7
  16. pixeltable/exec/expr_eval_node.py +1 -1
  17. pixeltable/exec/sql_node.py +92 -45
  18. pixeltable/exprs/__init__.py +1 -0
  19. pixeltable/exprs/arithmetic_expr.py +1 -1
  20. pixeltable/exprs/array_slice.py +1 -1
  21. pixeltable/exprs/column_property_ref.py +1 -1
  22. pixeltable/exprs/column_ref.py +29 -2
  23. pixeltable/exprs/comparison.py +1 -1
  24. pixeltable/exprs/compound_predicate.py +1 -1
  25. pixeltable/exprs/expr.py +12 -5
  26. pixeltable/exprs/expr_set.py +8 -0
  27. pixeltable/exprs/function_call.py +147 -39
  28. pixeltable/exprs/in_predicate.py +1 -1
  29. pixeltable/exprs/inline_expr.py +25 -5
  30. pixeltable/exprs/is_null.py +1 -1
  31. pixeltable/exprs/json_mapper.py +1 -1
  32. pixeltable/exprs/json_path.py +1 -1
  33. pixeltable/exprs/method_ref.py +1 -1
  34. pixeltable/exprs/row_builder.py +1 -1
  35. pixeltable/exprs/rowid_ref.py +1 -1
  36. pixeltable/exprs/similarity_expr.py +14 -7
  37. pixeltable/exprs/sql_element_cache.py +4 -0
  38. pixeltable/exprs/type_cast.py +2 -2
  39. pixeltable/exprs/variable.py +3 -0
  40. pixeltable/func/__init__.py +5 -4
  41. pixeltable/func/aggregate_function.py +151 -68
  42. pixeltable/func/callable_function.py +48 -16
  43. pixeltable/func/expr_template_function.py +64 -23
  44. pixeltable/func/function.py +195 -27
  45. pixeltable/func/function_registry.py +2 -1
  46. pixeltable/func/query_template_function.py +51 -9
  47. pixeltable/func/signature.py +64 -7
  48. pixeltable/func/tools.py +153 -0
  49. pixeltable/func/udf.py +57 -35
  50. pixeltable/functions/__init__.py +2 -2
  51. pixeltable/functions/anthropic.py +51 -4
  52. pixeltable/functions/gemini.py +85 -0
  53. pixeltable/functions/globals.py +54 -34
  54. pixeltable/functions/huggingface.py +10 -28
  55. pixeltable/functions/json.py +3 -8
  56. pixeltable/functions/math.py +67 -0
  57. pixeltable/functions/ollama.py +8 -8
  58. pixeltable/functions/openai.py +51 -4
  59. pixeltable/functions/timestamp.py +1 -1
  60. pixeltable/functions/video.py +3 -9
  61. pixeltable/functions/vision.py +1 -1
  62. pixeltable/globals.py +354 -80
  63. pixeltable/index/embedding_index.py +106 -34
  64. pixeltable/io/__init__.py +1 -1
  65. pixeltable/io/label_studio.py +1 -1
  66. pixeltable/io/parquet.py +39 -19
  67. pixeltable/iterators/document.py +12 -0
  68. pixeltable/metadata/__init__.py +1 -1
  69. pixeltable/metadata/converters/convert_16.py +2 -1
  70. pixeltable/metadata/converters/convert_17.py +2 -1
  71. pixeltable/metadata/converters/convert_22.py +17 -0
  72. pixeltable/metadata/converters/convert_23.py +35 -0
  73. pixeltable/metadata/converters/convert_24.py +56 -0
  74. pixeltable/metadata/converters/convert_25.py +19 -0
  75. pixeltable/metadata/converters/util.py +4 -2
  76. pixeltable/metadata/notes.py +4 -0
  77. pixeltable/metadata/schema.py +1 -0
  78. pixeltable/plan.py +128 -50
  79. pixeltable/store.py +1 -1
  80. pixeltable/type_system.py +196 -54
  81. pixeltable/utils/arrow.py +8 -3
  82. pixeltable/utils/description_helper.py +89 -0
  83. pixeltable/utils/documents.py +14 -0
  84. {pixeltable-0.2.25.dist-info → pixeltable-0.3.0.dist-info}/METADATA +30 -20
  85. pixeltable-0.3.0.dist-info/RECORD +155 -0
  86. {pixeltable-0.2.25.dist-info → pixeltable-0.3.0.dist-info}/WHEEL +1 -1
  87. pixeltable-0.3.0.dist-info/entry_points.txt +3 -0
  88. pixeltable/tool/create_test_db_dump.py +0 -311
  89. pixeltable/tool/create_test_video.py +0 -81
  90. pixeltable/tool/doc_plugins/griffe.py +0 -50
  91. pixeltable/tool/doc_plugins/mkdocstrings.py +0 -6
  92. pixeltable/tool/doc_plugins/templates/material/udf.html.jinja +0 -135
  93. pixeltable/tool/embed_udf.py +0 -9
  94. pixeltable/tool/mypy_plugin.py +0 -55
  95. pixeltable-0.2.25.dist-info/RECORD +0 -154
  96. pixeltable-0.2.25.dist-info/entry_points.txt +0 -3
  97. {pixeltable-0.2.25.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.2.25"
3
- __version_tuple__ = (0, 2, 25)
2
+ __version__ = "0.3.0"
3
+ __version_tuple__ = (0, 3, 0)
@@ -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:
@@ -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:
@@ -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
- schema_obj = self._resolve_path(path)
117
- if not isinstance(schema_obj, expected):
118
- raise excs.Error(
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.parent)} is a {type(parent_obj)._display_name()}, not a {Dir._display_name()}')
125
- if path.name in self.dir_contents[parent_obj._id]:
126
- obj = self.dir_contents[parent_obj._id][path.name]
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
+