pixeltable 0.3.12__tar.gz → 0.3.13__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.3.12 → pixeltable-0.3.13}/PKG-INFO +1 -1
- {pixeltable-0.3.12 → pixeltable-0.3.13}/pixeltable/__init__.py +1 -26
- {pixeltable-0.3.12 → pixeltable-0.3.13}/pixeltable/__version__.py +2 -2
- {pixeltable-0.3.12 → pixeltable-0.3.13}/pixeltable/catalog/insertable_table.py +11 -0
- {pixeltable-0.3.12 → pixeltable-0.3.13}/pixeltable/catalog/table.py +20 -35
- {pixeltable-0.3.12 → pixeltable-0.3.13}/pixeltable/catalog/view.py +31 -0
- {pixeltable-0.3.12 → pixeltable-0.3.13}/pixeltable/dataframe.py +2 -2
- pixeltable-0.3.13/pixeltable/exceptions.py +42 -0
- {pixeltable-0.3.12 → pixeltable-0.3.13}/pixeltable/exec/expr_eval/evaluators.py +0 -4
- {pixeltable-0.3.12 → pixeltable-0.3.13}/pixeltable/exec/expr_eval/expr_eval_node.py +0 -1
- {pixeltable-0.3.12 → pixeltable-0.3.13}/pixeltable/exec/sql_node.py +3 -2
- {pixeltable-0.3.12 → pixeltable-0.3.13}/pixeltable/func/udf.py +1 -1
- {pixeltable-0.3.12 → pixeltable-0.3.13}/pixeltable/functions/__init__.py +1 -0
- {pixeltable-0.3.12 → pixeltable-0.3.13}/pixeltable/functions/anthropic.py +1 -1
- pixeltable-0.3.13/pixeltable/functions/bedrock.py +130 -0
- {pixeltable-0.3.12 → pixeltable-0.3.13}/pixeltable/functions/huggingface.py +7 -6
- {pixeltable-0.3.12 → pixeltable-0.3.13}/pixeltable/functions/image.py +15 -16
- {pixeltable-0.3.12 → pixeltable-0.3.13}/pixeltable/functions/mistralai.py +3 -2
- {pixeltable-0.3.12 → pixeltable-0.3.13}/pixeltable/functions/openai.py +9 -8
- {pixeltable-0.3.12 → pixeltable-0.3.13}/pixeltable/functions/together.py +4 -3
- {pixeltable-0.3.12 → pixeltable-0.3.13}/pixeltable/io/datarows.py +4 -3
- {pixeltable-0.3.12 → pixeltable-0.3.13}/pixeltable/io/label_studio.py +17 -17
- {pixeltable-0.3.12 → pixeltable-0.3.13}/pixeltable/io/pandas.py +13 -12
- {pixeltable-0.3.12 → pixeltable-0.3.13}/pixeltable/io/table_data_conduit.py +8 -2
- {pixeltable-0.3.12 → pixeltable-0.3.13}/pixeltable/metadata/converters/convert_19.py +2 -2
- {pixeltable-0.3.12 → pixeltable-0.3.13}/pixeltable/share/packager.py +1 -1
- {pixeltable-0.3.12 → pixeltable-0.3.13}/pyproject.toml +2 -1
- pixeltable-0.3.12/pixeltable/exceptions.py +0 -24
- {pixeltable-0.3.12 → pixeltable-0.3.13}/LICENSE +0 -0
- {pixeltable-0.3.12 → pixeltable-0.3.13}/README.md +0 -0
- {pixeltable-0.3.12 → pixeltable-0.3.13}/pixeltable/catalog/__init__.py +0 -0
- {pixeltable-0.3.12 → pixeltable-0.3.13}/pixeltable/catalog/catalog.py +0 -0
- {pixeltable-0.3.12 → pixeltable-0.3.13}/pixeltable/catalog/column.py +0 -0
- {pixeltable-0.3.12 → pixeltable-0.3.13}/pixeltable/catalog/dir.py +0 -0
- {pixeltable-0.3.12 → pixeltable-0.3.13}/pixeltable/catalog/globals.py +0 -0
- {pixeltable-0.3.12 → pixeltable-0.3.13}/pixeltable/catalog/named_function.py +0 -0
- {pixeltable-0.3.12 → pixeltable-0.3.13}/pixeltable/catalog/path.py +0 -0
- {pixeltable-0.3.12 → pixeltable-0.3.13}/pixeltable/catalog/schema_object.py +0 -0
- {pixeltable-0.3.12 → pixeltable-0.3.13}/pixeltable/catalog/table_version.py +0 -0
- {pixeltable-0.3.12 → pixeltable-0.3.13}/pixeltable/catalog/table_version_handle.py +0 -0
- {pixeltable-0.3.12 → pixeltable-0.3.13}/pixeltable/catalog/table_version_path.py +0 -0
- {pixeltable-0.3.12 → pixeltable-0.3.13}/pixeltable/config.py +0 -0
- {pixeltable-0.3.12 → pixeltable-0.3.13}/pixeltable/env.py +0 -0
- {pixeltable-0.3.12 → pixeltable-0.3.13}/pixeltable/exec/__init__.py +0 -0
- {pixeltable-0.3.12 → pixeltable-0.3.13}/pixeltable/exec/aggregation_node.py +0 -0
- {pixeltable-0.3.12 → pixeltable-0.3.13}/pixeltable/exec/cache_prefetch_node.py +0 -0
- {pixeltable-0.3.12 → pixeltable-0.3.13}/pixeltable/exec/component_iteration_node.py +0 -0
- {pixeltable-0.3.12 → pixeltable-0.3.13}/pixeltable/exec/data_row_batch.py +0 -0
- {pixeltable-0.3.12 → pixeltable-0.3.13}/pixeltable/exec/exec_context.py +0 -0
- {pixeltable-0.3.12 → pixeltable-0.3.13}/pixeltable/exec/exec_node.py +0 -0
- {pixeltable-0.3.12 → pixeltable-0.3.13}/pixeltable/exec/expr_eval/__init__.py +0 -0
- {pixeltable-0.3.12 → pixeltable-0.3.13}/pixeltable/exec/expr_eval/globals.py +0 -0
- {pixeltable-0.3.12 → pixeltable-0.3.13}/pixeltable/exec/expr_eval/row_buffer.py +0 -0
- {pixeltable-0.3.12 → pixeltable-0.3.13}/pixeltable/exec/expr_eval/schedulers.py +0 -0
- {pixeltable-0.3.12 → pixeltable-0.3.13}/pixeltable/exec/in_memory_data_node.py +0 -0
- {pixeltable-0.3.12 → pixeltable-0.3.13}/pixeltable/exec/row_update_node.py +0 -0
- {pixeltable-0.3.12 → pixeltable-0.3.13}/pixeltable/exprs/__init__.py +0 -0
- {pixeltable-0.3.12 → pixeltable-0.3.13}/pixeltable/exprs/arithmetic_expr.py +0 -0
- {pixeltable-0.3.12 → pixeltable-0.3.13}/pixeltable/exprs/array_slice.py +0 -0
- {pixeltable-0.3.12 → pixeltable-0.3.13}/pixeltable/exprs/column_property_ref.py +0 -0
- {pixeltable-0.3.12 → pixeltable-0.3.13}/pixeltable/exprs/column_ref.py +0 -0
- {pixeltable-0.3.12 → pixeltable-0.3.13}/pixeltable/exprs/comparison.py +0 -0
- {pixeltable-0.3.12 → pixeltable-0.3.13}/pixeltable/exprs/compound_predicate.py +0 -0
- {pixeltable-0.3.12 → pixeltable-0.3.13}/pixeltable/exprs/data_row.py +0 -0
- {pixeltable-0.3.12 → pixeltable-0.3.13}/pixeltable/exprs/expr.py +0 -0
- {pixeltable-0.3.12 → pixeltable-0.3.13}/pixeltable/exprs/expr_dict.py +0 -0
- {pixeltable-0.3.12 → pixeltable-0.3.13}/pixeltable/exprs/expr_set.py +0 -0
- {pixeltable-0.3.12 → pixeltable-0.3.13}/pixeltable/exprs/function_call.py +0 -0
- {pixeltable-0.3.12 → pixeltable-0.3.13}/pixeltable/exprs/globals.py +0 -0
- {pixeltable-0.3.12 → pixeltable-0.3.13}/pixeltable/exprs/in_predicate.py +0 -0
- {pixeltable-0.3.12 → pixeltable-0.3.13}/pixeltable/exprs/inline_expr.py +0 -0
- {pixeltable-0.3.12 → pixeltable-0.3.13}/pixeltable/exprs/is_null.py +0 -0
- {pixeltable-0.3.12 → pixeltable-0.3.13}/pixeltable/exprs/json_mapper.py +0 -0
- {pixeltable-0.3.12 → pixeltable-0.3.13}/pixeltable/exprs/json_path.py +0 -0
- {pixeltable-0.3.12 → pixeltable-0.3.13}/pixeltable/exprs/literal.py +0 -0
- {pixeltable-0.3.12 → pixeltable-0.3.13}/pixeltable/exprs/method_ref.py +0 -0
- {pixeltable-0.3.12 → pixeltable-0.3.13}/pixeltable/exprs/object_ref.py +0 -0
- {pixeltable-0.3.12 → pixeltable-0.3.13}/pixeltable/exprs/row_builder.py +0 -0
- {pixeltable-0.3.12 → pixeltable-0.3.13}/pixeltable/exprs/rowid_ref.py +0 -0
- {pixeltable-0.3.12 → pixeltable-0.3.13}/pixeltable/exprs/similarity_expr.py +0 -0
- {pixeltable-0.3.12 → pixeltable-0.3.13}/pixeltable/exprs/sql_element_cache.py +0 -0
- {pixeltable-0.3.12 → pixeltable-0.3.13}/pixeltable/exprs/string_op.py +0 -0
- {pixeltable-0.3.12 → pixeltable-0.3.13}/pixeltable/exprs/type_cast.py +0 -0
- {pixeltable-0.3.12 → pixeltable-0.3.13}/pixeltable/exprs/variable.py +0 -0
- {pixeltable-0.3.12 → pixeltable-0.3.13}/pixeltable/ext/__init__.py +0 -0
- {pixeltable-0.3.12 → pixeltable-0.3.13}/pixeltable/ext/functions/__init__.py +0 -0
- {pixeltable-0.3.12 → pixeltable-0.3.13}/pixeltable/ext/functions/whisperx.py +0 -0
- {pixeltable-0.3.12 → pixeltable-0.3.13}/pixeltable/ext/functions/yolox.py +0 -0
- {pixeltable-0.3.12 → pixeltable-0.3.13}/pixeltable/func/__init__.py +0 -0
- {pixeltable-0.3.12 → pixeltable-0.3.13}/pixeltable/func/aggregate_function.py +0 -0
- {pixeltable-0.3.12 → pixeltable-0.3.13}/pixeltable/func/callable_function.py +0 -0
- {pixeltable-0.3.12 → pixeltable-0.3.13}/pixeltable/func/expr_template_function.py +0 -0
- {pixeltable-0.3.12 → pixeltable-0.3.13}/pixeltable/func/function.py +0 -0
- {pixeltable-0.3.12 → pixeltable-0.3.13}/pixeltable/func/function_registry.py +0 -0
- {pixeltable-0.3.12 → pixeltable-0.3.13}/pixeltable/func/globals.py +0 -0
- {pixeltable-0.3.12 → pixeltable-0.3.13}/pixeltable/func/query_template_function.py +0 -0
- {pixeltable-0.3.12 → pixeltable-0.3.13}/pixeltable/func/signature.py +0 -0
- {pixeltable-0.3.12 → pixeltable-0.3.13}/pixeltable/func/tools.py +0 -0
- {pixeltable-0.3.12 → pixeltable-0.3.13}/pixeltable/functions/audio.py +0 -0
- {pixeltable-0.3.12 → pixeltable-0.3.13}/pixeltable/functions/deepseek.py +0 -0
- {pixeltable-0.3.12 → pixeltable-0.3.13}/pixeltable/functions/fireworks.py +0 -0
- {pixeltable-0.3.12 → pixeltable-0.3.13}/pixeltable/functions/gemini.py +0 -0
- {pixeltable-0.3.12 → pixeltable-0.3.13}/pixeltable/functions/globals.py +0 -0
- {pixeltable-0.3.12 → pixeltable-0.3.13}/pixeltable/functions/json.py +0 -0
- {pixeltable-0.3.12 → pixeltable-0.3.13}/pixeltable/functions/llama_cpp.py +0 -0
- {pixeltable-0.3.12 → pixeltable-0.3.13}/pixeltable/functions/math.py +0 -0
- {pixeltable-0.3.12 → pixeltable-0.3.13}/pixeltable/functions/ollama.py +0 -0
- {pixeltable-0.3.12 → pixeltable-0.3.13}/pixeltable/functions/replicate.py +0 -0
- {pixeltable-0.3.12 → pixeltable-0.3.13}/pixeltable/functions/string.py +0 -0
- {pixeltable-0.3.12 → pixeltable-0.3.13}/pixeltable/functions/timestamp.py +0 -0
- {pixeltable-0.3.12 → pixeltable-0.3.13}/pixeltable/functions/util.py +0 -0
- {pixeltable-0.3.12 → pixeltable-0.3.13}/pixeltable/functions/video.py +0 -0
- {pixeltable-0.3.12 → pixeltable-0.3.13}/pixeltable/functions/vision.py +0 -0
- {pixeltable-0.3.12 → pixeltable-0.3.13}/pixeltable/functions/whisper.py +0 -0
- {pixeltable-0.3.12 → pixeltable-0.3.13}/pixeltable/globals.py +0 -0
- {pixeltable-0.3.12 → pixeltable-0.3.13}/pixeltable/index/__init__.py +0 -0
- {pixeltable-0.3.12 → pixeltable-0.3.13}/pixeltable/index/base.py +0 -0
- {pixeltable-0.3.12 → pixeltable-0.3.13}/pixeltable/index/btree.py +0 -0
- {pixeltable-0.3.12 → pixeltable-0.3.13}/pixeltable/index/embedding_index.py +0 -0
- {pixeltable-0.3.12 → pixeltable-0.3.13}/pixeltable/io/__init__.py +0 -0
- {pixeltable-0.3.12 → pixeltable-0.3.13}/pixeltable/io/external_store.py +0 -0
- {pixeltable-0.3.12 → pixeltable-0.3.13}/pixeltable/io/fiftyone.py +0 -0
- {pixeltable-0.3.12 → pixeltable-0.3.13}/pixeltable/io/globals.py +0 -0
- {pixeltable-0.3.12 → pixeltable-0.3.13}/pixeltable/io/hf_datasets.py +0 -0
- {pixeltable-0.3.12 → pixeltable-0.3.13}/pixeltable/io/parquet.py +0 -0
- {pixeltable-0.3.12 → pixeltable-0.3.13}/pixeltable/io/utils.py +0 -0
- {pixeltable-0.3.12 → pixeltable-0.3.13}/pixeltable/iterators/__init__.py +0 -0
- {pixeltable-0.3.12 → pixeltable-0.3.13}/pixeltable/iterators/audio.py +0 -0
- {pixeltable-0.3.12 → pixeltable-0.3.13}/pixeltable/iterators/base.py +0 -0
- {pixeltable-0.3.12 → pixeltable-0.3.13}/pixeltable/iterators/document.py +0 -0
- {pixeltable-0.3.12 → pixeltable-0.3.13}/pixeltable/iterators/image.py +0 -0
- {pixeltable-0.3.12 → pixeltable-0.3.13}/pixeltable/iterators/string.py +0 -0
- {pixeltable-0.3.12 → pixeltable-0.3.13}/pixeltable/iterators/video.py +0 -0
- {pixeltable-0.3.12 → pixeltable-0.3.13}/pixeltable/metadata/__init__.py +0 -0
- {pixeltable-0.3.12 → pixeltable-0.3.13}/pixeltable/metadata/converters/convert_10.py +0 -0
- {pixeltable-0.3.12 → pixeltable-0.3.13}/pixeltable/metadata/converters/convert_12.py +0 -0
- {pixeltable-0.3.12 → pixeltable-0.3.13}/pixeltable/metadata/converters/convert_13.py +0 -0
- {pixeltable-0.3.12 → pixeltable-0.3.13}/pixeltable/metadata/converters/convert_14.py +0 -0
- {pixeltable-0.3.12 → pixeltable-0.3.13}/pixeltable/metadata/converters/convert_15.py +0 -0
- {pixeltable-0.3.12 → pixeltable-0.3.13}/pixeltable/metadata/converters/convert_16.py +0 -0
- {pixeltable-0.3.12 → pixeltable-0.3.13}/pixeltable/metadata/converters/convert_17.py +0 -0
- {pixeltable-0.3.12 → pixeltable-0.3.13}/pixeltable/metadata/converters/convert_18.py +0 -0
- {pixeltable-0.3.12 → pixeltable-0.3.13}/pixeltable/metadata/converters/convert_20.py +0 -0
- {pixeltable-0.3.12 → pixeltable-0.3.13}/pixeltable/metadata/converters/convert_21.py +0 -0
- {pixeltable-0.3.12 → pixeltable-0.3.13}/pixeltable/metadata/converters/convert_22.py +0 -0
- {pixeltable-0.3.12 → pixeltable-0.3.13}/pixeltable/metadata/converters/convert_23.py +0 -0
- {pixeltable-0.3.12 → pixeltable-0.3.13}/pixeltable/metadata/converters/convert_24.py +0 -0
- {pixeltable-0.3.12 → pixeltable-0.3.13}/pixeltable/metadata/converters/convert_25.py +0 -0
- {pixeltable-0.3.12 → pixeltable-0.3.13}/pixeltable/metadata/converters/convert_26.py +0 -0
- {pixeltable-0.3.12 → pixeltable-0.3.13}/pixeltable/metadata/converters/convert_27.py +0 -0
- {pixeltable-0.3.12 → pixeltable-0.3.13}/pixeltable/metadata/converters/convert_28.py +0 -0
- {pixeltable-0.3.12 → pixeltable-0.3.13}/pixeltable/metadata/converters/convert_29.py +0 -0
- {pixeltable-0.3.12 → pixeltable-0.3.13}/pixeltable/metadata/converters/convert_30.py +0 -0
- {pixeltable-0.3.12 → pixeltable-0.3.13}/pixeltable/metadata/converters/convert_31.py +0 -0
- {pixeltable-0.3.12 → pixeltable-0.3.13}/pixeltable/metadata/converters/convert_32.py +0 -0
- {pixeltable-0.3.12 → pixeltable-0.3.13}/pixeltable/metadata/converters/convert_33.py +0 -0
- {pixeltable-0.3.12 → pixeltable-0.3.13}/pixeltable/metadata/converters/util.py +0 -0
- {pixeltable-0.3.12 → pixeltable-0.3.13}/pixeltable/metadata/notes.py +0 -0
- {pixeltable-0.3.12 → pixeltable-0.3.13}/pixeltable/metadata/schema.py +0 -0
- {pixeltable-0.3.12 → pixeltable-0.3.13}/pixeltable/plan.py +0 -0
- {pixeltable-0.3.12 → pixeltable-0.3.13}/pixeltable/py.typed +0 -0
- {pixeltable-0.3.12 → pixeltable-0.3.13}/pixeltable/share/__init__.py +0 -0
- {pixeltable-0.3.12 → pixeltable-0.3.13}/pixeltable/share/publish.py +0 -0
- {pixeltable-0.3.12 → pixeltable-0.3.13}/pixeltable/store.py +0 -0
- {pixeltable-0.3.12 → pixeltable-0.3.13}/pixeltable/type_system.py +0 -0
- {pixeltable-0.3.12 → pixeltable-0.3.13}/pixeltable/utils/__init__.py +0 -0
- {pixeltable-0.3.12 → pixeltable-0.3.13}/pixeltable/utils/arrow.py +0 -0
- {pixeltable-0.3.12 → pixeltable-0.3.13}/pixeltable/utils/coco.py +0 -0
- {pixeltable-0.3.12 → pixeltable-0.3.13}/pixeltable/utils/code.py +0 -0
- {pixeltable-0.3.12 → pixeltable-0.3.13}/pixeltable/utils/console_output.py +0 -0
- {pixeltable-0.3.12 → pixeltable-0.3.13}/pixeltable/utils/coroutine.py +0 -0
- {pixeltable-0.3.12 → pixeltable-0.3.13}/pixeltable/utils/dbms.py +0 -0
- {pixeltable-0.3.12 → pixeltable-0.3.13}/pixeltable/utils/description_helper.py +0 -0
- {pixeltable-0.3.12 → pixeltable-0.3.13}/pixeltable/utils/documents.py +0 -0
- {pixeltable-0.3.12 → pixeltable-0.3.13}/pixeltable/utils/exception_handler.py +0 -0
- {pixeltable-0.3.12 → pixeltable-0.3.13}/pixeltable/utils/filecache.py +0 -0
- {pixeltable-0.3.12 → pixeltable-0.3.13}/pixeltable/utils/formatter.py +0 -0
- {pixeltable-0.3.12 → pixeltable-0.3.13}/pixeltable/utils/http_server.py +0 -0
- {pixeltable-0.3.12 → pixeltable-0.3.13}/pixeltable/utils/iceberg.py +0 -0
- {pixeltable-0.3.12 → pixeltable-0.3.13}/pixeltable/utils/media_store.py +0 -0
- {pixeltable-0.3.12 → pixeltable-0.3.13}/pixeltable/utils/pytorch.py +0 -0
- {pixeltable-0.3.12 → pixeltable-0.3.13}/pixeltable/utils/s3.py +0 -0
- {pixeltable-0.3.12 → pixeltable-0.3.13}/pixeltable/utils/sql.py +0 -0
- {pixeltable-0.3.12 → pixeltable-0.3.13}/pixeltable/utils/transactional_directory.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: pixeltable
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.13
|
|
4
4
|
Summary: AI Data Infrastructure: Declarative, Multimodal, and Incremental
|
|
5
5
|
License: Apache-2.0
|
|
6
6
|
Keywords: data-science,machine-learning,database,ai,computer-vision,chatbot,ml,artificial-intelligence,feature-engineering,multimodal,mlops,feature-store,vector-database,llm,genai
|
|
@@ -24,32 +24,7 @@ from .globals import (
|
|
|
24
24
|
tool,
|
|
25
25
|
tools,
|
|
26
26
|
)
|
|
27
|
-
from .type_system import
|
|
28
|
-
Array,
|
|
29
|
-
ArrayType,
|
|
30
|
-
Audio,
|
|
31
|
-
AudioType,
|
|
32
|
-
Bool,
|
|
33
|
-
BoolType,
|
|
34
|
-
ColumnType,
|
|
35
|
-
Document,
|
|
36
|
-
DocumentType,
|
|
37
|
-
Float,
|
|
38
|
-
FloatType,
|
|
39
|
-
Image,
|
|
40
|
-
ImageType,
|
|
41
|
-
Int,
|
|
42
|
-
IntType,
|
|
43
|
-
Json,
|
|
44
|
-
JsonType,
|
|
45
|
-
Required,
|
|
46
|
-
String,
|
|
47
|
-
StringType,
|
|
48
|
-
Timestamp,
|
|
49
|
-
TimestampType,
|
|
50
|
-
Video,
|
|
51
|
-
VideoType,
|
|
52
|
-
)
|
|
27
|
+
from .type_system import Array, Audio, Bool, Document, Float, Image, Int, Json, Required, String, Timestamp, Video
|
|
53
28
|
|
|
54
29
|
# This import must go last to avoid circular imports.
|
|
55
30
|
from . import ext, functions, io, iterators # isort: skip
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
# These version placeholders will be replaced during build.
|
|
2
|
-
__version__ = '0.3.
|
|
3
|
-
__version_tuple__ = (0, 3,
|
|
2
|
+
__version__ = '0.3.13'
|
|
3
|
+
__version_tuple__ = (0, 3, 13)
|
|
@@ -228,3 +228,14 @@ class InsertableTable(Table):
|
|
|
228
228
|
"""
|
|
229
229
|
with Env.get().begin_xact():
|
|
230
230
|
return self._tbl_version.get().delete(where=where)
|
|
231
|
+
|
|
232
|
+
@property
|
|
233
|
+
def _base_table(self) -> Optional['Table']:
|
|
234
|
+
return None
|
|
235
|
+
|
|
236
|
+
@property
|
|
237
|
+
def _effective_base_versions(self) -> list[Optional[int]]:
|
|
238
|
+
return []
|
|
239
|
+
|
|
240
|
+
def _table_descriptor(self) -> str:
|
|
241
|
+
return f'Table {self._path()!r}'
|
|
@@ -109,7 +109,7 @@ class Table(SchemaObject):
|
|
|
109
109
|
self._check_is_dropped()
|
|
110
110
|
with env.Env.get().begin_xact():
|
|
111
111
|
md = super().get_metadata()
|
|
112
|
-
md['base'] = self.
|
|
112
|
+
md['base'] = self._base_table._path() if self._base_table is not None else None
|
|
113
113
|
md['schema'] = self._schema
|
|
114
114
|
md['is_replica'] = self._tbl_version.get().is_replica
|
|
115
115
|
md['version'] = self._version
|
|
@@ -255,28 +255,27 @@ class Table(SchemaObject):
|
|
|
255
255
|
return {c.name: c.col_type for c in self._tbl_version_path.columns()}
|
|
256
256
|
|
|
257
257
|
@property
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
The base
|
|
261
|
-
|
|
262
|
-
"""
|
|
263
|
-
if self._tbl_version_path.base is None:
|
|
264
|
-
return None
|
|
265
|
-
base_id = self._tbl_version_path.base.tbl_version.id
|
|
266
|
-
return catalog.Catalog.get().get_table_by_id(base_id)
|
|
258
|
+
@abc.abstractmethod
|
|
259
|
+
def _base_table(self) -> Optional['Table']:
|
|
260
|
+
"""The base's Table instance"""
|
|
261
|
+
...
|
|
267
262
|
|
|
268
263
|
@property
|
|
269
|
-
def
|
|
270
|
-
"""
|
|
271
|
-
The ancestor list of bases of this table, starting with its immediate base.
|
|
272
|
-
"""
|
|
264
|
+
def _base_tables(self) -> list['Table']:
|
|
265
|
+
"""The ancestor list of bases of this table, starting with its immediate base."""
|
|
273
266
|
bases = []
|
|
274
|
-
base = self.
|
|
267
|
+
base = self._base_table
|
|
275
268
|
while base is not None:
|
|
276
269
|
bases.append(base)
|
|
277
|
-
base = base.
|
|
270
|
+
base = base._base_table
|
|
278
271
|
return bases
|
|
279
272
|
|
|
273
|
+
@property
|
|
274
|
+
@abc.abstractmethod
|
|
275
|
+
def _effective_base_versions(self) -> list[Optional[int]]:
|
|
276
|
+
"""The effective versions of the ancestor bases, starting with its immediate base."""
|
|
277
|
+
...
|
|
278
|
+
|
|
280
279
|
@property
|
|
281
280
|
def _comment(self) -> str:
|
|
282
281
|
return self._tbl_version.get().comment
|
|
@@ -300,7 +299,7 @@ class Table(SchemaObject):
|
|
|
300
299
|
Constructs a list of descriptors for this table that can be pretty-printed.
|
|
301
300
|
"""
|
|
302
301
|
helper = DescriptionHelper()
|
|
303
|
-
helper.append(self.
|
|
302
|
+
helper.append(self._table_descriptor())
|
|
304
303
|
helper.append(self._col_descriptor())
|
|
305
304
|
idxs = self._index_descriptor()
|
|
306
305
|
if not idxs.empty:
|
|
@@ -312,14 +311,8 @@ class Table(SchemaObject):
|
|
|
312
311
|
helper.append(f'COMMENT: {self._comment}')
|
|
313
312
|
return helper
|
|
314
313
|
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
if self._base is None:
|
|
318
|
-
title = f'Table\n{self._path()!r}'
|
|
319
|
-
else:
|
|
320
|
-
title = f'View\n{self._path()!r}'
|
|
321
|
-
title += f'\n(of {self.__bases_to_desc()})'
|
|
322
|
-
return title
|
|
314
|
+
@abc.abstractmethod
|
|
315
|
+
def _table_descriptor(self) -> str: ...
|
|
323
316
|
|
|
324
317
|
def _col_descriptor(self, columns: Optional[list[str]] = None) -> pd.DataFrame:
|
|
325
318
|
return pd.DataFrame(
|
|
@@ -332,14 +325,6 @@ class Table(SchemaObject):
|
|
|
332
325
|
if columns is None or col.name in columns
|
|
333
326
|
)
|
|
334
327
|
|
|
335
|
-
def __bases_to_desc(self) -> str:
|
|
336
|
-
bases = self._bases
|
|
337
|
-
assert len(bases) >= 1
|
|
338
|
-
if len(bases) <= 2:
|
|
339
|
-
return ', '.join(repr(b._path()) for b in bases)
|
|
340
|
-
else:
|
|
341
|
-
return f'{bases[0]._path()!r}, ..., {bases[-1]._path()!r}'
|
|
342
|
-
|
|
343
328
|
def _index_descriptor(self, columns: Optional[list[str]] = None) -> pd.DataFrame:
|
|
344
329
|
from pixeltable import index
|
|
345
330
|
|
|
@@ -373,9 +358,9 @@ class Table(SchemaObject):
|
|
|
373
358
|
"""
|
|
374
359
|
self._check_is_dropped()
|
|
375
360
|
if getattr(builtins, '__IPYTHON__', False):
|
|
376
|
-
from IPython.display import display
|
|
361
|
+
from IPython.display import Markdown, display
|
|
377
362
|
|
|
378
|
-
display(self._repr_html_())
|
|
363
|
+
display(Markdown(self._repr_html_()))
|
|
379
364
|
else:
|
|
380
365
|
print(repr(self))
|
|
381
366
|
|
|
@@ -267,3 +267,34 @@ class View(Table):
|
|
|
267
267
|
|
|
268
268
|
def delete(self, where: Optional[exprs.Expr] = None) -> UpdateStatus:
|
|
269
269
|
raise excs.Error(f'{self._display_name()} {self._name!r}: cannot delete from view')
|
|
270
|
+
|
|
271
|
+
@property
|
|
272
|
+
def _base_table(self) -> Optional['Table']:
|
|
273
|
+
# if this is a pure snapshot, our tbl_version_path only reflects the base (there is no TableVersion instance
|
|
274
|
+
# for the snapshot itself)
|
|
275
|
+
base_id = self._tbl_version.id if self._snapshot_only else self._tbl_version_path.base.tbl_version.id
|
|
276
|
+
return catalog.Catalog.get().get_table_by_id(base_id)
|
|
277
|
+
|
|
278
|
+
@property
|
|
279
|
+
def _effective_base_versions(self) -> list[Optional[int]]:
|
|
280
|
+
effective_versions = [tv.effective_version for tv in self._tbl_version_path.get_tbl_versions()]
|
|
281
|
+
if self._snapshot_only:
|
|
282
|
+
return effective_versions
|
|
283
|
+
else:
|
|
284
|
+
return effective_versions[1:]
|
|
285
|
+
|
|
286
|
+
def _table_descriptor(self) -> str:
|
|
287
|
+
display_name = 'Snapshot' if self._snapshot_only else 'View'
|
|
288
|
+
result = [f'{display_name} {self._path()!r}']
|
|
289
|
+
bases_descrs: list[str] = []
|
|
290
|
+
for base, effective_version in zip(self._base_tables, self._effective_base_versions):
|
|
291
|
+
if effective_version is None:
|
|
292
|
+
bases_descrs.append(f'{base._path()!r}')
|
|
293
|
+
else:
|
|
294
|
+
base_descr = f'{base._path()}:{effective_version}'
|
|
295
|
+
bases_descrs.append(f'{base_descr!r}')
|
|
296
|
+
result.append(f' (of {", ".join(bases_descrs)})')
|
|
297
|
+
|
|
298
|
+
if self._tbl_version.get().predicate is not None:
|
|
299
|
+
result.append(f'\nWhere: {self._tbl_version.get().predicate!s}')
|
|
300
|
+
return ''.join(result)
|
|
@@ -513,9 +513,9 @@ class DataFrame:
|
|
|
513
513
|
(select list, where clause, ...) vertically.
|
|
514
514
|
"""
|
|
515
515
|
if getattr(builtins, '__IPYTHON__', False):
|
|
516
|
-
from IPython.display import display
|
|
516
|
+
from IPython.display import Markdown, display
|
|
517
517
|
|
|
518
|
-
display(self._repr_html_())
|
|
518
|
+
display(Markdown(self._repr_html_()))
|
|
519
519
|
else:
|
|
520
520
|
print(repr(self))
|
|
521
521
|
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
from types import TracebackType
|
|
2
|
+
from typing import TYPE_CHECKING, Any
|
|
3
|
+
|
|
4
|
+
if TYPE_CHECKING:
|
|
5
|
+
from pixeltable import exprs
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class Error(Exception):
|
|
9
|
+
pass
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class ExprEvalError(Exception):
|
|
13
|
+
expr: 'exprs.Expr'
|
|
14
|
+
expr_msg: str
|
|
15
|
+
exc: Exception
|
|
16
|
+
exc_tb: TracebackType
|
|
17
|
+
input_vals: list[Any]
|
|
18
|
+
row_num: int
|
|
19
|
+
|
|
20
|
+
def __init__(
|
|
21
|
+
self,
|
|
22
|
+
expr: 'exprs.Expr',
|
|
23
|
+
expr_msg: str,
|
|
24
|
+
exc: Exception,
|
|
25
|
+
exc_tb: TracebackType,
|
|
26
|
+
input_vals: list[Any],
|
|
27
|
+
row_num: int,
|
|
28
|
+
) -> None:
|
|
29
|
+
exct = type(exc)
|
|
30
|
+
super().__init__(
|
|
31
|
+
f'Expression evaluation failed with an error of type `{exct.__module__}.{exct.__qualname__}`:\n{expr}'
|
|
32
|
+
)
|
|
33
|
+
self.expr = expr
|
|
34
|
+
self.expr_msg = expr_msg
|
|
35
|
+
self.exc = exc
|
|
36
|
+
self.exc_tb = exc_tb
|
|
37
|
+
self.input_vals = input_vals
|
|
38
|
+
self.row_num = row_num
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
class PixeltableWarning(Warning):
|
|
42
|
+
pass
|
|
@@ -208,10 +208,6 @@ class FnCallEvaluator(Evaluator):
|
|
|
208
208
|
_logger.debug(f'Evaluated slot {self.fn_call.slot_idx} in {end_ts - start_ts}')
|
|
209
209
|
self.dispatcher.dispatch([call_args.row], self.exec_ctx)
|
|
210
210
|
except Exception as exc:
|
|
211
|
-
import anthropic
|
|
212
|
-
|
|
213
|
-
if isinstance(exc, anthropic.RateLimitError):
|
|
214
|
-
_logger.debug(f'RateLimitError: {exc}')
|
|
215
211
|
_, _, exc_tb = sys.exc_info()
|
|
216
212
|
call_args.row.set_exc(self.fn_call.slot_idx, exc)
|
|
217
213
|
self.dispatcher.dispatch_exc(call_args.rows, self.fn_call.slot_idx, exc_tb, self.exec_ctx)
|
|
@@ -282,7 +282,6 @@ class ExprEvalNode(ExecNode):
|
|
|
282
282
|
|
|
283
283
|
if self.exc_event.is_set():
|
|
284
284
|
# we got an exception that we need to propagate through __iter__()
|
|
285
|
-
_logger.debug(f'Propagating exception {self.error}')
|
|
286
285
|
if isinstance(self.error, excs.ExprEvalError):
|
|
287
286
|
raise self.error from self.error.exc
|
|
288
287
|
else:
|
|
@@ -424,6 +424,7 @@ class SqlAggregationNode(SqlNode):
|
|
|
424
424
|
"""
|
|
425
425
|
|
|
426
426
|
group_by_items: Optional[list[exprs.Expr]]
|
|
427
|
+
input_cte: Optional[sql.CTE]
|
|
427
428
|
|
|
428
429
|
def __init__(
|
|
429
430
|
self,
|
|
@@ -440,13 +441,13 @@ class SqlAggregationNode(SqlNode):
|
|
|
440
441
|
group_by_items: list of expressions to group by
|
|
441
442
|
limit: max number of rows to return: None = no limit
|
|
442
443
|
"""
|
|
443
|
-
|
|
444
|
+
self.input_cte, input_col_map = input.to_cte()
|
|
444
445
|
sql_elements = exprs.SqlElementCache(input_col_map)
|
|
445
446
|
super().__init__(None, row_builder, select_list, sql_elements)
|
|
446
447
|
self.group_by_items = group_by_items
|
|
447
448
|
|
|
448
449
|
def _create_stmt(self) -> sql.Select:
|
|
449
|
-
stmt = super()._create_stmt()
|
|
450
|
+
stmt = super()._create_stmt().select_from(self.input_cte)
|
|
450
451
|
if self.group_by_items is not None:
|
|
451
452
|
sql_group_by_items = [self.sql_elements.get(e) for e in self.group_by_items]
|
|
452
453
|
assert all(e is not None for e in sql_group_by_items)
|
|
@@ -262,7 +262,7 @@ def from_table(
|
|
|
262
262
|
"""
|
|
263
263
|
from pixeltable import exprs
|
|
264
264
|
|
|
265
|
-
ancestors = [tbl, *tbl.
|
|
265
|
+
ancestors = [tbl, *tbl._base_tables]
|
|
266
266
|
ancestors.reverse() # We must traverse the ancestors in order from base to derived
|
|
267
267
|
|
|
268
268
|
subst: dict[exprs.Expr, exprs.Expr] = {}
|
|
@@ -112,7 +112,7 @@ async def messages(
|
|
|
112
112
|
to an existing Pixeltable column `tbl.prompt` of the table `tbl`:
|
|
113
113
|
|
|
114
114
|
>>> msgs = [{'role': 'user', 'content': tbl.prompt}]
|
|
115
|
-
... tbl.add_computed_column(response=
|
|
115
|
+
... tbl.add_computed_column(response=messages(msgs, model='claude-3-haiku-20240307'))
|
|
116
116
|
"""
|
|
117
117
|
|
|
118
118
|
# it doesn't look like count_tokens() actually exists in the current version of the library
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import logging
|
|
2
|
+
from typing import TYPE_CHECKING, Any, Optional
|
|
3
|
+
|
|
4
|
+
import pixeltable as pxt
|
|
5
|
+
from pixeltable import env, exprs
|
|
6
|
+
from pixeltable.func import Tools
|
|
7
|
+
from pixeltable.utils.code import local_public_names
|
|
8
|
+
|
|
9
|
+
if TYPE_CHECKING:
|
|
10
|
+
from botocore.client import BaseClient
|
|
11
|
+
|
|
12
|
+
_logger = logging.getLogger('pixeltable')
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
@env.register_client('bedrock')
|
|
16
|
+
def _() -> 'BaseClient':
|
|
17
|
+
import boto3
|
|
18
|
+
|
|
19
|
+
return boto3.client(service_name='bedrock-runtime')
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
# boto3 typing is weird; type information is dynamically defined, so the best we can do for the static checker is `Any`
|
|
23
|
+
def _bedrock_client() -> Any:
|
|
24
|
+
return env.Env.get().get_client('bedrock')
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
@pxt.udf
|
|
28
|
+
def converse(
|
|
29
|
+
messages: list[dict[str, Any]],
|
|
30
|
+
*,
|
|
31
|
+
model_id: str,
|
|
32
|
+
system: Optional[list[dict[str, Any]]] = None,
|
|
33
|
+
inference_config: Optional[dict] = None,
|
|
34
|
+
additional_model_request_fields: Optional[dict] = None,
|
|
35
|
+
tool_config: Optional[list[dict]] = None,
|
|
36
|
+
) -> dict:
|
|
37
|
+
"""
|
|
38
|
+
Generate a conversation response.
|
|
39
|
+
|
|
40
|
+
Equivalent to the AWS Bedrock `converse` API endpoint.
|
|
41
|
+
For additional details, see: <https://docs.aws.amazon.com/bedrock/latest/userguide/conversation-inference.html>
|
|
42
|
+
|
|
43
|
+
__Requirements:__
|
|
44
|
+
|
|
45
|
+
- `pip install boto3`
|
|
46
|
+
|
|
47
|
+
Args:
|
|
48
|
+
messages: Input messages.
|
|
49
|
+
model_id: The model that will complete your prompt.
|
|
50
|
+
system: An optional system prompt.
|
|
51
|
+
inference_config: Base inference parameters to use.
|
|
52
|
+
additional_model_request_fields: Additional inference parameters to use.
|
|
53
|
+
|
|
54
|
+
For details on the optional parameters, see:
|
|
55
|
+
<https://docs.aws.amazon.com/bedrock/latest/userguide/conversation-inference.html>
|
|
56
|
+
|
|
57
|
+
Returns:
|
|
58
|
+
A dictionary containing the response and other metadata.
|
|
59
|
+
|
|
60
|
+
Examples:
|
|
61
|
+
Add a computed column that applies the model `anthropic.claude-3-haiku-20240307-v1:0`
|
|
62
|
+
to an existing Pixeltable column `tbl.prompt` of the table `tbl`:
|
|
63
|
+
|
|
64
|
+
>>> msgs = [{'role': 'user', 'content': [{'text': tbl.prompt}]}]
|
|
65
|
+
... tbl.add_computed_column(response=messages(msgs, model_id='anthropic.claude-3-haiku-20240307-v1:0'))
|
|
66
|
+
"""
|
|
67
|
+
|
|
68
|
+
kwargs: dict[str, Any] = {'messages': messages, 'modelId': model_id}
|
|
69
|
+
|
|
70
|
+
if system is not None:
|
|
71
|
+
kwargs['system'] = system
|
|
72
|
+
if inference_config is not None:
|
|
73
|
+
kwargs['inferenceConfig'] = inference_config
|
|
74
|
+
if additional_model_request_fields is not None:
|
|
75
|
+
kwargs['additionalModelRequestFields'] = additional_model_request_fields
|
|
76
|
+
|
|
77
|
+
if tool_config is not None:
|
|
78
|
+
tool_config_ = {
|
|
79
|
+
'tools': [
|
|
80
|
+
{
|
|
81
|
+
'toolSpec': {
|
|
82
|
+
'name': tool['name'],
|
|
83
|
+
'description': tool['description'],
|
|
84
|
+
'inputSchema': {
|
|
85
|
+
'json': {
|
|
86
|
+
'type': 'object',
|
|
87
|
+
'properties': tool['parameters']['properties'],
|
|
88
|
+
'required': tool['required'],
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
for tool in tool_config
|
|
94
|
+
]
|
|
95
|
+
}
|
|
96
|
+
kwargs['toolConfig'] = tool_config_
|
|
97
|
+
|
|
98
|
+
return _bedrock_client().converse(**kwargs)
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
def invoke_tools(tools: Tools, response: exprs.Expr) -> exprs.InlineDict:
|
|
102
|
+
"""Converts an Anthropic response dict to Pixeltable tool invocation format and calls `tools._invoke()`."""
|
|
103
|
+
return tools._invoke(_bedrock_response_to_pxt_tool_calls(response))
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
@pxt.udf
|
|
107
|
+
def _bedrock_response_to_pxt_tool_calls(response: dict) -> Optional[dict]:
|
|
108
|
+
if response.get('stopReason') != 'tool_use':
|
|
109
|
+
return None
|
|
110
|
+
|
|
111
|
+
pxt_tool_calls: dict[str, list[dict[str, Any]]] = {}
|
|
112
|
+
for message in response['output']['message']['content']:
|
|
113
|
+
if 'toolUse' in message:
|
|
114
|
+
tool_call = message['toolUse']
|
|
115
|
+
tool_name = tool_call['name']
|
|
116
|
+
if tool_name not in pxt_tool_calls:
|
|
117
|
+
pxt_tool_calls[tool_name] = []
|
|
118
|
+
pxt_tool_calls[tool_name].append({'args': tool_call['input']})
|
|
119
|
+
|
|
120
|
+
if len(pxt_tool_calls) == 0:
|
|
121
|
+
return None
|
|
122
|
+
|
|
123
|
+
return pxt_tool_calls
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
__all__ = local_public_names(__name__)
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
def __dir__() -> list[str]:
|
|
130
|
+
return __all__
|
|
@@ -13,6 +13,7 @@ import PIL.Image
|
|
|
13
13
|
|
|
14
14
|
import pixeltable as pxt
|
|
15
15
|
import pixeltable.exceptions as excs
|
|
16
|
+
import pixeltable.type_system as ts
|
|
16
17
|
from pixeltable import env
|
|
17
18
|
from pixeltable.func import Batch
|
|
18
19
|
from pixeltable.functions.util import normalize_image_mode, resolve_torch_device
|
|
@@ -61,14 +62,14 @@ def sentence_transformer(
|
|
|
61
62
|
|
|
62
63
|
|
|
63
64
|
@sentence_transformer.conditional_return_type
|
|
64
|
-
def _(model_id: str) ->
|
|
65
|
+
def _(model_id: str) -> ts.ArrayType:
|
|
65
66
|
try:
|
|
66
67
|
from sentence_transformers import SentenceTransformer
|
|
67
68
|
|
|
68
69
|
model = _lookup_model(model_id, SentenceTransformer)
|
|
69
|
-
return
|
|
70
|
+
return ts.ArrayType((model.get_sentence_embedding_dimension(),), dtype=ts.FloatType(), nullable=False)
|
|
70
71
|
except ImportError:
|
|
71
|
-
return
|
|
72
|
+
return ts.ArrayType((None,), dtype=ts.FloatType(), nullable=False)
|
|
72
73
|
|
|
73
74
|
|
|
74
75
|
@pxt.udf
|
|
@@ -199,14 +200,14 @@ def _(image: Batch[PIL.Image.Image], *, model_id: str) -> Batch[pxt.Array[(None,
|
|
|
199
200
|
|
|
200
201
|
|
|
201
202
|
@clip.conditional_return_type
|
|
202
|
-
def _(model_id: str) ->
|
|
203
|
+
def _(model_id: str) -> ts.ArrayType:
|
|
203
204
|
try:
|
|
204
205
|
from transformers import CLIPModel
|
|
205
206
|
|
|
206
207
|
model = _lookup_model(model_id, CLIPModel.from_pretrained)
|
|
207
|
-
return
|
|
208
|
+
return ts.ArrayType((model.config.projection_dim,), dtype=ts.FloatType(), nullable=False)
|
|
208
209
|
except ImportError:
|
|
209
|
-
return
|
|
210
|
+
return ts.ArrayType((None,), dtype=ts.FloatType(), nullable=False)
|
|
210
211
|
|
|
211
212
|
|
|
212
213
|
@pxt.udf(batch_size=4)
|
|
@@ -16,6 +16,7 @@ from typing import Optional
|
|
|
16
16
|
import PIL.Image
|
|
17
17
|
|
|
18
18
|
import pixeltable as pxt
|
|
19
|
+
import pixeltable.type_system as ts
|
|
19
20
|
from pixeltable.exprs import Expr
|
|
20
21
|
from pixeltable.utils.code import local_public_names
|
|
21
22
|
|
|
@@ -88,10 +89,10 @@ def convert(self: PIL.Image.Image, mode: str) -> PIL.Image.Image:
|
|
|
88
89
|
|
|
89
90
|
|
|
90
91
|
@convert.conditional_return_type
|
|
91
|
-
def _(self: Expr, mode: str) ->
|
|
92
|
+
def _(self: Expr, mode: str) -> ts.ColumnType:
|
|
92
93
|
input_type = self.col_type
|
|
93
|
-
assert isinstance(input_type,
|
|
94
|
-
return
|
|
94
|
+
assert isinstance(input_type, ts.ImageType)
|
|
95
|
+
return ts.ImageType(size=input_type.size, mode=mode, nullable=input_type.nullable)
|
|
95
96
|
|
|
96
97
|
|
|
97
98
|
# Image.crop()
|
|
@@ -108,14 +109,12 @@ def crop(self: PIL.Image.Image, box: tuple[int, int, int, int]) -> PIL.Image.Ima
|
|
|
108
109
|
|
|
109
110
|
|
|
110
111
|
@crop.conditional_return_type
|
|
111
|
-
def _(self: Expr, box: tuple[int, int, int, int]) ->
|
|
112
|
+
def _(self: Expr, box: tuple[int, int, int, int]) -> ts.ColumnType:
|
|
112
113
|
input_type = self.col_type
|
|
113
|
-
assert isinstance(input_type,
|
|
114
|
+
assert isinstance(input_type, ts.ImageType)
|
|
114
115
|
if (isinstance(box, (list, tuple))) and len(box) == 4 and all(isinstance(x, int) for x in box):
|
|
115
|
-
return
|
|
116
|
-
|
|
117
|
-
)
|
|
118
|
-
return pxt.ImageType(mode=input_type.mode, nullable=input_type.nullable) # we can't compute the size statically
|
|
116
|
+
return ts.ImageType(size=(box[2] - box[0], box[3] - box[1]), mode=input_type.mode, nullable=input_type.nullable)
|
|
117
|
+
return ts.ImageType(mode=input_type.mode, nullable=input_type.nullable) # we can't compute the size statically
|
|
119
118
|
|
|
120
119
|
|
|
121
120
|
# Image.getchannel()
|
|
@@ -134,10 +133,10 @@ def getchannel(self: PIL.Image.Image, channel: int) -> PIL.Image.Image:
|
|
|
134
133
|
|
|
135
134
|
|
|
136
135
|
@getchannel.conditional_return_type
|
|
137
|
-
def _(self: Expr) ->
|
|
136
|
+
def _(self: Expr) -> ts.ColumnType:
|
|
138
137
|
input_type = self.col_type
|
|
139
|
-
assert isinstance(input_type,
|
|
140
|
-
return
|
|
138
|
+
assert isinstance(input_type, ts.ImageType)
|
|
139
|
+
return ts.ImageType(size=input_type.size, mode='L', nullable=input_type.nullable)
|
|
141
140
|
|
|
142
141
|
|
|
143
142
|
@pxt.udf(is_method=True)
|
|
@@ -183,10 +182,10 @@ def resize(self: PIL.Image.Image, size: tuple[int, int]) -> PIL.Image.Image:
|
|
|
183
182
|
|
|
184
183
|
|
|
185
184
|
@resize.conditional_return_type
|
|
186
|
-
def _(self: Expr, size: tuple[int, int]) ->
|
|
185
|
+
def _(self: Expr, size: tuple[int, int]) -> ts.ColumnType:
|
|
187
186
|
input_type = self.col_type
|
|
188
|
-
assert isinstance(input_type,
|
|
189
|
-
return
|
|
187
|
+
assert isinstance(input_type, ts.ImageType)
|
|
188
|
+
return ts.ImageType(size=size, mode=input_type.mode, nullable=input_type.nullable)
|
|
190
189
|
|
|
191
190
|
|
|
192
191
|
# Image.rotate()
|
|
@@ -237,7 +236,7 @@ def transpose(self: PIL.Image.Image, method: int) -> PIL.Image.Image:
|
|
|
237
236
|
@rotate.conditional_return_type
|
|
238
237
|
@effect_spread.conditional_return_type
|
|
239
238
|
@transpose.conditional_return_type
|
|
240
|
-
def _(self: Expr) ->
|
|
239
|
+
def _(self: Expr) -> ts.ColumnType:
|
|
241
240
|
return self.col_type
|
|
242
241
|
|
|
243
242
|
|
|
@@ -10,6 +10,7 @@ from typing import TYPE_CHECKING, Optional, TypeVar, Union
|
|
|
10
10
|
import numpy as np
|
|
11
11
|
|
|
12
12
|
import pixeltable as pxt
|
|
13
|
+
import pixeltable.type_system as ts
|
|
13
14
|
from pixeltable.env import Env, register_client
|
|
14
15
|
from pixeltable.func.signature import Batch
|
|
15
16
|
from pixeltable.utils.code import local_public_names
|
|
@@ -176,9 +177,9 @@ async def embeddings(input: Batch[str], *, model: str) -> Batch[pxt.Array[(None,
|
|
|
176
177
|
|
|
177
178
|
|
|
178
179
|
@embeddings.conditional_return_type
|
|
179
|
-
def _(model: str) ->
|
|
180
|
+
def _(model: str) -> ts.ArrayType:
|
|
180
181
|
dimensions = _embedding_dimensions_cache.get(model) # `None` if unknown model
|
|
181
|
-
return
|
|
182
|
+
return ts.ArrayType((dimensions,), dtype=ts.FloatType())
|
|
182
183
|
|
|
183
184
|
|
|
184
185
|
_T = TypeVar('_T')
|
|
@@ -21,6 +21,7 @@ import numpy as np
|
|
|
21
21
|
import PIL
|
|
22
22
|
|
|
23
23
|
import pixeltable as pxt
|
|
24
|
+
import pixeltable.type_system as ts
|
|
24
25
|
from pixeltable import env, exprs
|
|
25
26
|
from pixeltable.func import Batch, Tools
|
|
26
27
|
from pixeltable.utils.code import local_public_names
|
|
@@ -666,13 +667,13 @@ async def embeddings(
|
|
|
666
667
|
|
|
667
668
|
|
|
668
669
|
@embeddings.conditional_return_type
|
|
669
|
-
def _(model: str, dimensions: Optional[int] = None) ->
|
|
670
|
+
def _(model: str, dimensions: Optional[int] = None) -> ts.ArrayType:
|
|
670
671
|
if dimensions is None:
|
|
671
672
|
if model not in _embedding_dimensions_cache:
|
|
672
673
|
# TODO: find some other way to retrieve a sample
|
|
673
|
-
return
|
|
674
|
+
return ts.ArrayType((None,), dtype=ts.FloatType(), nullable=False)
|
|
674
675
|
dimensions = _embedding_dimensions_cache.get(model)
|
|
675
|
-
return
|
|
676
|
+
return ts.ArrayType((dimensions,), dtype=ts.FloatType(), nullable=False)
|
|
676
677
|
|
|
677
678
|
|
|
678
679
|
#####################################
|
|
@@ -738,17 +739,17 @@ async def image_generations(
|
|
|
738
739
|
|
|
739
740
|
|
|
740
741
|
@image_generations.conditional_return_type
|
|
741
|
-
def _(size: Optional[str] = None) ->
|
|
742
|
+
def _(size: Optional[str] = None) -> ts.ImageType:
|
|
742
743
|
if size is None:
|
|
743
|
-
return
|
|
744
|
+
return ts.ImageType(size=(1024, 1024))
|
|
744
745
|
x_pos = size.find('x')
|
|
745
746
|
if x_pos == -1:
|
|
746
|
-
return
|
|
747
|
+
return ts.ImageType()
|
|
747
748
|
try:
|
|
748
749
|
width, height = int(size[:x_pos]), int(size[x_pos + 1 :])
|
|
749
750
|
except ValueError:
|
|
750
|
-
return
|
|
751
|
-
return
|
|
751
|
+
return ts.ImageType()
|
|
752
|
+
return ts.ImageType(size=(width, height))
|
|
752
753
|
|
|
753
754
|
|
|
754
755
|
#####################################
|