pixeltable 0.2.28__py3-none-any.whl → 0.2.30__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 (62) hide show
  1. pixeltable/__init__.py +1 -1
  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 +96 -19
  10. pixeltable/catalog/table_version.py +22 -8
  11. pixeltable/dataframe.py +201 -3
  12. pixeltable/env.py +9 -3
  13. pixeltable/exec/expr_eval_node.py +1 -1
  14. pixeltable/exec/sql_node.py +2 -2
  15. pixeltable/exprs/function_call.py +134 -29
  16. pixeltable/exprs/inline_expr.py +22 -2
  17. pixeltable/exprs/row_builder.py +1 -1
  18. pixeltable/exprs/similarity_expr.py +9 -2
  19. pixeltable/func/__init__.py +1 -0
  20. pixeltable/func/aggregate_function.py +151 -68
  21. pixeltable/func/callable_function.py +50 -16
  22. pixeltable/func/expr_template_function.py +62 -24
  23. pixeltable/func/function.py +191 -23
  24. pixeltable/func/function_registry.py +2 -1
  25. pixeltable/func/query_template_function.py +11 -6
  26. pixeltable/func/signature.py +64 -7
  27. pixeltable/func/tools.py +116 -0
  28. pixeltable/func/udf.py +57 -35
  29. pixeltable/functions/__init__.py +2 -2
  30. pixeltable/functions/anthropic.py +36 -2
  31. pixeltable/functions/globals.py +54 -34
  32. pixeltable/functions/json.py +3 -8
  33. pixeltable/functions/math.py +67 -0
  34. pixeltable/functions/ollama.py +4 -4
  35. pixeltable/functions/openai.py +31 -2
  36. pixeltable/functions/timestamp.py +1 -1
  37. pixeltable/functions/video.py +2 -8
  38. pixeltable/functions/vision.py +1 -1
  39. pixeltable/globals.py +347 -79
  40. pixeltable/index/embedding_index.py +44 -24
  41. pixeltable/metadata/__init__.py +1 -1
  42. pixeltable/metadata/converters/convert_16.py +2 -1
  43. pixeltable/metadata/converters/convert_17.py +2 -1
  44. pixeltable/metadata/converters/convert_23.py +35 -0
  45. pixeltable/metadata/converters/convert_24.py +47 -0
  46. pixeltable/metadata/converters/util.py +4 -2
  47. pixeltable/metadata/notes.py +2 -0
  48. pixeltable/metadata/schema.py +1 -0
  49. pixeltable/type_system.py +192 -48
  50. {pixeltable-0.2.28.dist-info → pixeltable-0.2.30.dist-info}/METADATA +4 -2
  51. {pixeltable-0.2.28.dist-info → pixeltable-0.2.30.dist-info}/RECORD +54 -57
  52. pixeltable-0.2.30.dist-info/entry_points.txt +3 -0
  53. pixeltable/tool/create_test_db_dump.py +0 -311
  54. pixeltable/tool/create_test_video.py +0 -81
  55. pixeltable/tool/doc_plugins/griffe.py +0 -50
  56. pixeltable/tool/doc_plugins/mkdocstrings.py +0 -6
  57. pixeltable/tool/doc_plugins/templates/material/udf.html.jinja +0 -135
  58. pixeltable/tool/embed_udf.py +0 -9
  59. pixeltable/tool/mypy_plugin.py +0 -55
  60. pixeltable-0.2.28.dist-info/entry_points.txt +0 -3
  61. {pixeltable-0.2.28.dist-info → pixeltable-0.2.30.dist-info}/LICENSE +0 -0
  62. {pixeltable-0.2.28.dist-info → pixeltable-0.2.30.dist-info}/WHEEL +0 -0
