pixeltable 0.3.6__py3-none-any.whl → 0.3.8__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 (127) hide show
  1. pixeltable/__init__.py +5 -3
  2. pixeltable/__version__.py +2 -2
  3. pixeltable/catalog/__init__.py +1 -0
  4. pixeltable/catalog/catalog.py +335 -128
  5. pixeltable/catalog/column.py +22 -5
  6. pixeltable/catalog/dir.py +19 -6
  7. pixeltable/catalog/insertable_table.py +34 -37
  8. pixeltable/catalog/named_function.py +0 -4
  9. pixeltable/catalog/schema_object.py +28 -42
  10. pixeltable/catalog/table.py +193 -158
  11. pixeltable/catalog/table_version.py +191 -232
  12. pixeltable/catalog/table_version_handle.py +50 -0
  13. pixeltable/catalog/table_version_path.py +49 -33
  14. pixeltable/catalog/view.py +56 -96
  15. pixeltable/config.py +103 -0
  16. pixeltable/dataframe.py +89 -89
  17. pixeltable/env.py +98 -168
  18. pixeltable/exec/aggregation_node.py +5 -4
  19. pixeltable/exec/cache_prefetch_node.py +1 -1
  20. pixeltable/exec/component_iteration_node.py +13 -9
  21. pixeltable/exec/data_row_batch.py +3 -3
  22. pixeltable/exec/exec_context.py +0 -4
  23. pixeltable/exec/exec_node.py +3 -2
  24. pixeltable/exec/expr_eval/schedulers.py +2 -1
  25. pixeltable/exec/in_memory_data_node.py +9 -4
  26. pixeltable/exec/row_update_node.py +1 -2
  27. pixeltable/exec/sql_node.py +20 -16
  28. pixeltable/exprs/__init__.py +2 -0
  29. pixeltable/exprs/arithmetic_expr.py +7 -11
  30. pixeltable/exprs/array_slice.py +1 -1
  31. pixeltable/exprs/column_property_ref.py +3 -3
  32. pixeltable/exprs/column_ref.py +12 -13
  33. pixeltable/exprs/comparison.py +3 -6
  34. pixeltable/exprs/compound_predicate.py +4 -4
  35. pixeltable/exprs/expr.py +31 -22
  36. pixeltable/exprs/expr_dict.py +3 -3
  37. pixeltable/exprs/expr_set.py +1 -1
  38. pixeltable/exprs/function_call.py +110 -80
  39. pixeltable/exprs/globals.py +3 -3
  40. pixeltable/exprs/in_predicate.py +1 -1
  41. pixeltable/exprs/inline_expr.py +3 -3
  42. pixeltable/exprs/is_null.py +1 -1
  43. pixeltable/exprs/json_mapper.py +2 -2
  44. pixeltable/exprs/json_path.py +17 -10
  45. pixeltable/exprs/literal.py +1 -1
  46. pixeltable/exprs/method_ref.py +2 -2
  47. pixeltable/exprs/row_builder.py +8 -17
  48. pixeltable/exprs/rowid_ref.py +21 -10
  49. pixeltable/exprs/similarity_expr.py +5 -5
  50. pixeltable/exprs/sql_element_cache.py +1 -1
  51. pixeltable/exprs/type_cast.py +2 -3
  52. pixeltable/exprs/variable.py +2 -2
  53. pixeltable/ext/__init__.py +2 -0
  54. pixeltable/ext/functions/__init__.py +2 -0
  55. pixeltable/ext/functions/yolox.py +3 -3
  56. pixeltable/func/__init__.py +3 -1
  57. pixeltable/func/aggregate_function.py +9 -9
  58. pixeltable/func/callable_function.py +3 -4
  59. pixeltable/func/expr_template_function.py +6 -16
  60. pixeltable/func/function.py +48 -14
  61. pixeltable/func/function_registry.py +1 -3
  62. pixeltable/func/query_template_function.py +5 -12
  63. pixeltable/func/signature.py +23 -22
  64. pixeltable/func/tools.py +3 -3
  65. pixeltable/func/udf.py +6 -4
  66. pixeltable/functions/__init__.py +2 -0
  67. pixeltable/functions/fireworks.py +7 -4
  68. pixeltable/functions/globals.py +4 -5
  69. pixeltable/functions/huggingface.py +1 -5
  70. pixeltable/functions/image.py +17 -7
  71. pixeltable/functions/llama_cpp.py +1 -1
  72. pixeltable/functions/mistralai.py +1 -1
  73. pixeltable/functions/ollama.py +4 -4
  74. pixeltable/functions/openai.py +19 -19
  75. pixeltable/functions/string.py +23 -30
  76. pixeltable/functions/timestamp.py +11 -6
  77. pixeltable/functions/together.py +14 -12
  78. pixeltable/functions/util.py +1 -1
  79. pixeltable/functions/video.py +5 -4
  80. pixeltable/functions/vision.py +6 -9
  81. pixeltable/functions/whisper.py +3 -3
  82. pixeltable/globals.py +246 -260
  83. pixeltable/index/__init__.py +2 -0
  84. pixeltable/index/base.py +1 -1
  85. pixeltable/index/btree.py +3 -1
  86. pixeltable/index/embedding_index.py +11 -5
  87. pixeltable/io/external_store.py +11 -12
  88. pixeltable/io/label_studio.py +4 -3
  89. pixeltable/io/parquet.py +57 -56
  90. pixeltable/iterators/__init__.py +4 -2
  91. pixeltable/iterators/audio.py +11 -11
  92. pixeltable/iterators/document.py +10 -10
  93. pixeltable/iterators/string.py +1 -2
  94. pixeltable/iterators/video.py +14 -15
  95. pixeltable/metadata/__init__.py +9 -5
  96. pixeltable/metadata/converters/convert_10.py +0 -1
  97. pixeltable/metadata/converters/convert_15.py +0 -2
  98. pixeltable/metadata/converters/convert_23.py +0 -2
  99. pixeltable/metadata/converters/convert_24.py +3 -3
  100. pixeltable/metadata/converters/convert_25.py +1 -1
  101. pixeltable/metadata/converters/convert_27.py +0 -2
  102. pixeltable/metadata/converters/convert_28.py +0 -2
  103. pixeltable/metadata/converters/convert_29.py +7 -8
  104. pixeltable/metadata/converters/util.py +7 -7
  105. pixeltable/metadata/schema.py +27 -19
  106. pixeltable/plan.py +68 -40
  107. pixeltable/share/__init__.py +2 -0
  108. pixeltable/share/packager.py +15 -12
  109. pixeltable/share/publish.py +3 -5
  110. pixeltable/store.py +37 -38
  111. pixeltable/type_system.py +41 -28
  112. pixeltable/utils/coco.py +4 -4
  113. pixeltable/utils/console_output.py +1 -3
  114. pixeltable/utils/description_helper.py +1 -1
  115. pixeltable/utils/documents.py +3 -3
  116. pixeltable/utils/filecache.py +20 -9
  117. pixeltable/utils/formatter.py +2 -3
  118. pixeltable/utils/media_store.py +1 -1
  119. pixeltable/utils/pytorch.py +1 -1
  120. pixeltable/utils/sql.py +4 -4
  121. pixeltable/utils/transactional_directory.py +2 -1
  122. {pixeltable-0.3.6.dist-info → pixeltable-0.3.8.dist-info}/METADATA +1 -1
  123. pixeltable-0.3.8.dist-info/RECORD +174 -0
  124. pixeltable-0.3.6.dist-info/RECORD +0 -172
  125. {pixeltable-0.3.6.dist-info → pixeltable-0.3.8.dist-info}/LICENSE +0 -0
  126. {pixeltable-0.3.6.dist-info → pixeltable-0.3.8.dist-info}/WHEEL +0 -0
  127. {pixeltable-0.3.6.dist-info → pixeltable-0.3.8.dist-info}/entry_points.txt +0 -0
