cocoindex 0.1.59__cp313-cp313-manylinux_2_28_x86_64.whl → 0.1.61__cp313-cp313-manylinux_2_28_x86_64.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.
cocoindex/__init__.py CHANGED
@@ -12,12 +12,21 @@ from .flow import flow_def
12
12
  from .flow import EvaluateAndDumpOptions, GeneratedField
13
13
  from .flow import FlowLiveUpdater, FlowLiveUpdaterOptions
14
14
  from .flow import update_all_flows_async, setup_all_flows, drop_all_flows
15
- from .lib import init, start_server, stop, main_fn
15
+ from .lib import init, start_server, stop
16
16
  from .llm import LlmSpec, LlmApiType
17
17
  from .index import VectorSimilarityMetric, VectorIndexDef, IndexOptions
18
18
  from .setting import DatabaseConnectionSpec, Settings, ServerSettings
19
19
  from .setting import get_app_namespace
20
- from .typing import Float32, Float64, LocalDateTime, OffsetDateTime, Range, Vector, Json
20
+ from .typing import (
21
+ Int64,
22
+ Float32,
23
+ Float64,
24
+ LocalDateTime,
25
+ OffsetDateTime,
26
+ Range,
27
+ Vector,
28
+ Json,
29
+ )
21
30
 