@@ -1,50 +0,0 @@
1
- import ast
2
- import warnings
3
- from typing import Optional, Union
4
-
5
- import griffe
6
- import griffe.expressions
7
- from griffe import Extension, Object, ObjectNode
8
-
9
- import pixeltable as pxt
10
-
11
- logger = griffe.get_logger(__name__)
12
-
13
- class PxtGriffeExtension(Extension):
14
- """Implementation of a Pixeltable custom griffe extension."""
15
-
16
- def on_instance(self, node: Union[ast.AST, ObjectNode], obj: Object) -> None:
17
- if obj.docstring is None:
18
- # Skip over entities without a docstring
19
- return
20
-
21
- if isinstance(obj, griffe.Function):
22
- # See if the (Python) function has a @pxt.udf decorator
23
- if any(
24
- isinstance(dec.value, griffe.expressions.Expr) and dec.value.canonical_path in ['pixeltable.func.udf', 'pixeltable.udf']
25
- for dec in obj.decorators
26
- ):
27
- # Update the template
28
- self.__modify_pxt_udf(obj)
29
-
30
- def __modify_pxt_udf(self, func: griffe.Function) -> None:
31
- """
32
- Instructs the doc snippet for `func` to use the custom Pixeltable UDF jinja template, and
33
- converts all type hints to Pixeltable column type references, in accordance with the @udf
34
- decorator behavior.
35
- """
36
- func.extra['mkdocstrings']['template'] = 'udf.html.jinja'
37
- # Dynamically load the UDF reference so we can inspect the Pixeltable signature directly
38
- warnings.simplefilter("ignore")
39
- udf = griffe.dynamic_import(func.path)
40
- assert isinstance(udf, pxt.Function)
41
- # Convert the return type to a Pixeltable type reference
42
- func.returns = str(udf.signature.get_return_type())
43
- # Convert the parameter types to Pixeltable type references
44
- for griffe_param in func.parameters:
45
- assert isinstance(griffe_param.annotation, griffe.expressions.Expr)
46
- if griffe_param.name not in udf.signature.parameters:
47
- logger.warning(f'Parameter `{griffe_param.name}` not found in signature for UDF: {udf.display_name}')
48
- continue
49
- pxt_param = udf.signature.parameters[griffe_param.name]
50
- griffe_param.annotation = str(pxt_param.col_type)
@@ -1,6 +0,0 @@
1
- from pathlib import Path
2
-
3
-
4
- def get_templates_path() -> Path:
5
- """Implementation of the 'mkdocstrings.python.templates' plugin for custom jinja templates."""
6
- return Path(__file__).parent / "templates"
@@ -1,135 +0,0 @@
1
- {#- Template for Pixeltable UDFs. Cargo-culted (with modification) from _base/function.html.jinja. -#}
2
-
3
- {% block logs scoped %}
4
- {#- Logging block.
5
-
6
- This block can be used to log debug messages, deprecation messages, warnings, etc.
7
- -#}
8
- {{ log.debug("Rendering " + function.path) }}
9
- {% endblock logs %}
10
-
11
- {% import "language"|get_template as lang with context %}
12
- {#- Language module providing the `t` translation method. -#}
13
-
14
- <div class="doc doc-object doc-function">
15
- {% with obj = function, html_id = function.path %}
16
-
17
- {% if root %}
18
- {% set show_full_path = config.show_root_full_path %}
19
- {% set root_members = True %}
20
- {% elif root_members %}
21
- {% set show_full_path = config.show_root_members_full_path or config.show_object_full_path %}
22
- {% set root_members = False %}
23
- {% else %}
24
- {% set show_full_path = config.show_object_full_path %}
25
- {% endif %}
26
-
27
- {% set function_name = function.path if show_full_path else function.name %}
28
- {#- Brief or full function name depending on configuration. -#}
29
- {% set symbol_type = "udf" %}
30
- {#- Symbol type: method when parent is a class, function otherwise. -#}
31
-
32
- {% if not root or config.show_root_heading %}
33
- {% filter heading(
34
- heading_level,
35
- role="function",
36
- id=html_id,
37
- class="doc doc-heading",
38
- toc_label=(('<code class="doc-symbol doc-symbol-toc doc-symbol-' + symbol_type + '"></code>&nbsp;')|safe if config.show_symbol_type_toc else '') + function.name,
39
- ) %}
40
-
41
- {% block heading scoped %}
42
- {#- Heading block.
43
-
44
- This block renders the heading for the function.
45
- -#}
46
- {% if config.show_symbol_type_heading %}<code class="doc-symbol doc-symbol-heading doc-symbol-{{ symbol_type }}"></code>{% endif %}
47
- {% if config.separate_signature %}
48
- <span class="doc doc-object-name doc-function-name">{{ function_name }}</span>
49
- {% else %}
50
- {%+ filter highlight(language="python", inline=True) %}
51
- {{ function_name }}{% include "signature"|get_template with context %}
52
- {% endfilter %}
53
- {% endif %}
54
- {% endblock heading %}
55
-
56
- {% block labels scoped %}
57
- {#- Labels block.
58
-
59
- This block renders the labels for the function.
60
- -#}
61
- {% with labels = function.labels %}
62
- {% include "labels"|get_template with context %}
63
- {% endwith %}
64
- {% endblock labels %}
65
-
66
- {% endfilter %}
67
-
68
- {% block signature scoped %}
69
- {#- Signature block.
70
-
71
- This block renders the signature for the function.
72
- -#}
73
- {% if config.separate_signature %}
74
- {% filter format_signature(function, config.line_length, crossrefs=config.signature_crossrefs) %}
75
- {{ function.name }}
76
- {% endfilter %}
77
- {% endif %}
78
- {% endblock signature %}
79
-
80
- {% else %}
81
-
82
- {% if config.show_root_toc_entry %}
83
- {% filter heading(
84
- heading_level,
85
- role="function",
86
- id=html_id,
87
- toc_label=(('<code class="doc-symbol doc-symbol-toc doc-symbol-' + symbol_type + '"></code>&nbsp;')|safe if config.show_symbol_type_toc else '') + function.name,
88
- hidden=True,
89
- ) %}
90
- {% endfilter %}
91
- {% endif %}
92
- {% set heading_level = heading_level - 1 %}
93
- {% endif %}
94
-
95
- <div class="doc doc-contents {% if root %}first{% endif %}">
96
- {% block contents scoped %}
97
- {#- Contents block.
98
-
99
- This block renders the contents of the function.
100
- It contains other blocks that users can override.
101
- Overriding the contents block allows to rearrange the order of the blocks.
102
- -#}
103
- {% block docstring scoped %}
104
- {#- Docstring block.
105
-
106
- This block renders the docstring for the function.
107
- -#}
108
- {% with docstring_sections = function.docstring.parsed %}
109
- {% include "docstring"|get_template with context %}
110
- {% endwith %}
111
- {% endblock docstring %}
112
-
113
- {% block source scoped %}
114
- {#- Source block.
115
-
116
- This block renders the source code for the function.
117
- -#}
118
- {% if config.show_source and function.source %}
119
- <details class="quote">
120
- <summary>{{ lang.t("Source code in") }} <code>
121
- {%- if function.relative_filepath.is_absolute() -%}
122
- {{ function.relative_package_filepath }}
123
- {%- else -%}
124
- {{ function.relative_filepath }}
125
- {%- endif -%}
126
- </code></summary>
127
- {{ function.source|highlight(language="python", linestart=function.lineno, linenums=True) }}
128
- </details>
129
- {% endif %}
130
- {% endblock source %}
131
- {% endblock contents %}
132
- </div>
133
-
134
- {% endwith %}
135
- </div>
@@ -1,9 +0,0 @@
1
- import numpy as np
2
-
3
- import pixeltable as pxt
4
-
5
-
6
- # TODO This can go away once we have the ability to inline expr_udf's
7
- @pxt.expr_udf
8
- def clip_text_embed(txt: str) -> np.ndarray:
9
- return pxt.functions.huggingface.clip_text(txt, model_id='openai/clip-vit-base-patch32') # type: ignore[return-value]
@@ -1,55 +0,0 @@
1
- from typing import Callable, Optional
2
-
3
- from mypy import nodes
4
- from mypy.plugin import AnalyzeTypeContext, ClassDefContext, Plugin
5
- from mypy.plugins.common import add_method_to_class
6
- from mypy.types import AnyType, Type, TypeOfAny
7
-
8
- import pixeltable as pxt
9
-
10
-
11
- class PxtPlugin(Plugin):
12
- __UDA_FULLNAME = f'{pxt.uda.__module__}.{pxt.uda.__name__}'
13
- __TYPE_MAP = {
14
- pxt.Json: 'typing.Any',
15
- pxt.Array: 'numpy.ndarray',
16
- pxt.Image: 'PIL.Image.Image',
17
- pxt.Video: 'builtins.str',
18
- pxt.Audio: 'builtins.str',
19
- pxt.Document: 'builtins.str',
20
- }
21
- __FULLNAME_MAP = {
22
- f'{k.__module__}.{k.__name__}': v
23
- for k, v in __TYPE_MAP.items()
24
- }
25
-
26
- def get_type_analyze_hook(self, fullname: str) -> Optional[Callable[[AnalyzeTypeContext], Type]]:
27
- if fullname in self.__FULLNAME_MAP:
28
- subst_name = self.__FULLNAME_MAP[fullname]
29
- return lambda ctx: pxt_hook(ctx, subst_name)
30
- return None
31
-
32
- def get_class_decorator_hook_2(self, fullname: str) -> Optional[Callable[[ClassDefContext], bool]]:
33
- if fullname == self.__UDA_FULLNAME:
34
- return pxt_decorator_hook
35
- return None
36
-
37
- def plugin(version: str) -> type:
38
- return PxtPlugin
39
-
40
- def pxt_hook(ctx: AnalyzeTypeContext, subst_name: str) -> Type:
41
- if subst_name == 'typing.Any':
42
- return AnyType(TypeOfAny.special_form)
43
- return ctx.api.named_type(subst_name, [])
44
-
45
- def pxt_decorator_hook(ctx: ClassDefContext) -> bool:
46
- arg = nodes.Argument(nodes.Var('fn'), AnyType(TypeOfAny.special_form), None, nodes.ARG_POS)
47
- add_method_to_class(
48
- ctx.api,
49
- ctx.cls,
50
- "to_sql",
51
- args=[arg],
52
- return_type=AnyType(TypeOfAny.special_form),
53
- is_staticmethod=True,
54
- )
55
- return True
@@ -1,3 +0,0 @@
1
- [mkdocstrings.python.templates]
2
- extension-name=pixeltable.tool.doc_plugins.mkdocstrings:get_templates_path
3
-