@@ -68,7 +68,7 @@ async def completions(
68
68
  Generate completions based on a given prompt using a specified model.
69
69
 
70
70
  Equivalent to the Together AI `completions` API endpoint.
71
- For additional details, see: [https://docs.together.ai/reference/completions-1](https://docs.together.ai/reference/completions-1)
71
+ For additional details, see: <https://docs.together.ai/reference/completions-1>
72
72
 
73
73
  Request throttling:
74
74
  Applies the rate limit set in the config (section `together.rate_limits`, key `chat`). If no rate
@@ -82,14 +82,14 @@ async def completions(
82
82
  prompt: A string providing context for the model to complete.
83
83
  model: The name of the model to query.
84
84
 
85
- For details on the other parameters, see: [https://docs.together.ai/reference/completions-1](https://docs.together.ai/reference/completions-1)
85
+ For details on the other parameters, see: <https://docs.together.ai/reference/completions-1>
86
86
 
87
87
  Returns:
88
88
  A dictionary containing the response and other metadata.
89
89
 
90
90
  Examples:
91
- Add a computed column that applies the model `mistralai/Mixtral-8x7B-v0.1` to an existing Pixeltable column `tbl.prompt`
92
- of the table `tbl`:
91
+ Add a computed column that applies the model `mistralai/Mixtral-8x7B-v0.1` to an existing Pixeltable column
92
+ `tbl.prompt` of the table `tbl`:
93
93
 
94
94
  >>> tbl.add_computed_column(response=completions(tbl.prompt, model='mistralai/Mixtral-8x7B-v0.1'))
95
95
  """
@@ -133,7 +133,7 @@ async def chat_completions(
133
133
  Generate chat completions based on a given prompt using a specified model.
134
134
 
135
135
  Equivalent to the Together AI `chat/completions` API endpoint.
136
- For additional details, see: [https://docs.together.ai/reference/chat-completions-1](https://docs.together.ai/reference/chat-completions-1)
136
+ For additional details, see: <https://docs.together.ai/reference/chat-completions-1>
137
137
 
138
138
  Request throttling:
139
139
  Applies the rate limit set in the config (section `together.rate_limits`, key `chat`). If no rate
@@ -147,14 +147,14 @@ async def chat_completions(
147
147
  messages: A list of messages comprising the conversation so far.
148
148
  model: The name of the model to query.
149
149
 
150
- For details on the other parameters, see: [https://docs.together.ai/reference/chat-completions-1](https://docs.together.ai/reference/chat-completions-1)
150
+ For details on the other parameters, see: <https://docs.together.ai/reference/chat-completions-1>
151
151
 
152
152
  Returns:
153
153
  A dictionary containing the response and other metadata.
154
154
 
155
155
  Examples:
156
- Add a computed column that applies the model `mistralai/Mixtral-8x7B-v0.1` to an existing Pixeltable column `tbl.prompt`
157
- of the table `tbl`:
156
+ Add a computed column that applies the model `mistralai/Mixtral-8x7B-v0.1` to an existing Pixeltable column
157
+ `tbl.prompt` of the table `tbl`:
158
158
 
159
159
  >>> messages = [{'role': 'user', 'content': tbl.prompt}]
160
160
  ... tbl.add_computed_column(response=chat_completions(messages, model='mistralai/Mixtral-8x7B-v0.1'))
@@ -197,7 +197,7 @@ async def embeddings(input: Batch[str], *, model: str) -> Batch[pxt.Array[(None,
197
197
  Query an embedding model for a given string of text.
198
198
 
199
199
  Equivalent to the Together AI `embeddings` API endpoint.
200
- For additional details, see: [https://docs.together.ai/reference/embeddings-2](https://docs.together.ai/reference/embeddings-2)
200
+ For additional details, see: <https://docs.together.ai/reference/embeddings-2>
201
201
 
202
202
  Request throttling:
203
203
  Applies the rate limit set in the config (section `together.rate_limits`, key `embeddings`). If no rate
@@ -248,7 +248,7 @@ async def image_generations(
248
248
  Generate images based on a given prompt using a specified model.
249
249
 
250
250
  Equivalent to the Together AI `images/generations` API endpoint.
251
- For additional details, see: [https://docs.together.ai/reference/post_images-generations](https://docs.together.ai/reference/post_images-generations)
251
+ For additional details, see: <https://docs.together.ai/reference/post_images-generations>
252
252
 
253
253
  Request throttling:
254
254
  Applies the rate limit set in the config (section `together.rate_limits`, key `images`). If no rate
@@ -262,7 +262,7 @@ async def image_generations(
262
262
  prompt: A description of the desired images.
263
263
  model: The model to use for image generation.
264
264
 
265
- For details on the other parameters, see: [https://docs.together.ai/reference/post_images-generations](https://docs.together.ai/reference/post_images-generations)
265
+ For details on the other parameters, see: <https://docs.together.ai/reference/post_images-generations>
266
266
 
267
267
  Returns:
268
268
  The generated image.
@@ -271,7 +271,9 @@ async def image_generations(
271
271
  Add a computed column that applies the model `stabilityai/stable-diffusion-xl-base-1.0`
272
272
  to an existing Pixeltable column `tbl.prompt` of the table `tbl`:
273
273
 
274
- >>> tbl.add_computed_column(response=image_generations(tbl.prompt, model='stabilityai/stable-diffusion-xl-base-1.0'))
274
+ >>> tbl.add_computed_column(
275
+ ... response=image_generations(tbl.prompt, model='stabilityai/stable-diffusion-xl-base-1.0')
276
+ ... )
275
277
  """
276
278
  result = await _together_client().images.generate(
277
279
  prompt=prompt, model=model, steps=steps, seed=seed, height=height, width=width, negative_prompt=negative_prompt
@@ -21,7 +21,7 @@ def normalize_image_mode(image: PIL.Image.Image) -> PIL.Image.Image:
21
21
  Converts grayscale images to 3-channel for compatibility with models that only work with
22
22
  multichannel input.
23
23
  """
24
- if image.mode == '1' or image.mode == 'L':
24
+ if image.mode in {'1', 'L'}:
25
25
  return image.convert('RGB')
26
26
  if image.mode == 'LA':
27
27
  return image.convert('RGBA')
@@ -21,18 +21,19 @@ import numpy as np
21
21
  import PIL.Image
22
22
 
23
23
  import pixeltable as pxt
24
- import pixeltable.env as env
24
+ from pixeltable import env
25
25
  from pixeltable.utils.code import local_public_names
26
26
 
27
27
  _format_defaults = { # format -> (codec, ext)
28
28
  'wav': ('pcm_s16le', 'wav'),
29
29
  'mp3': ('libmp3lame', 'mp3'),
30
30
  'flac': ('flac', 'flac'),
31
- #'mp4': ('aac', 'm4a'),
31
+ # 'mp4': ('aac', 'm4a'),
32
32
  }
33
33
 
34
34
  # for mp4:
35
- # - extract_audio() fails with "Application provided invalid, non monotonically increasing dts to muxer in stream 0: 1146 >= 290"
35
+ # - extract_audio() fails with
36
+ # "Application provided invalid, non monotonically increasing dts to muxer in stream 0: 1146 >= 290"
36
37
  # - chatgpt suggests this can be fixed in the following manner
37
38
  # for packet in container.demux(audio_stream):
38
39
  # packet.pts = None # Reset the PTS and DTS to allow FFmpeg to set them automatically
@@ -142,7 +143,7 @@ def _get_metadata(path: str) -> dict:
142
143
 
143
144
 
144
145
  def __get_stream_metadata(stream: av.stream.Stream) -> dict:
145
- if stream.type != 'audio' and stream.type != 'video':
146
+ if stream.type not in {'audio', 'video'}:
146
147
  return {'type': stream.type} # Currently unsupported
147
148
 
148
149
  codec_context = stream.codec_context
@@ -250,7 +250,6 @@ class mean_ap(pxt.Aggregator):
250
250
  eps = np.finfo(np.float32).eps
251
251
  result: dict[int, float] = {}
252
252
  for class_idx, tpfp in self.class_tpfp.items():
253
- a1 = [x['tp'] for x in tpfp]
254
253
  tp = np.concatenate([x['tp'] for x in tpfp], axis=0)
255
254
  fp = np.concatenate([x['fp'] for x in tpfp], axis=0)
256
255
  num_gts = np.sum([x['num_gts'] for x in tpfp])
@@ -341,16 +340,14 @@ def draw_bounding_boxes(
341
340
  elif len(labels) != num_boxes:
342
341
  raise ValueError('Number of boxes and labels must match')
343
342
 
344
- DEFAULT_COLOR = 'white'
345
343
  if box_colors is not None:
346
344
  if len(box_colors) != num_boxes:
347
345
  raise ValueError('Number of boxes and box colors must match')
346
+ elif color is not None:
347
+ box_colors = [color] * num_boxes
348
348
  else:
349
- if color is not None:
350
- box_colors = [color] * num_boxes
351
- else:
352
- label_colors = __create_label_colors(labels)
353
- box_colors = [label_colors[label] for label in labels]
349
+ label_colors = __create_label_colors(labels)
350
+ box_colors = [label_colors[label] for label in labels]
354
351
 
355
352
  from PIL import ImageColor, ImageDraw, ImageFont
356
353
 
@@ -369,13 +366,13 @@ def draw_bounding_boxes(
369
366
 
370
367
  if fill:
371
368
  rgb_color = ImageColor.getrgb(color)
372
- fill_color = rgb_color + (100,) # semi-transparent
369
+ fill_color = (*rgb_color, 100) # semi-transparent
373
370
  draw.rectangle(bbox, outline=color, width=width, fill=fill_color) # type: ignore[arg-type]
374
371
  else:
375
372
  draw.rectangle(bbox, outline=color, width=width) # type: ignore[arg-type]
376
373
 
377
374
  # Now draw labels separately, so they are not obscured by the boxes
378
- for i, (bbox, label) in enumerate(zip(boxes, labels)):
375
+ for bbox, label in zip(boxes, labels):
379
376
  if label is not None:
380
377
  label_str = str(label)
381
378
  _, _, text_width, text_height = draw.textbbox((0, 0), label_str, font=txt_font)
@@ -6,7 +6,7 @@ This UDF will cause Pixeltable to invoke the relevant model locally. In order to
6
6
  first `pip install openai-whisper`.
7
7
  """
8
8
 
9
- from typing import TYPE_CHECKING, Optional
9
+ from typing import TYPE_CHECKING, Optional, Sequence
10
10
 
11
11
  import pixeltable as pxt
12
12
  from pixeltable.env import Env
@@ -20,7 +20,7 @@ def transcribe(
20
20
  audio: pxt.Audio,
21
21
  *,
22
22
  model: str,
23
- temperature: Optional[list[float]] = [0.0, 0.2, 0.4, 0.6, 0.8, 1.0],
23
+ temperature: Optional[Sequence[float]] = (0.0, 0.2, 0.4, 0.6, 0.8, 1.0),
24
24
  compression_ratio_threshold: Optional[float] = 2.4,
25
25
  logprob_threshold: Optional[float] = -1.0,
26
26
  no_speech_threshold: Optional[float] = 0.6,
@@ -28,7 +28,7 @@ def transcribe(
28
28
  initial_prompt: Optional[str] = None,
29
29
  word_timestamps: bool = False,
30
30
  prepend_punctuations: str = '"\'“¿([{-',
31
- append_punctuations: str = '"\'.。,,!!??::”)]}、',
31
+ append_punctuations: str = '"\'.。,,!!??::”)]}、', # noqa: RUF001
32
32
  decode_options: Optional[dict] = None,
33
33
  ) -> dict:
34
34
  """