22
31
  __all__ = [
23
32
  # Submodules
@@ -50,7 +59,6 @@ __all__ = [
50
59
  "init",
51
60
  "start_server",
52
61
  "stop",
53
- "main_fn",
54
62
  # LLM
55
63
  "LlmSpec",
56
64
  "LlmApiType",
@@ -64,6 +72,7 @@ __all__ = [
64
72
  "ServerSettings",
65
73
  "get_app_namespace",
66
74
  # Typing
75
+ "Int64",
67
76
  "Float32",
68
77
  "Float64",
69
78
  "LocalDateTime",
cocoindex/flow.py CHANGED
@@ -416,6 +416,11 @@ class _SourceRefreshOptions:
416
416
  refresh_interval: datetime.timedelta | None = None
417
417
 
418
418
 
419
+ @dataclass
420
+ class _ExecutionOptions:
421
+ max_inflight_count: int | None = None
422
+
423
+
419
424
  class FlowBuilder:
420
425
  """
421
426
  A flow builder is used to build a flow.
@@ -439,6 +444,7 @@ class FlowBuilder:
439
444
  *,
440
445
  name: str | None = None,
441
446
  refresh_interval: datetime.timedelta | None = None,
447
+ max_inflight_count: int | None = None,
442
448
  ) -> DataSlice[T]:
443
449
  """
444
450
  Import a source to the flow.
@@ -454,9 +460,12 @@ class FlowBuilder:
454
460
  self._state.field_name_builder.build_name(
455
461
  name, prefix=_to_snake_case(_spec_kind(spec)) + "_"
456
462
  ),
457
- dump_engine_object(
463
+ refresh_options=dump_engine_object(
458
464
  _SourceRefreshOptions(refresh_interval=refresh_interval)
459
465
  ),
466
+ execution_options=dump_engine_object(
467
+ _ExecutionOptions(max_inflight_count=max_inflight_count)
468
+ ),
460
469
  ),
461
470
  name,
462
471
  )
cocoindex/lib.py CHANGED
@@ -30,46 +30,3 @@ def start_server(settings: setting.ServerSettings) -> None:
30
30
  def stop() -> None:
31
31
  """Stop the cocoindex library."""
32
32
  _engine.stop()
33
-
34
-
35
- def main_fn(
36
- settings: Any | None = None,
37
- cocoindex_cmd: str | None = None,
38
- ) -> Callable[[Callable[..., Any]], Callable[..., Any]]:
39
- """
40
- DEPRECATED: The @cocoindex.main_fn() decorator is obsolete and has no effect.
41
- It will be removed in a future version, which will cause an AttributeError.
42
-
43
- Please remove this decorator from your code and use the standalone 'cocoindex' CLI.
44
- See the updated CLI usage examples in the warning message.
45
- """
46
- warnings.warn(
47
- "\n\n"
48
- "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n"
49
- "CRITICAL DEPRECATION NOTICE from CocoIndex:\n"
50
- "The @cocoindex.main_fn() decorator in your script is DEPRECATED and IGNORED.\n"
51
- "It provides NO functionality and will be REMOVED entirely in a future version.\n"
52
- "If not removed, your script will FAIL with an AttributeError in the future.\n\n"
53
- "ACTION REQUIRED: Please REMOVE @cocoindex.main_fn() from your Python script.\n\n"
54
- "To use CocoIndex, invoke the standalone 'cocoindex' CLI."
55
- " Examples of new CLI usage:\n\n"
56
- " To list flows from 'main.py' (previously 'python main.py cocoindex ls'):\n"
57
- " cocoindex ls main.py\n\n"
58
- " To list all persisted flows (previously 'python main.py cocoindex ls --all'):\n"
59
- " cocoindex ls\n\n"
60
- " To show 'MyFlow' defined in 'main.py' (previously 'python main.py cocoindex show MyFlow'):\n"
61
- " cocoindex show main.py:MyFlow\n\n"
62
- " To update all flows in 'my_package.flows_module':\n"
63
- " cocoindex update my_package.flows_module\n\n"
64
- " To update 'SpecificFlow' in 'my_package.flows_module':\n"
65
- " cocoindex update my_package.flows_module:SpecificFlow\n\n"
66
- "See cocoindex <command> --help for more details.\n"
67
- "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n\n",
68
- DeprecationWarning,
69
- stacklevel=2,
70
- )
71
-
72
- def _main_wrapper(fn: Callable[..., Any]) -> Callable[..., Any]:
73
- return fn
74
-
75
- return _main_wrapper
@@ -78,16 +78,15 @@ def build_engine_value_decoder(
78
78
  return make_engine_value_decoder([], engine_type, python_type or engine_type_in_py)
79
79
 
80
80
 
81
- def validate_full_roundtrip(
81
+ def validate_full_roundtrip_to(
82
82
  value: Any,
83
- value_type: Any = None,
84
- *other_decoded_values: tuple[Any, Any],
83
+ value_type: Any,
84
+ *decoded_values: tuple[Any, Any],
85
85
  ) -> None:
86
86
  """
87
- Validate the given value doesn't change after encoding, sending to engine (using output_type), receiving back and decoding (using input_type).
87
+ Validate the given value becomes specific values after encoding, sending to engine (using output_type), receiving back and decoding (using input_type).
88
88
 
89
- `other_decoded_values` is a tuple of (value, type) pairs.
90
- If provided, also validate the value can be decoded to the other types.
89
+ `decoded_values` is a tuple of (value, type) pairs.
91
90
  """
92
91
  from cocoindex import _engine # type: ignore
93
92
 
@@ -102,15 +101,27 @@ def validate_full_roundtrip(
102
101
  value_from_engine = _engine.testutil.seder_roundtrip(
103
102
  encoded_value, encoded_output_type
104
103
  )
105
- decoder = make_engine_value_decoder([], encoded_output_type, value_type)
106
- decoded_value = decoder(value_from_engine)
107
- assert eq(decoded_value, value), f"{decoded_value} != {value}"
108
104
 
109
- if other_decoded_values is not None:
110
- for other_value, other_type in other_decoded_values:
111
- decoder = make_engine_value_decoder([], encoded_output_type, other_type)
112
- other_decoded_value = decoder(value_from_engine)
113
- assert eq(other_decoded_value, other_value)
105
+ for other_value, other_type in decoded_values:
106
+ decoder = make_engine_value_decoder([], encoded_output_type, other_type)
107
+ other_decoded_value = decoder(value_from_engine)
108
+ assert eq(other_decoded_value, other_value)
109
+
110
+
111
+ def validate_full_roundtrip(
112
+ value: Any,
113
+ value_type: Any,
114
+ *other_decoded_values: tuple[Any, Any],
115
+ ) -> None:
116
+ """
117
+ Validate the given value doesn't change after encoding, sending to engine (using output_type), receiving back and decoding (using input_type).
118
+
119
+ `other_decoded_values` is a tuple of (value, type) pairs.
120
+ If provided, also validate the value can be decoded to the other types.
121
+ """
122
+ validate_full_roundtrip_to(
123
+ value, value_type, (value, value_type), *other_decoded_values
124
+ )
114
125
 
115
126
 
116
127
  def test_encode_engine_value_basic_types() -> None:
@@ -218,17 +229,33 @@ def test_encode_engine_value_none() -> None:
218
229
 
219
230
 
220
231
  def test_roundtrip_basic_types() -> None:
221
- validate_full_roundtrip(42, int, (42, None))
222
- validate_full_roundtrip(3.25, float, (3.25, Float64))
223
232
  validate_full_roundtrip(
224
- 3.25, Float64, (3.25, float), (np.float64(3.25), np.float64)
233
+ 42, cocoindex.Int64, (42, int), (np.int64(42), np.int64), (42, None)
225
234
  )
235
+ validate_full_roundtrip(42, int, (42, cocoindex.Int64))
236
+ validate_full_roundtrip(np.int64(42), np.int64, (42, cocoindex.Int64))
237
+
226
238
  validate_full_roundtrip(
227
- 3.25, Float32, (3.25, float), (np.float32(3.25), np.float32)
239
+ 3.25, Float64, (3.25, float), (np.float64(3.25), np.float64), (3.25, None)
228
240
  )
241
+ validate_full_roundtrip(3.25, float, (3.25, Float64))
242
+ validate_full_roundtrip(np.float64(3.25), np.float64, (3.25, Float64))
243
+
244
+ validate_full_roundtrip(
245
+ 3.25,
246
+ Float32,
247
+ (3.25, float),
248
+ (np.float32(3.25), np.float32),
249
+ (np.float64(3.25), np.float64),
250
+ (3.25, Float64),
251
+ (3.25, None),
252
+ )
253
+ validate_full_roundtrip(np.float32(3.25), np.float32, (3.25, Float32))
254
+
229
255
  validate_full_roundtrip("hello", str, ("hello", None))
230
256
  validate_full_roundtrip(True, bool, (True, None))
231
257
  validate_full_roundtrip(False, bool, (False, None))
258
+ validate_full_roundtrip((1, 2), cocoindex.Range, ((1, 2), None))
232
259
  validate_full_roundtrip(
233
260
  datetime.date(2025, 1, 1), datetime.date, (datetime.date(2025, 1, 1), None)
234
261
  )
@@ -238,14 +265,37 @@ def test_roundtrip_basic_types() -> None:
238
265
  cocoindex.LocalDateTime,
239
266
  (datetime.datetime(2025, 1, 2, 3, 4, 5, 123456), datetime.datetime),
240
267
  )
268
+
269
+ tz = datetime.timezone(datetime.timedelta(hours=5))
241
270
  validate_full_roundtrip(
242
- datetime.datetime(2025, 1, 2, 3, 4, 5, 123456, datetime.UTC),
271
+ datetime.datetime(2025, 1, 2, 3, 4, 5, 123456, tz),
272
+ cocoindex.OffsetDateTime,
273
+ (
274
+ datetime.datetime(2025, 1, 2, 3, 4, 5, 123456, tz),
275
+ datetime.datetime,
276
+ ),
277
+ )
278
+ validate_full_roundtrip(
279
+ datetime.datetime(2025, 1, 2, 3, 4, 5, 123456, tz),
280
+ datetime.datetime,
281
+ (datetime.datetime(2025, 1, 2, 3, 4, 5, 123456, tz), cocoindex.OffsetDateTime),
282
+ )
283
+ validate_full_roundtrip_to(
284
+ datetime.datetime(2025, 1, 2, 3, 4, 5, 123456),
243
285
  cocoindex.OffsetDateTime,
244
286
  (
245
287
  datetime.datetime(2025, 1, 2, 3, 4, 5, 123456, datetime.UTC),
246
288
  datetime.datetime,
247
289
  ),
248
290
  )
291
+ validate_full_roundtrip_to(
292
+ datetime.datetime(2025, 1, 2, 3, 4, 5, 123456),
293
+ datetime.datetime,
294
+ (
295
+ datetime.datetime(2025, 1, 2, 3, 4, 5, 123456, datetime.UTC),
296
+ cocoindex.OffsetDateTime,
297
+ ),
298
+ )
249
299
 
250
300
  uuid_value = uuid.uuid4()
251
301
  validate_full_roundtrip(uuid_value, uuid.UUID, (uuid_value, None))
cocoindex/typing.py CHANGED
@@ -40,6 +40,7 @@ class TypeAttr:
40
40
 
41
41
  Annotation = TypeKind | TypeAttr | VectorInfo
42
42
 
43
+ Int64 = Annotated[int, TypeKind("Int64")]
43
44
  Float32 = Annotated[float, TypeKind("Float32")]
44
45
  Float64 = Annotated[float, TypeKind("Float64")]
45
46
  Range = Annotated[tuple[int, int], TypeKind("Range")]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cocoindex
3
- Version: 0.1.59
3
+ Version: 0.1.61
4
4
  Requires-Dist: click>=8.1.8
5
5
  Requires-Dist: rich>=14.0.0
6
6
  Requires-Dist: python-dotenv>=1.1.0
@@ -1,16 +1,16 @@
1
- cocoindex-0.1.59.dist-info/METADATA,sha256=XyuEgs1E6LhwzhvSwCwjcRmzFZkEHaw-GFEgpp5qVn8,10020
2
- cocoindex-0.1.59.dist-info/WHEEL,sha256=LA67brojLOZ0i0Pcaw_z7b5IlOGp1xIEPobtgkZ23mU,108
3
- cocoindex-0.1.59.dist-info/entry_points.txt,sha256=_NretjYVzBdNTn7dK-zgwr7YfG2afz1u1uSE-5bZXF8,46
4
- cocoindex-0.1.59.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
5
- cocoindex/__init__.py,sha256=MFm-QJzrr0ODJCsAAsPUzJXh8KH1WdZod8F60B1iUYw,1877
6
- cocoindex/_engine.cpython-313-x86_64-linux-gnu.so,sha256=wG8dOSu6-Rj6tiDz4rE8kb43YjxD3EC7l9EWgCj0FGM,63204256
1
+ cocoindex-0.1.61.dist-info/METADATA,sha256=k-_WSzTH8tqfDz3Vk_LmL6iZIH1IcrlxYvxXpXxzJ1c,10020
2
+ cocoindex-0.1.61.dist-info/WHEEL,sha256=LA67brojLOZ0i0Pcaw_z7b5IlOGp1xIEPobtgkZ23mU,108
3
+ cocoindex-0.1.61.dist-info/entry_points.txt,sha256=_NretjYVzBdNTn7dK-zgwr7YfG2afz1u1uSE-5bZXF8,46
4
+ cocoindex-0.1.61.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
5
+ cocoindex/__init__.py,sha256=hDjehCjxRabFCW0RTt00JxnSAJIn9HeVoK4OjFbETsk,1910
6
+ cocoindex/_engine.cpython-313-x86_64-linux-gnu.so,sha256=2VQkq8Jv5aI9bGayVUVXWTNgNhVq_rFrFMDgysoP0iI,63213888
7
7
  cocoindex/auth_registry.py,sha256=1XqO7ibjmBBd8i11XSJTvTgdz8p1ptW-ZpuSgo_5zzk,716
8
8
  cocoindex/cli.py,sha256=8bDL-Qmd9NYtn1DsDfvUMk45xfAqNf9YTyM7H9KRuNU,21345
9
9
  cocoindex/convert.py,sha256=FsKb2Pfbm7e1VQDOs_AsoiW9PbIUuyHQuqUlrENXmUY,11199
10
- cocoindex/flow.py,sha256=UQviW2O6nzCKt3jf7N1xAXULvK7YRCZDAj5hy5VLkjM,33041
10
+ cocoindex/flow.py,sha256=x13SDZvFZ-MR-gGF1HPp14DMSn0vp37cfz0YFK9Pmy8,33334
11
11
  cocoindex/functions.py,sha256=IBwvdPpGR-S5mk53HvHpT2GVs15MI9wQznxgOdxA0ac,3202
12
12
  cocoindex/index.py,sha256=j93B9jEvvLXHtpzKWL88SY6wCGEoPgpsQhEGHlyYGFg,540
13
- cocoindex/lib.py,sha256=BeRUn3RqE_wSsVtsgCzbFFKe1LXgRyRmMOcmwWBuEXo,2940
13
+ cocoindex/lib.py,sha256=f--9dAYd84CZosbDZqNW0oGbBLsY3dXiUTR1VrfQ_QY,817
14
14
  cocoindex/llm.py,sha256=0ri8ZRg9_Zf2gyC5xuQ1Kq6kdZUO8r-A5WLnxit5S_4,448
15
15
  cocoindex/op.py,sha256=r_Usx7Jqh49Cck3tsYLx2vLRNUZArkQP_g7bIID6LPU,11809
16
16
  cocoindex/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -20,9 +20,9 @@ cocoindex/setup.py,sha256=7uIHKN4FOCuoidPXcKyGTrkqpkl9luL49-6UcnMxYzw,3068
20
20
  cocoindex/sources.py,sha256=JCnOhv1w4o28e03i7yvo4ESicWYAhckkBg5bQlxNH4U,1330
21
21
  cocoindex/targets.py,sha256=Nfh_tpFd1goTnS_cxBjIs4j9zl3Z4Z1JomAQ1dl3Sic,2796
22
22
  cocoindex/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
23
- cocoindex/tests/test_convert.py,sha256=fY3p1gRHZpuWUgk5v28UGPYzyaMI4Qakv4I4qHSNGu8,36528
23
+ cocoindex/tests/test_convert.py,sha256=WmgbaQTYPDnjBfMlIrZWBHipPW7SlrvHYsLLqb--KH0,38025
24
24
  cocoindex/tests/test_optional_database.py,sha256=snAmkNa6wtOSaxoZE1HgjvL5v_ylitt3Jt_9df4Cgdc,8506
25
25
  cocoindex/tests/test_typing.py,sha256=t6UCYShcfonTfjBlGRWPiFGMZ8DGFfABXo6idekPoJE,14757
26
- cocoindex/typing.py,sha256=kPMFVKs2i4SCLzW1Tn5NP_Ev9DAc-2qW6eJ68gpLexU,12580
26
+ cocoindex/typing.py,sha256=s_Hk4Npi8pxJUM2h_7Km0VFrojA8wJU9VDtRqVSL6C0,12622
27
27
  cocoindex/utils.py,sha256=hUhX-XV6XGCtJSEIpBOuDv6VvqImwPlgBxztBTw7u0U,598
28
- cocoindex-0.1.59.dist-info/RECORD,,
28
+ cocoindex-0.1.61.dist-info/RECORD,,