pixeltable 0.2.12__tar.gz → 0.2.14__tar.gz
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-0.2.14/PKG-INFO +206 -0
- pixeltable-0.2.14/README.md +168 -0
- {pixeltable-0.2.12 → pixeltable-0.2.14}/pixeltable/__init__.py +1 -1
- {pixeltable-0.2.12 → pixeltable-0.2.14}/pixeltable/__version__.py +2 -2
- {pixeltable-0.2.12 → pixeltable-0.2.14}/pixeltable/catalog/column.py +5 -0
- {pixeltable-0.2.12 → pixeltable-0.2.14}/pixeltable/catalog/globals.py +8 -0
- {pixeltable-0.2.12 → pixeltable-0.2.14}/pixeltable/catalog/insertable_table.py +2 -2
- {pixeltable-0.2.12 → pixeltable-0.2.14}/pixeltable/catalog/table.py +27 -9
- {pixeltable-0.2.12 → pixeltable-0.2.14}/pixeltable/catalog/table_version.py +41 -68
- {pixeltable-0.2.12 → pixeltable-0.2.14}/pixeltable/catalog/view.py +3 -3
- {pixeltable-0.2.12 → pixeltable-0.2.14}/pixeltable/dataframe.py +7 -6
- {pixeltable-0.2.12 → pixeltable-0.2.14}/pixeltable/exec/__init__.py +2 -1
- {pixeltable-0.2.12 → pixeltable-0.2.14}/pixeltable/exec/expr_eval_node.py +8 -1
- pixeltable-0.2.14/pixeltable/exec/row_update_node.py +61 -0
- pixeltable-0.2.12/pixeltable/exec/sql_scan_node.py → pixeltable-0.2.14/pixeltable/exec/sql_node.py +120 -56
- {pixeltable-0.2.12 → pixeltable-0.2.14}/pixeltable/exprs/__init__.py +1 -2
- {pixeltable-0.2.12 → pixeltable-0.2.14}/pixeltable/exprs/comparison.py +5 -5
- {pixeltable-0.2.12 → pixeltable-0.2.14}/pixeltable/exprs/compound_predicate.py +12 -12
- {pixeltable-0.2.12 → pixeltable-0.2.14}/pixeltable/exprs/expr.py +67 -22
- {pixeltable-0.2.12 → pixeltable-0.2.14}/pixeltable/exprs/function_call.py +60 -29
- {pixeltable-0.2.12 → pixeltable-0.2.14}/pixeltable/exprs/globals.py +2 -0
- {pixeltable-0.2.12 → pixeltable-0.2.14}/pixeltable/exprs/in_predicate.py +3 -3
- {pixeltable-0.2.12 → pixeltable-0.2.14}/pixeltable/exprs/inline_array.py +18 -11
- {pixeltable-0.2.12 → pixeltable-0.2.14}/pixeltable/exprs/is_null.py +5 -5
- pixeltable-0.2.14/pixeltable/exprs/method_ref.py +63 -0
- {pixeltable-0.2.12 → pixeltable-0.2.14}/pixeltable/ext/__init__.py +9 -0
- pixeltable-0.2.14/pixeltable/ext/functions/__init__.py +8 -0
- pixeltable-0.2.14/pixeltable/ext/functions/whisperx.py +70 -0
- {pixeltable-0.2.12 → pixeltable-0.2.14}/pixeltable/ext/functions/yolox.py +60 -14
- {pixeltable-0.2.12 → pixeltable-0.2.14}/pixeltable/func/aggregate_function.py +10 -4
- {pixeltable-0.2.12 → pixeltable-0.2.14}/pixeltable/func/callable_function.py +16 -4
- {pixeltable-0.2.12 → pixeltable-0.2.14}/pixeltable/func/expr_template_function.py +1 -1
- {pixeltable-0.2.12 → pixeltable-0.2.14}/pixeltable/func/function.py +12 -2
- {pixeltable-0.2.12 → pixeltable-0.2.14}/pixeltable/func/function_registry.py +26 -9
- {pixeltable-0.2.12 → pixeltable-0.2.14}/pixeltable/func/udf.py +32 -4
- {pixeltable-0.2.12 → pixeltable-0.2.14}/pixeltable/functions/__init__.py +1 -1
- pixeltable-0.2.14/pixeltable/functions/fireworks.py +74 -0
- {pixeltable-0.2.12 → pixeltable-0.2.14}/pixeltable/functions/globals.py +36 -1
- {pixeltable-0.2.12 → pixeltable-0.2.14}/pixeltable/functions/huggingface.py +155 -7
- pixeltable-0.2.14/pixeltable/functions/image.py +387 -0
- pixeltable-0.2.14/pixeltable/functions/openai.py +475 -0
- pixeltable-0.2.14/pixeltable/functions/string.py +613 -0
- pixeltable-0.2.14/pixeltable/functions/timestamp.py +210 -0
- {pixeltable-0.2.12 → pixeltable-0.2.14}/pixeltable/functions/together.py +106 -0
- {pixeltable-0.2.12 → pixeltable-0.2.14}/pixeltable/functions/video.py +28 -10
- {pixeltable-0.2.12 → pixeltable-0.2.14}/pixeltable/functions/whisper.py +32 -0
- {pixeltable-0.2.12 → pixeltable-0.2.14}/pixeltable/globals.py +3 -3
- {pixeltable-0.2.12 → pixeltable-0.2.14}/pixeltable/io/__init__.py +1 -1
- pixeltable-0.2.14/pixeltable/io/globals.py +268 -0
- {pixeltable-0.2.12 → pixeltable-0.2.14}/pixeltable/io/label_studio.py +42 -2
- {pixeltable-0.2.12 → pixeltable-0.2.14}/pixeltable/io/pandas.py +70 -34
- {pixeltable-0.2.12 → pixeltable-0.2.14}/pixeltable/metadata/__init__.py +1 -1
- pixeltable-0.2.14/pixeltable/metadata/converters/convert_18.py +39 -0
- pixeltable-0.2.14/pixeltable/metadata/notes.py +10 -0
- {pixeltable-0.2.12 → pixeltable-0.2.14}/pixeltable/plan.py +82 -7
- {pixeltable-0.2.12 → pixeltable-0.2.14}/pixeltable/tool/create_test_db_dump.py +4 -5
- pixeltable-0.2.14/pixeltable/tool/doc_plugins/griffe.py +81 -0
- pixeltable-0.2.14/pixeltable/tool/doc_plugins/mkdocstrings.py +6 -0
- pixeltable-0.2.14/pixeltable/tool/doc_plugins/templates/material/udf.html.jinja +135 -0
- {pixeltable-0.2.12 → pixeltable-0.2.14}/pixeltable/type_system.py +15 -14
- {pixeltable-0.2.12 → pixeltable-0.2.14}/pixeltable/utils/s3.py +1 -1
- {pixeltable-0.2.12 → pixeltable-0.2.14}/pyproject.toml +4 -1
- pixeltable-0.2.12/PKG-INFO +0 -137
- pixeltable-0.2.12/README.md +0 -99
- pixeltable-0.2.12/pixeltable/exprs/image_member_access.py +0 -96
- pixeltable-0.2.12/pixeltable/exprs/predicate.py +0 -44
- pixeltable-0.2.12/pixeltable/ext/functions/whisperx.py +0 -30
- pixeltable-0.2.12/pixeltable/functions/fireworks.py +0 -41
- pixeltable-0.2.12/pixeltable/functions/image.py +0 -185
- pixeltable-0.2.12/pixeltable/functions/openai.py +0 -261
- pixeltable-0.2.12/pixeltable/functions/string.py +0 -21
- pixeltable-0.2.12/pixeltable/io/globals.py +0 -87
- {pixeltable-0.2.12 → pixeltable-0.2.14}/LICENSE +0 -0
- {pixeltable-0.2.12 → pixeltable-0.2.14}/pixeltable/catalog/__init__.py +0 -0
- {pixeltable-0.2.12 → pixeltable-0.2.14}/pixeltable/catalog/catalog.py +0 -0
- {pixeltable-0.2.12 → pixeltable-0.2.14}/pixeltable/catalog/dir.py +0 -0
- {pixeltable-0.2.12 → pixeltable-0.2.14}/pixeltable/catalog/named_function.py +0 -0
- {pixeltable-0.2.12 → pixeltable-0.2.14}/pixeltable/catalog/path.py +0 -0
- {pixeltable-0.2.12 → pixeltable-0.2.14}/pixeltable/catalog/path_dict.py +0 -0
- {pixeltable-0.2.12 → pixeltable-0.2.14}/pixeltable/catalog/schema_object.py +0 -0
- {pixeltable-0.2.12 → pixeltable-0.2.14}/pixeltable/catalog/table_version_path.py +0 -0
- {pixeltable-0.2.12 → pixeltable-0.2.14}/pixeltable/env.py +0 -0
- {pixeltable-0.2.12 → pixeltable-0.2.14}/pixeltable/exceptions.py +0 -0
- {pixeltable-0.2.12 → pixeltable-0.2.14}/pixeltable/exec/aggregation_node.py +0 -0
- {pixeltable-0.2.12 → pixeltable-0.2.14}/pixeltable/exec/cache_prefetch_node.py +0 -0
- {pixeltable-0.2.12 → pixeltable-0.2.14}/pixeltable/exec/component_iteration_node.py +0 -0
- {pixeltable-0.2.12 → pixeltable-0.2.14}/pixeltable/exec/data_row_batch.py +0 -0
- {pixeltable-0.2.12 → pixeltable-0.2.14}/pixeltable/exec/exec_context.py +0 -0
- {pixeltable-0.2.12 → pixeltable-0.2.14}/pixeltable/exec/exec_node.py +0 -0
- {pixeltable-0.2.12 → pixeltable-0.2.14}/pixeltable/exec/in_memory_data_node.py +0 -0
- {pixeltable-0.2.12 → pixeltable-0.2.14}/pixeltable/exec/media_validation_node.py +0 -0
- {pixeltable-0.2.12 → pixeltable-0.2.14}/pixeltable/exprs/arithmetic_expr.py +0 -0
- {pixeltable-0.2.12 → pixeltable-0.2.14}/pixeltable/exprs/array_slice.py +0 -0
- {pixeltable-0.2.12 → pixeltable-0.2.14}/pixeltable/exprs/column_property_ref.py +0 -0
- {pixeltable-0.2.12 → pixeltable-0.2.14}/pixeltable/exprs/column_ref.py +0 -0
- {pixeltable-0.2.12 → pixeltable-0.2.14}/pixeltable/exprs/data_row.py +0 -0
- {pixeltable-0.2.12 → pixeltable-0.2.14}/pixeltable/exprs/expr_set.py +0 -0
- {pixeltable-0.2.12 → pixeltable-0.2.14}/pixeltable/exprs/inline_dict.py +0 -0
- {pixeltable-0.2.12 → pixeltable-0.2.14}/pixeltable/exprs/json_mapper.py +0 -0
- {pixeltable-0.2.12 → pixeltable-0.2.14}/pixeltable/exprs/json_path.py +0 -0
- {pixeltable-0.2.12 → pixeltable-0.2.14}/pixeltable/exprs/literal.py +0 -0
- {pixeltable-0.2.12 → pixeltable-0.2.14}/pixeltable/exprs/object_ref.py +0 -0
- {pixeltable-0.2.12 → pixeltable-0.2.14}/pixeltable/exprs/row_builder.py +0 -0
- {pixeltable-0.2.12 → pixeltable-0.2.14}/pixeltable/exprs/rowid_ref.py +0 -0
- {pixeltable-0.2.12 → pixeltable-0.2.14}/pixeltable/exprs/similarity_expr.py +0 -0
- {pixeltable-0.2.12 → pixeltable-0.2.14}/pixeltable/exprs/type_cast.py +0 -0
- {pixeltable-0.2.12 → pixeltable-0.2.14}/pixeltable/exprs/variable.py +0 -0
- {pixeltable-0.2.12 → pixeltable-0.2.14}/pixeltable/func/__init__.py +0 -0
- {pixeltable-0.2.12 → pixeltable-0.2.14}/pixeltable/func/globals.py +0 -0
- {pixeltable-0.2.12 → pixeltable-0.2.14}/pixeltable/func/query_template_function.py +0 -0
- {pixeltable-0.2.12 → pixeltable-0.2.14}/pixeltable/func/signature.py +0 -0
- {pixeltable-0.2.12 → pixeltable-0.2.14}/pixeltable/functions/eval.py +0 -0
- {pixeltable-0.2.12 → pixeltable-0.2.14}/pixeltable/functions/util.py +0 -0
- {pixeltable-0.2.12 → pixeltable-0.2.14}/pixeltable/index/__init__.py +0 -0
- {pixeltable-0.2.12 → pixeltable-0.2.14}/pixeltable/index/base.py +0 -0
- {pixeltable-0.2.12 → pixeltable-0.2.14}/pixeltable/index/btree.py +0 -0
- {pixeltable-0.2.12 → pixeltable-0.2.14}/pixeltable/index/embedding_index.py +0 -0
- {pixeltable-0.2.12 → pixeltable-0.2.14}/pixeltable/io/external_store.py +0 -0
- {pixeltable-0.2.12 → pixeltable-0.2.14}/pixeltable/io/hf_datasets.py +0 -0
- {pixeltable-0.2.12 → pixeltable-0.2.14}/pixeltable/io/parquet.py +0 -0
- {pixeltable-0.2.12 → pixeltable-0.2.14}/pixeltable/iterators/__init__.py +0 -0
- {pixeltable-0.2.12 → pixeltable-0.2.14}/pixeltable/iterators/base.py +0 -0
- {pixeltable-0.2.12 → pixeltable-0.2.14}/pixeltable/iterators/document.py +0 -0
- {pixeltable-0.2.12 → pixeltable-0.2.14}/pixeltable/iterators/string.py +0 -0
- {pixeltable-0.2.12 → pixeltable-0.2.14}/pixeltable/iterators/video.py +0 -0
- {pixeltable-0.2.12 → pixeltable-0.2.14}/pixeltable/metadata/converters/convert_10.py +0 -0
- {pixeltable-0.2.12 → pixeltable-0.2.14}/pixeltable/metadata/converters/convert_12.py +0 -0
- {pixeltable-0.2.12 → pixeltable-0.2.14}/pixeltable/metadata/converters/convert_13.py +0 -0
- {pixeltable-0.2.12 → pixeltable-0.2.14}/pixeltable/metadata/converters/convert_14.py +0 -0
- {pixeltable-0.2.12 → pixeltable-0.2.14}/pixeltable/metadata/converters/convert_15.py +0 -0
- {pixeltable-0.2.12 → pixeltable-0.2.14}/pixeltable/metadata/converters/convert_16.py +0 -0
- {pixeltable-0.2.12 → pixeltable-0.2.14}/pixeltable/metadata/converters/convert_17.py +0 -0
- {pixeltable-0.2.12 → pixeltable-0.2.14}/pixeltable/metadata/converters/util.py +0 -0
- {pixeltable-0.2.12 → pixeltable-0.2.14}/pixeltable/metadata/schema.py +0 -0
- {pixeltable-0.2.12 → pixeltable-0.2.14}/pixeltable/store.py +0 -0
- {pixeltable-0.2.12 → pixeltable-0.2.14}/pixeltable/tool/create_test_video.py +0 -0
- {pixeltable-0.2.12 → pixeltable-0.2.14}/pixeltable/tool/embed_udf.py +0 -0
- {pixeltable-0.2.12 → pixeltable-0.2.14}/pixeltable/utils/__init__.py +0 -0
- {pixeltable-0.2.12 → pixeltable-0.2.14}/pixeltable/utils/arrow.py +0 -0
- {pixeltable-0.2.12 → pixeltable-0.2.14}/pixeltable/utils/coco.py +0 -0
- {pixeltable-0.2.12 → pixeltable-0.2.14}/pixeltable/utils/code.py +0 -0
- {pixeltable-0.2.12 → pixeltable-0.2.14}/pixeltable/utils/documents.py +0 -0
- {pixeltable-0.2.12 → pixeltable-0.2.14}/pixeltable/utils/filecache.py +0 -0
- {pixeltable-0.2.12 → pixeltable-0.2.14}/pixeltable/utils/formatter.py +0 -0
- {pixeltable-0.2.12 → pixeltable-0.2.14}/pixeltable/utils/help.py +0 -0
- {pixeltable-0.2.12 → pixeltable-0.2.14}/pixeltable/utils/http_server.py +0 -0
- {pixeltable-0.2.12 → pixeltable-0.2.14}/pixeltable/utils/media_store.py +0 -0
- {pixeltable-0.2.12 → pixeltable-0.2.14}/pixeltable/utils/pytorch.py +0 -0
- {pixeltable-0.2.12 → pixeltable-0.2.14}/pixeltable/utils/sql.py +0 -0
- {pixeltable-0.2.12 → pixeltable-0.2.14}/pixeltable/utils/transactional_directory.py +0 -0
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: pixeltable
|
|
3
|
+
Version: 0.2.14
|
|
4
|
+
Summary: Pixeltable: The Multimodal AI Data Plane
|
|
5
|
+
Author: Pixeltable, Inc.
|
|
6
|
+
Author-email: contact@pixeltable.com
|
|
7
|
+
Requires-Python: >=3.9,<4.0
|
|
8
|
+
Classifier: Programming Language :: Python :: 3
|
|
9
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
10
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
13
|
+
Requires-Dist: av (>=10.0.0)
|
|
14
|
+
Requires-Dist: beautifulsoup4 (>=4.0.0,<5.0.0)
|
|
15
|
+
Requires-Dist: cloudpickle (>=2.2.1,<3.0.0)
|
|
16
|
+
Requires-Dist: ftfy (>=6.2.0,<7.0.0)
|
|
17
|
+
Requires-Dist: jinja2 (>=3.1.3,<4.0.0)
|
|
18
|
+
Requires-Dist: jmespath (>=1.0.1,<2.0.0)
|
|
19
|
+
Requires-Dist: mistune (>=3.0.2,<4.0.0)
|
|
20
|
+
Requires-Dist: more-itertools (>=10.2,<11.0)
|
|
21
|
+
Requires-Dist: numpy (>=1.25)
|
|
22
|
+
Requires-Dist: opencv-python-headless (>=4.7.0.68,<5.0.0.0)
|
|
23
|
+
Requires-Dist: pandas (>=2.0,<3.0)
|
|
24
|
+
Requires-Dist: pgserver (==0.1.4)
|
|
25
|
+
Requires-Dist: pgvector (>=0.2.1,<0.3.0)
|
|
26
|
+
Requires-Dist: pillow (>=9.3.0)
|
|
27
|
+
Requires-Dist: psutil (>=5.9.5,<6.0.0)
|
|
28
|
+
Requires-Dist: psycopg2-binary (>=2.9.5,<3.0.0)
|
|
29
|
+
Requires-Dist: pymupdf (>=1.24.1,<2.0.0)
|
|
30
|
+
Requires-Dist: pyyaml (>=6.0.1,<7.0.0)
|
|
31
|
+
Requires-Dist: requests (>=2.31.0,<3.0.0)
|
|
32
|
+
Requires-Dist: setuptools (==69.1.1)
|
|
33
|
+
Requires-Dist: sqlalchemy[mypy] (>=2.0.23,<3.0.0)
|
|
34
|
+
Requires-Dist: tenacity (>=8.2,<9.0)
|
|
35
|
+
Requires-Dist: tqdm (>=4.64)
|
|
36
|
+
Description-Content-Type: text/markdown
|
|
37
|
+
|
|
38
|
+
<div align="center">
|
|
39
|
+
<img src="https://raw.githubusercontent.com/pixeltable/pixeltable/master/docs/release/pixeltable-banner.png" alt="Pixeltable" width="45%" />
|
|
40
|
+
|
|
41
|
+
# Unifying Data, Models, and Orchestration for AI Products
|
|
42
|
+
|
|
43
|
+
[](https://opensource.org/licenses/Apache-2.0)
|
|
44
|
+

|
|
45
|
+
[]()
|
|
46
|
+
[](https://github.com/pixeltable/pixeltable/actions)
|
|
47
|
+
[](https://pypi.org/project/pixeltable/)
|
|
48
|
+
|
|
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/master/docs/release/tutorials)
|
|
50
|
+
</div>
|
|
51
|
+
|
|
52
|
+
Pixeltable is a Python library that lets ML Engineers and Data Scientists focus on exploration, modeling, and app development without dealing with the customary data plumbing.
|
|
53
|
+
|
|
54
|
+
### What problems does Pixeltable solve?
|
|
55
|
+
|
|
56
|
+
Today’s solutions for AI app development require extensive custom coding and infrastructure plumbing. Tracking lineage and versions between and across data transformations, models, and deployment is cumbersome.
|
|
57
|
+
|
|
58
|
+
## 💾 Installation
|
|
59
|
+
|
|
60
|
+
```python
|
|
61
|
+
pip install pixeltable
|
|
62
|
+
```
|
|
63
|
+
> [!IMPORTANT]
|
|
64
|
+
> Pixeltable is persistent. Unlike in-memory Python libraries such as Pandas, Pixeltable is a database. When working locally or against an hosted version of Pixeltable, use [get_table](https://pixeltable.github.io/pixeltable/api/pixeltable/#pixeltable.get_table) at any time to retrieve an existing table.
|
|
65
|
+
|
|
66
|
+
## 💡 Getting Started
|
|
67
|
+
Learn how to create tables, populate them with data, and enhance them with built-in or user-defined transformations and AI operations.
|
|
68
|
+
|
|
69
|
+
| Topic | Notebook | Topic | Notebook |
|
|
70
|
+
|:----------|:-----------------|:-------------------------|:---------------------------------:|
|
|
71
|
+
| 10-Minute Tour of Pixeltable | <a target="_blank" href="https://colab.research.google.com/github/pixeltable/pixeltable/blob/master/docs/release/tutorials/pixeltable-basics.ipynb"> <img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"/> </a> | Tables and Data Operations | <a target="_blank" href="https://colab.research.google.com/github/pixeltable/pixeltable/blob/master/docs/release/fundamentals/tables-and-data-operations.ipynb"> <img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"/> </a>
|
|
72
|
+
| User-Defined Functions (UDFs) | <a target="_blank" href="https://colab.research.google.com/github/pixeltable/pixeltable/blob/master/docs/release/howto/udfs-in-pixeltable.ipynb"> <img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"/> </a> | Object Detection Models | <a target="_blank" href="https://colab.research.google.com/github/pixeltable/pixeltable/blob/master/docs/release/tutorials/object-detection-in-videos.ipynb"> <img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"/> </a>
|
|
73
|
+
| Experimenting with Chunking (RAG) | <a target="_blank" href="https://colab.research.google.com/github/pixeltable/pixeltable/blob/master/docs/release/tutorials/rag-operations.ipynb"> <img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"/> | Working with External Files | <a target="_blank" href="https://colab.research.google.com/github/pixeltable/pixeltable/blob/master/docs/release/howto/working-with-external-files.ipynb"> <img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"/> </a>
|
|
74
|
+
| Integrating with Label Studio | <a target="_blank" href="https://pixeltable.readme.io/docs/label-studio"> <img src="https://img.shields.io/badge/Docs-Label Studio-blue" alt="Visit our documentation"/></a> | Audio/Video Transcript Indexing | <a target="_blank" href="https://colab.research.google.com/github/pixeltable/pixeltable/blob/master/docs/release/tutorials/audio-transcriptions.ipynb"> <img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"/> </a>
|
|
75
|
+
|
|
76
|
+
## 🧱 Code Samples
|
|
77
|
+
|
|
78
|
+
### Import media data into Pixeltable (videos, images, audio...)
|
|
79
|
+
```python
|
|
80
|
+
import pixeltable as pxt
|
|
81
|
+
|
|
82
|
+
v = pxt.create_table('external_data.videos', {'video': pxt.VideoType()})
|
|
83
|
+
|
|
84
|
+
prefix = 's3://multimedia-commons/'
|
|
85
|
+
paths = [
|
|
86
|
+
'data/videos/mp4/ffe/ffb/ffeffbef41bbc269810b2a1a888de.mp4',
|
|
87
|
+
'data/videos/mp4/ffe/feb/ffefebb41485539f964760e6115fbc44.mp4',
|
|
88
|
+
'data/videos/mp4/ffe/f73/ffef7384d698b5f70d411c696247169.mp4'
|
|
89
|
+
]
|
|
90
|
+
v.insert({'video': prefix + p} for p in paths)
|
|
91
|
+
```
|
|
92
|
+
Learn how to [work with data in Pixeltable](https://pixeltable.readme.io/docs/working-with-external-files).
|
|
93
|
+
|
|
94
|
+
### Add an object detection model to your workflow
|
|
95
|
+
```python
|
|
96
|
+
table['detections'] = huggingface.detr_for_object_detection(table.input_image, model_id='facebook/detr-resnet-50')
|
|
97
|
+
```
|
|
98
|
+
Learn about computed columns and object detection: [Comparing object detection models](https://pixeltable.readme.io/docs/object-detection-in-videos).
|
|
99
|
+
|
|
100
|
+
### Extend Pixeltable's capabilities with user-defined functions
|
|
101
|
+
```python
|
|
102
|
+
@pxt.udf
|
|
103
|
+
def draw_boxes(img: PIL.Image.Image, boxes: list[list[float]]) -> PIL.Image.Image:
|
|
104
|
+
result = img.copy() # Create a copy of `img`
|
|
105
|
+
d = PIL.ImageDraw.Draw(result)
|
|
106
|
+
for box in boxes:
|
|
107
|
+
d.rectangle(box, width=3) # Draw bounding box rectangles on the copied image
|
|
108
|
+
return result
|
|
109
|
+
```
|
|
110
|
+
Learn more about user-defined functions: [UDFs in Pixeltable](https://pixeltable.readme.io/docs/user-defined-functions-udfs).
|
|
111
|
+
|
|
112
|
+
### Automate data operations with views
|
|
113
|
+
```python
|
|
114
|
+
# In this example, the view is defined by iteration over the chunks of a DocumentSplitter.
|
|
115
|
+
chunks_table = pxt.create_view(
|
|
116
|
+
'rag_demo.chunks',
|
|
117
|
+
documents_table,
|
|
118
|
+
iterator=DocumentSplitter.create(
|
|
119
|
+
document=documents_table.document,
|
|
120
|
+
separators='token_limit', limit=300)
|
|
121
|
+
)
|
|
122
|
+
```
|
|
123
|
+
Learn how to leverage views to build your [RAG workflow](https://pixeltable.readme.io/docs/document-indexing-and-rag).
|
|
124
|
+
|
|
125
|
+
### Evaluate model performance
|
|
126
|
+
```python
|
|
127
|
+
# The computation of the mAP metric can simply become a query over the evaluation output, aggregated with the mean_ap() function.
|
|
128
|
+
frames_view.select(mean_ap(frames_view.eval_yolox_tiny), mean_ap(frames_view.eval_yolox_m)).show()
|
|
129
|
+
```
|
|
130
|
+
Learn how to leverage Pixeltable for [Model analytics](https://pixeltable.readme.io/docs/object-detection-in-videos).
|
|
131
|
+
|
|
132
|
+
### Working with inference services
|
|
133
|
+
```python
|
|
134
|
+
chat_table = pxt.create_table('together_demo.chat', {'input': pxt.StringType()})
|
|
135
|
+
|
|
136
|
+
# The chat-completions API expects JSON-formatted input:
|
|
137
|
+
messages = [{'role': 'user', 'content': chat_table.input}]
|
|
138
|
+
|
|
139
|
+
# This example shows how additional parameters from the Together API can be used in Pixeltable to customize the model behavior.
|
|
140
|
+
chat_table['output'] = chat_completions(
|
|
141
|
+
messages=messages,
|
|
142
|
+
model='mistralai/Mixtral-8x7B-Instruct-v0.1',
|
|
143
|
+
max_tokens=300,
|
|
144
|
+
stop=['\n'],
|
|
145
|
+
temperature=0.7,
|
|
146
|
+
top_p=0.9,
|
|
147
|
+
top_k=40,
|
|
148
|
+
repetition_penalty=1.1,
|
|
149
|
+
logprobs=1,
|
|
150
|
+
echo=True
|
|
151
|
+
)
|
|
152
|
+
chat_table['response'] = chat_table.output.choices[0].message.content
|
|
153
|
+
|
|
154
|
+
# Start a conversation
|
|
155
|
+
chat_table.insert([
|
|
156
|
+
{'input': 'How many species of felids have been classified?'},
|
|
157
|
+
{'input': 'Can you make me a coffee?'}
|
|
158
|
+
])
|
|
159
|
+
chat_table.select(chat_table.input, chat_table.response).head()
|
|
160
|
+
```
|
|
161
|
+
Learn how to interact with inference services such as [Together AI](https://pixeltable.readme.io/docs/together-ai) in Pixeltable.
|
|
162
|
+
|
|
163
|
+
## ❓ FAQ
|
|
164
|
+
|
|
165
|
+
### What is Pixeltable?
|
|
166
|
+
|
|
167
|
+
Pixeltable unifies data storage, versioning, and indexing with orchestration and model versioning under a declarative table interface, with transformations, model inference, and custom logic represented as computed columns.
|
|
168
|
+
|
|
169
|
+
### What does Pixeltable provide me with? Pixeltable provides:
|
|
170
|
+
|
|
171
|
+
- Data storage and versioning
|
|
172
|
+
- Combined Data and Model Lineage
|
|
173
|
+
- Indexing (e.g. embedding vectors) and Data Retrieval
|
|
174
|
+
- Orchestration of multimodal workloads
|
|
175
|
+
- Incremental updates
|
|
176
|
+
- Code is automatically production-ready
|
|
177
|
+
|
|
178
|
+
### Why should you use Pixeltable?
|
|
179
|
+
|
|
180
|
+
- **It gives you transparency and reproducibility**
|
|
181
|
+
- All generated data is automatically recorded and versioned
|
|
182
|
+
- You will never need to re-run a workload because you lost track of the input data
|
|
183
|
+
- **It saves you money**
|
|
184
|
+
- All data changes are automatically incremental
|
|
185
|
+
- You never need to re-run pipelines from scratch because you’re adding data
|
|
186
|
+
- **It integrates with any existing Python code or libraries**
|
|
187
|
+
- Bring your ever-changing code and workloads
|
|
188
|
+
- You choose the models, tools, and AI practices (e.g., your embedding model for a vector index); Pixeltable orchestrates the data
|
|
189
|
+
|
|
190
|
+
### What is Pixeltable not providing?
|
|
191
|
+
|
|
192
|
+
- Pixeltable is not a low-code, prescriptive AI solution. We empower you to use the best frameworks and techniques for your specific needs.
|
|
193
|
+
- We do not aim to replace your existing AI toolkit, but rather enhance it by streamlining the underlying data infrastructure and orchestration.
|
|
194
|
+
|
|
195
|
+
> [!TIP]
|
|
196
|
+
> Check out the [Integrations](https://pixeltable.readme.io/docs/working-with-openai) section, and feel free to submit a request for additional ones.
|
|
197
|
+
|
|
198
|
+
## 🐛 Contributions & Feedback
|
|
199
|
+
|
|
200
|
+
Are you experiencing issues or bugs with Pixeltable? File an [Issue](https://github.com/pixeltable/pixeltable/issues).
|
|
201
|
+
</br>Do you want to contribute? Feel free to open a [PR](https://github.com/pixeltable/pixeltable/pulls).
|
|
202
|
+
|
|
203
|
+
## :classical_building: License
|
|
204
|
+
|
|
205
|
+
This library is licensed under the Apache 2.0 License.
|
|
206
|
+
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
<img src="https://raw.githubusercontent.com/pixeltable/pixeltable/master/docs/release/pixeltable-banner.png" alt="Pixeltable" width="45%" />
|
|
3
|
+
|
|
4
|
+
# Unifying Data, Models, and Orchestration for AI Products
|
|
5
|
+
|
|
6
|
+
[](https://opensource.org/licenses/Apache-2.0)
|
|
7
|
+

|
|
8
|
+
[]()
|
|
9
|
+
[](https://github.com/pixeltable/pixeltable/actions)
|
|
10
|
+
[](https://pypi.org/project/pixeltable/)
|
|
11
|
+
|
|
12
|
+
[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/master/docs/release/tutorials)
|
|
13
|
+
</div>
|
|
14
|
+
|
|
15
|
+
Pixeltable is a Python library that lets ML Engineers and Data Scientists focus on exploration, modeling, and app development without dealing with the customary data plumbing.
|
|
16
|
+
|
|
17
|
+
### What problems does Pixeltable solve?
|
|
18
|
+
|
|
19
|
+
Today’s solutions for AI app development require extensive custom coding and infrastructure plumbing. Tracking lineage and versions between and across data transformations, models, and deployment is cumbersome.
|
|
20
|
+
|
|
21
|
+
## 💾 Installation
|
|
22
|
+
|
|
23
|
+
```python
|
|
24
|
+
pip install pixeltable
|
|
25
|
+
```
|
|
26
|
+
> [!IMPORTANT]
|
|
27
|
+
> Pixeltable is persistent. Unlike in-memory Python libraries such as Pandas, Pixeltable is a database. When working locally or against an hosted version of Pixeltable, use [get_table](https://pixeltable.github.io/pixeltable/api/pixeltable/#pixeltable.get_table) at any time to retrieve an existing table.
|
|
28
|
+
|
|
29
|
+
## 💡 Getting Started
|
|
30
|
+
Learn how to create tables, populate them with data, and enhance them with built-in or user-defined transformations and AI operations.
|
|
31
|
+
|
|
32
|
+
| Topic | Notebook | Topic | Notebook |
|
|
33
|
+
|:----------|:-----------------|:-------------------------|:---------------------------------:|
|
|
34
|
+
| 10-Minute Tour of Pixeltable | <a target="_blank" href="https://colab.research.google.com/github/pixeltable/pixeltable/blob/master/docs/release/tutorials/pixeltable-basics.ipynb"> <img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"/> </a> | Tables and Data Operations | <a target="_blank" href="https://colab.research.google.com/github/pixeltable/pixeltable/blob/master/docs/release/fundamentals/tables-and-data-operations.ipynb"> <img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"/> </a>
|
|
35
|
+
| User-Defined Functions (UDFs) | <a target="_blank" href="https://colab.research.google.com/github/pixeltable/pixeltable/blob/master/docs/release/howto/udfs-in-pixeltable.ipynb"> <img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"/> </a> | Object Detection Models | <a target="_blank" href="https://colab.research.google.com/github/pixeltable/pixeltable/blob/master/docs/release/tutorials/object-detection-in-videos.ipynb"> <img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"/> </a>
|
|
36
|
+
| Experimenting with Chunking (RAG) | <a target="_blank" href="https://colab.research.google.com/github/pixeltable/pixeltable/blob/master/docs/release/tutorials/rag-operations.ipynb"> <img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"/> | Working with External Files | <a target="_blank" href="https://colab.research.google.com/github/pixeltable/pixeltable/blob/master/docs/release/howto/working-with-external-files.ipynb"> <img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"/> </a>
|
|
37
|
+
| Integrating with Label Studio | <a target="_blank" href="https://pixeltable.readme.io/docs/label-studio"> <img src="https://img.shields.io/badge/Docs-Label Studio-blue" alt="Visit our documentation"/></a> | Audio/Video Transcript Indexing | <a target="_blank" href="https://colab.research.google.com/github/pixeltable/pixeltable/blob/master/docs/release/tutorials/audio-transcriptions.ipynb"> <img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"/> </a>
|
|
38
|
+
|
|
39
|
+
## 🧱 Code Samples
|
|
40
|
+
|
|
41
|
+
### Import media data into Pixeltable (videos, images, audio...)
|
|
42
|
+
```python
|
|
43
|
+
import pixeltable as pxt
|
|
44
|
+
|
|
45
|
+
v = pxt.create_table('external_data.videos', {'video': pxt.VideoType()})
|
|
46
|
+
|
|
47
|
+
prefix = 's3://multimedia-commons/'
|
|
48
|
+
paths = [
|
|
49
|
+
'data/videos/mp4/ffe/ffb/ffeffbef41bbc269810b2a1a888de.mp4',
|
|
50
|
+
'data/videos/mp4/ffe/feb/ffefebb41485539f964760e6115fbc44.mp4',
|
|
51
|
+
'data/videos/mp4/ffe/f73/ffef7384d698b5f70d411c696247169.mp4'
|
|
52
|
+
]
|
|
53
|
+
v.insert({'video': prefix + p} for p in paths)
|
|
54
|
+
```
|
|
55
|
+
Learn how to [work with data in Pixeltable](https://pixeltable.readme.io/docs/working-with-external-files).
|
|
56
|
+
|
|
57
|
+
### Add an object detection model to your workflow
|
|
58
|
+
```python
|
|
59
|
+
table['detections'] = huggingface.detr_for_object_detection(table.input_image, model_id='facebook/detr-resnet-50')
|
|
60
|
+
```
|
|
61
|
+
Learn about computed columns and object detection: [Comparing object detection models](https://pixeltable.readme.io/docs/object-detection-in-videos).
|
|
62
|
+
|
|
63
|
+
### Extend Pixeltable's capabilities with user-defined functions
|
|
64
|
+
```python
|
|
65
|
+
@pxt.udf
|
|
66
|
+
def draw_boxes(img: PIL.Image.Image, boxes: list[list[float]]) -> PIL.Image.Image:
|
|
67
|
+
result = img.copy() # Create a copy of `img`
|
|
68
|
+
d = PIL.ImageDraw.Draw(result)
|
|
69
|
+
for box in boxes:
|
|
70
|
+
d.rectangle(box, width=3) # Draw bounding box rectangles on the copied image
|
|
71
|
+
return result
|
|
72
|
+
```
|
|
73
|
+
Learn more about user-defined functions: [UDFs in Pixeltable](https://pixeltable.readme.io/docs/user-defined-functions-udfs).
|
|
74
|
+
|
|
75
|
+
### Automate data operations with views
|
|
76
|
+
```python
|
|
77
|
+
# In this example, the view is defined by iteration over the chunks of a DocumentSplitter.
|
|
78
|
+
chunks_table = pxt.create_view(
|
|
79
|
+
'rag_demo.chunks',
|
|
80
|
+
documents_table,
|
|
81
|
+
iterator=DocumentSplitter.create(
|
|
82
|
+
document=documents_table.document,
|
|
83
|
+
separators='token_limit', limit=300)
|
|
84
|
+
)
|
|
85
|
+
```
|
|
86
|
+
Learn how to leverage views to build your [RAG workflow](https://pixeltable.readme.io/docs/document-indexing-and-rag).
|
|
87
|
+
|
|
88
|
+
### Evaluate model performance
|
|
89
|
+
```python
|
|
90
|
+
# The computation of the mAP metric can simply become a query over the evaluation output, aggregated with the mean_ap() function.
|
|
91
|
+
frames_view.select(mean_ap(frames_view.eval_yolox_tiny), mean_ap(frames_view.eval_yolox_m)).show()
|
|
92
|
+
```
|
|
93
|
+
Learn how to leverage Pixeltable for [Model analytics](https://pixeltable.readme.io/docs/object-detection-in-videos).
|
|
94
|
+
|
|
95
|
+
### Working with inference services
|
|
96
|
+
```python
|
|
97
|
+
chat_table = pxt.create_table('together_demo.chat', {'input': pxt.StringType()})
|
|
98
|
+
|
|
99
|
+
# The chat-completions API expects JSON-formatted input:
|
|
100
|
+
messages = [{'role': 'user', 'content': chat_table.input}]
|
|
101
|
+
|
|
102
|
+
# This example shows how additional parameters from the Together API can be used in Pixeltable to customize the model behavior.
|
|
103
|
+
chat_table['output'] = chat_completions(
|
|
104
|
+
messages=messages,
|
|
105
|
+
model='mistralai/Mixtral-8x7B-Instruct-v0.1',
|
|
106
|
+
max_tokens=300,
|
|
107
|
+
stop=['\n'],
|
|
108
|
+
temperature=0.7,
|
|
109
|
+
top_p=0.9,
|
|
110
|
+
top_k=40,
|
|
111
|
+
repetition_penalty=1.1,
|
|
112
|
+
logprobs=1,
|
|
113
|
+
echo=True
|
|
114
|
+
)
|
|
115
|
+
chat_table['response'] = chat_table.output.choices[0].message.content
|
|
116
|
+
|
|
117
|
+
# Start a conversation
|
|
118
|
+
chat_table.insert([
|
|
119
|
+
{'input': 'How many species of felids have been classified?'},
|
|
120
|
+
{'input': 'Can you make me a coffee?'}
|
|
121
|
+
])
|
|
122
|
+
chat_table.select(chat_table.input, chat_table.response).head()
|
|
123
|
+
```
|
|
124
|
+
Learn how to interact with inference services such as [Together AI](https://pixeltable.readme.io/docs/together-ai) in Pixeltable.
|
|
125
|
+
|
|
126
|
+
## ❓ FAQ
|
|
127
|
+
|
|
128
|
+
### What is Pixeltable?
|
|
129
|
+
|
|
130
|
+
Pixeltable unifies data storage, versioning, and indexing with orchestration and model versioning under a declarative table interface, with transformations, model inference, and custom logic represented as computed columns.
|
|
131
|
+
|
|
132
|
+
### What does Pixeltable provide me with? Pixeltable provides:
|
|
133
|
+
|
|
134
|
+
- Data storage and versioning
|
|
135
|
+
- Combined Data and Model Lineage
|
|
136
|
+
- Indexing (e.g. embedding vectors) and Data Retrieval
|
|
137
|
+
- Orchestration of multimodal workloads
|
|
138
|
+
- Incremental updates
|
|
139
|
+
- Code is automatically production-ready
|
|
140
|
+
|
|
141
|
+
### Why should you use Pixeltable?
|
|
142
|
+
|
|
143
|
+
- **It gives you transparency and reproducibility**
|
|
144
|
+
- All generated data is automatically recorded and versioned
|
|
145
|
+
- You will never need to re-run a workload because you lost track of the input data
|
|
146
|
+
- **It saves you money**
|
|
147
|
+
- All data changes are automatically incremental
|
|
148
|
+
- You never need to re-run pipelines from scratch because you’re adding data
|
|
149
|
+
- **It integrates with any existing Python code or libraries**
|
|
150
|
+
- Bring your ever-changing code and workloads
|
|
151
|
+
- You choose the models, tools, and AI practices (e.g., your embedding model for a vector index); Pixeltable orchestrates the data
|
|
152
|
+
|
|
153
|
+
### What is Pixeltable not providing?
|
|
154
|
+
|
|
155
|
+
- Pixeltable is not a low-code, prescriptive AI solution. We empower you to use the best frameworks and techniques for your specific needs.
|
|
156
|
+
- We do not aim to replace your existing AI toolkit, but rather enhance it by streamlining the underlying data infrastructure and orchestration.
|
|
157
|
+
|
|
158
|
+
> [!TIP]
|
|
159
|
+
> Check out the [Integrations](https://pixeltable.readme.io/docs/working-with-openai) section, and feel free to submit a request for additional ones.
|
|
160
|
+
|
|
161
|
+
## 🐛 Contributions & Feedback
|
|
162
|
+
|
|
163
|
+
Are you experiencing issues or bugs with Pixeltable? File an [Issue](https://github.com/pixeltable/pixeltable/issues).
|
|
164
|
+
</br>Do you want to contribute? Feel free to open a [PR](https://github.com/pixeltable/pixeltable/pulls).
|
|
165
|
+
|
|
166
|
+
## :classical_building: License
|
|
167
|
+
|
|
168
|
+
This library is licensed under the Apache 2.0 License.
|
|
@@ -21,7 +21,7 @@ from .type_system import (
|
|
|
21
21
|
)
|
|
22
22
|
from .utils.help import help
|
|
23
23
|
|
|
24
|
-
from . import functions, io, iterators
|
|
24
|
+
from . import ext, functions, io, iterators
|
|
25
25
|
from .__version__ import __version__, __version_tuple__
|
|
26
26
|
|
|
27
27
|
# This is the safest / most maintainable way to do this: start with the default and "blacklist" stuff that
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
# These version placeholders will be replaced during build.
|
|
2
|
-
__version__ = "0.2.
|
|
3
|
-
__version_tuple__ = (0, 2,
|
|
2
|
+
__version__ = "0.2.14"
|
|
3
|
+
__version_tuple__ = (0, 2, 14)
|
|
@@ -152,6 +152,11 @@ class Column:
|
|
|
152
152
|
return self._records_errors
|
|
153
153
|
return self.is_stored and (self.is_computed or self.col_type.is_media_type())
|
|
154
154
|
|
|
155
|
+
@property
|
|
156
|
+
def qualified_name(self) -> str:
|
|
157
|
+
assert self.tbl is not None
|
|
158
|
+
return f'{self.tbl.name}.{self.name}'
|
|
159
|
+
|
|
155
160
|
def source(self) -> None:
|
|
156
161
|
"""
|
|
157
162
|
If this is a computed col and the top-level expr is a function call, print the source, if possible.
|
|
@@ -19,6 +19,14 @@ class UpdateStatus:
|
|
|
19
19
|
updated_cols: List[str] = dataclasses.field(default_factory=list)
|
|
20
20
|
cols_with_excs: List[str] = dataclasses.field(default_factory=list)
|
|
21
21
|
|
|
22
|
+
def __iadd__(self, other: 'UpdateStatus') -> 'UpdateStatus':
|
|
23
|
+
self.num_rows += other.num_rows
|
|
24
|
+
self.num_computed_values += other.num_computed_values
|
|
25
|
+
self.num_excs += other.num_excs
|
|
26
|
+
self.updated_cols = list(dict.fromkeys(self.updated_cols + other.updated_cols))
|
|
27
|
+
self.cols_with_excs = list(dict.fromkeys(self.cols_with_excs + other.cols_with_excs))
|
|
28
|
+
return self
|
|
29
|
+
|
|
22
30
|
def is_valid_identifier(name: str) -> bool:
|
|
23
31
|
return name.isidentifier() and not name.startswith('_')
|
|
24
32
|
|
|
@@ -129,11 +129,11 @@ class InsertableTable(Table):
|
|
|
129
129
|
msg = str(e)
|
|
130
130
|
raise excs.Error(f'Error in column {col.name}: {msg[0].lower() + msg[1:]}\nRow: {row}')
|
|
131
131
|
|
|
132
|
-
def delete(self, where: Optional['pixeltable.exprs.
|
|
132
|
+
def delete(self, where: Optional['pixeltable.exprs.Expr'] = None) -> UpdateStatus:
|
|
133
133
|
"""Delete rows in this table.
|
|
134
134
|
|
|
135
135
|
Args:
|
|
136
|
-
where: a
|
|
136
|
+
where: a predicate to filter rows to delete.
|
|
137
137
|
|
|
138
138
|
Examples:
|
|
139
139
|
Delete all rows in a table:
|
|
@@ -3,7 +3,7 @@ from __future__ import annotations
|
|
|
3
3
|
import json
|
|
4
4
|
import logging
|
|
5
5
|
from pathlib import Path
|
|
6
|
-
from typing import Union, Any, Optional, Callable, Set, Tuple, Iterable, overload, Type
|
|
6
|
+
from typing import Union, Any, Optional, Callable, Set, Tuple, Iterable, overload, Type, Literal
|
|
7
7
|
from uuid import UUID
|
|
8
8
|
import abc
|
|
9
9
|
|
|
@@ -113,7 +113,7 @@ class Table(SchemaObject):
|
|
|
113
113
|
from pixeltable.dataframe import DataFrame
|
|
114
114
|
return DataFrame(self._tbl_version_path).select(*items, **named_items)
|
|
115
115
|
|
|
116
|
-
def where(self, pred: 'exprs.
|
|
116
|
+
def where(self, pred: 'exprs.Expr') -> 'pixeltable.dataframe.DataFrame':
|
|
117
117
|
"""Return a DataFrame for this table.
|
|
118
118
|
"""
|
|
119
119
|
# local import: avoid circular imports
|
|
@@ -716,13 +716,13 @@ class Table(SchemaObject):
|
|
|
716
716
|
raise NotImplementedError
|
|
717
717
|
|
|
718
718
|
def update(
|
|
719
|
-
self, value_spec: dict[str, Any], where: Optional['pixeltable.exprs.
|
|
719
|
+
self, value_spec: dict[str, Any], where: Optional['pixeltable.exprs.Expr'] = None, cascade: bool = True
|
|
720
720
|
) -> UpdateStatus:
|
|
721
721
|
"""Update rows in this table.
|
|
722
722
|
|
|
723
723
|
Args:
|
|
724
724
|
value_spec: a dictionary mapping column names to literal values or Pixeltable expressions.
|
|
725
|
-
where: a
|
|
725
|
+
where: a predicate to filter rows to update.
|
|
726
726
|
cascade: if True, also update all computed columns that transitively depend on the updated columns.
|
|
727
727
|
|
|
728
728
|
Examples:
|
|
@@ -745,18 +745,34 @@ class Table(SchemaObject):
|
|
|
745
745
|
self._check_is_dropped()
|
|
746
746
|
return self._tbl_version.update(value_spec, where, cascade)
|
|
747
747
|
|
|
748
|
-
def batch_update(
|
|
748
|
+
def batch_update(
|
|
749
|
+
self, rows: Iterable[dict[str, Any]], cascade: bool = True,
|
|
750
|
+
if_not_exists: Literal['error', 'ignore', 'insert'] = 'error'
|
|
751
|
+
) -> UpdateStatus:
|
|
749
752
|
"""Update rows in this table.
|
|
750
753
|
|
|
751
754
|
Args:
|
|
752
755
|
rows: an Iterable of dictionaries containing values for the updated columns plus values for the primary key
|
|
753
756
|
columns.
|
|
754
757
|
cascade: if True, also update all computed columns that transitively depend on the updated columns.
|
|
758
|
+
if_not_exists: Specifies the behavior if a row to update does not exist:
|
|
759
|
+
|
|
760
|
+
- `'error'`: Raise an error.
|
|
761
|
+
- `'ignore'`: Skip the row silently.
|
|
762
|
+
- `'insert'`: Insert the row.
|
|
755
763
|
|
|
756
764
|
Examples:
|
|
757
|
-
Update the
|
|
765
|
+
Update the `name` and `age` columns for the rows with ids 1 and 2 (assuming `id` is the primary key).
|
|
766
|
+
If either row does not exist, this raises an error:
|
|
758
767
|
|
|
759
768
|
>>> tbl.update([{'id': 1, 'name': 'Alice', 'age': 30}, {'id': 2, 'name': 'Bob', 'age': 40}])
|
|
769
|
+
|
|
770
|
+
Update the `name` and `age` columns for the row with `id` 1 (assuming `id` is the primary key) and insert
|
|
771
|
+
the row with new `id` 3 (assuming this key does not exist):
|
|
772
|
+
|
|
773
|
+
>>> tbl.update(
|
|
774
|
+
[{'id': 1, 'name': 'Alice', 'age': 30}, {'id': 3, 'name': 'Bob', 'age': 40}],
|
|
775
|
+
if_not_exists='insert')
|
|
760
776
|
"""
|
|
761
777
|
if self._tbl_version_path.is_snapshot():
|
|
762
778
|
raise excs.Error('Cannot update a snapshot')
|
|
@@ -784,13 +800,15 @@ class Table(SchemaObject):
|
|
|
784
800
|
missing_cols = pk_col_names - set(col.name for col in col_vals.keys())
|
|
785
801
|
raise excs.Error(f'Primary key columns ({", ".join(missing_cols)}) missing in {row_spec}')
|
|
786
802
|
row_updates.append(col_vals)
|
|
787
|
-
return self._tbl_version.batch_update(
|
|
803
|
+
return self._tbl_version.batch_update(
|
|
804
|
+
row_updates, rowids, error_if_not_exists=if_not_exists == 'error',
|
|
805
|
+
insert_if_not_exists=if_not_exists == 'insert', cascade=cascade)
|
|
788
806
|
|
|
789
|
-
def delete(self, where: Optional['pixeltable.exprs.
|
|
807
|
+
def delete(self, where: Optional['pixeltable.exprs.Expr'] = None) -> UpdateStatus:
|
|
790
808
|
"""Delete rows in this table.
|
|
791
809
|
|
|
792
810
|
Args:
|
|
793
|
-
where: a
|
|
811
|
+
where: a predicate to filter rows to delete.
|
|
794
812
|
|
|
795
813
|
Examples:
|
|
796
814
|
Delete all rows in a table:
|