cocoindex 0.1.57__cp312-cp312-manylinux_2_28_aarch64.whl → 0.1.58__cp312-cp312-manylinux_2_28_aarch64.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/_engine.cpython-312-aarch64-linux-gnu.so +0 -0
- cocoindex/flow.py +60 -27
- cocoindex/op.py +3 -4
- {cocoindex-0.1.57.dist-info → cocoindex-0.1.58.dist-info}/METADATA +1 -1
- {cocoindex-0.1.57.dist-info → cocoindex-0.1.58.dist-info}/RECORD +8 -8
- {cocoindex-0.1.57.dist-info → cocoindex-0.1.58.dist-info}/WHEEL +0 -0
- {cocoindex-0.1.57.dist-info → cocoindex-0.1.58.dist-info}/entry_points.txt +0 -0
- {cocoindex-0.1.57.dist-info → cocoindex-0.1.58.dist-info}/licenses/LICENSE +0 -0
Binary file
|
cocoindex/flow.py
CHANGED
@@ -5,25 +5,27 @@ Flow is the main interface for building and running flows.
|
|
5
5
|
from __future__ import annotations
|
6
6
|
|
7
7
|
import asyncio
|
8
|
-
import re
|
9
|
-
import inspect
|
10
8
|
import datetime
|
11
9
|
import functools
|
10
|
+
import inspect
|
11
|
+
import re
|
12
|
+
|
13
|
+
from dataclasses import dataclass
|
14
|
+
from enum import Enum
|
15
|
+
from threading import Lock
|
12
16
|
from typing import (
|
13
17
|
Any,
|
14
18
|
Callable,
|
19
|
+
Generic,
|
20
|
+
NamedTuple,
|
15
21
|
Sequence,
|
16
22
|
TypeVar,
|
17
|
-
|
23
|
+
cast,
|
18
24
|
get_args,
|
19
25
|
get_origin,
|
20
|
-
NamedTuple,
|
21
|
-
cast,
|
22
26
|
Iterable,
|
23
27
|
)
|
24
|
-
|
25
|
-
from enum import Enum
|
26
|
-
from dataclasses import dataclass
|
28
|
+
|
27
29
|
from rich.text import Text
|
28
30
|
from rich.tree import Tree
|
29
31
|
|
@@ -32,9 +34,10 @@ from . import index
|
|
32
34
|
from . import op
|
33
35
|
from . import setting
|
34
36
|
from .convert import dump_engine_object, encode_engine_value, make_engine_value_decoder
|
35
|
-
from .
|
37
|
+
from .op import FunctionSpec
|
36
38
|
from .runtime import execution_context
|
37
39
|
from .setup import SetupChangeBundle
|
40
|
+
from .typing import encode_enriched_type
|
38
41
|
|
39
42
|
|
40
43
|
class _NameBuilder:
|
@@ -92,6 +95,30 @@ def _spec_kind(spec: Any) -> str:
|
|
92
95
|
return cast(str, spec.__class__.__name__)
|
93
96
|
|
94
97
|
|
98
|
+
def _transform_helper(
|
99
|
+
flow_builder_state: _FlowBuilderState,
|
100
|
+
fn_spec: FunctionSpec,
|
101
|
+
transform_args: list[tuple[Any, str | None]],
|
102
|
+
name: str | None = None,
|
103
|
+
) -> DataSlice[Any]:
|
104
|
+
if not isinstance(fn_spec, FunctionSpec):
|
105
|
+
raise ValueError("transform() can only be called on a CocoIndex function")
|
106
|
+
|
107
|
+
return _create_data_slice(
|
108
|
+
flow_builder_state,
|
109
|
+
lambda target_scope, name: flow_builder_state.engine_flow_builder.transform(
|
110
|
+
_spec_kind(fn_spec),
|
111
|
+
dump_engine_object(fn_spec),
|
112
|
+
transform_args,
|
113
|
+
target_scope,
|
114
|
+
flow_builder_state.field_name_builder.build_name(
|
115
|
+
name, prefix=_to_snake_case(_spec_kind(fn_spec)) + "_"
|
116
|
+
),
|
117
|
+
),
|
118
|
+
name,
|
119
|
+
)
|
120
|
+
|
121
|
+
|
95
122
|
T = TypeVar("T")
|
96
123
|
S = TypeVar("S")
|
97
124
|
|
@@ -191,31 +218,19 @@ class DataSlice(Generic[T]):
|
|
191
218
|
"""
|
192
219
|
Apply a function to the data slice.
|
193
220
|
"""
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
transform_args: list[tuple[Any, str | None]]
|
198
|
-
transform_args = [(self._state.engine_data_slice, None)]
|
221
|
+
transform_args: list[tuple[Any, str | None]] = [
|
222
|
+
(self._state.engine_data_slice, None)
|
223
|
+
]
|
199
224
|
transform_args += [
|
200
225
|
(self._state.flow_builder_state.get_data_slice(v), None) for v in args
|
201
226
|
]
|
202
227
|
transform_args += [
|
203
228
|
(self._state.flow_builder_state.get_data_slice(v), k)
|
204
|
-
for
|
229
|
+
for k, v in kwargs.items()
|
205
230
|
]
|
206
231
|
|
207
|
-
|
208
|
-
|
209
|
-
flow_builder_state,
|
210
|
-
lambda target_scope, name: flow_builder_state.engine_flow_builder.transform(
|
211
|
-
_spec_kind(fn_spec),
|
212
|
-
dump_engine_object(fn_spec),
|
213
|
-
transform_args,
|
214
|
-
target_scope,
|
215
|
-
flow_builder_state.field_name_builder.build_name(
|
216
|
-
name, prefix=_to_snake_case(_spec_kind(fn_spec)) + "_"
|
217
|
-
),
|
218
|
-
),
|
232
|
+
return _transform_helper(
|
233
|
+
self._state.flow_builder_state, fn_spec, transform_args
|
219
234
|
)
|
220
235
|
|
221
236
|
def call(self, func: Callable[..., S], *args: Any, **kwargs: Any) -> S:
|
@@ -446,6 +461,24 @@ class FlowBuilder:
|
|
446
461
|
name,
|
447
462
|
)
|
448
463
|
|
464
|
+
def transform(
|
465
|
+
self, fn_spec: FunctionSpec, *args: Any, **kwargs: Any
|
466
|
+
) -> DataSlice[Any]:
|
467
|
+
"""
|
468
|
+
Apply a function to inputs, returning a DataSlice.
|
469
|
+
"""
|
470
|
+
transform_args: list[tuple[Any, str | None]] = [
|
471
|
+
(self._state.get_data_slice(v), None) for v in args
|
472
|
+
]
|
473
|
+
transform_args += [
|
474
|
+
(self._state.get_data_slice(v), k) for k, v in kwargs.items()
|
475
|
+
]
|
476
|
+
|
477
|
+
if not transform_args:
|
478
|
+
raise ValueError("At least one input is required for transformation")
|
479
|
+
|
480
|
+
return _transform_helper(self._state, fn_spec, transform_args)
|
481
|
+
|
449
482
|
def declare(self, spec: op.DeclarationSpec) -> None:
|
450
483
|
"""
|
451
484
|
Add a declaration to the flow.
|
cocoindex/op.py
CHANGED
@@ -5,13 +5,12 @@ Facilities for defining cocoindex operations.
|
|
5
5
|
import asyncio
|
6
6
|
import dataclasses
|
7
7
|
import inspect
|
8
|
-
|
9
|
-
from typing import Protocol, Any, Callable, Awaitable, dataclass_transform
|
10
8
|
from enum import Enum
|
9
|
+
from typing import Any, Awaitable, Callable, Protocol, dataclass_transform
|
11
10
|
|
12
|
-
from .typing import encode_enriched_type, resolve_forward_ref
|
13
|
-
from .convert import encode_engine_value, make_engine_value_decoder
|
14
11
|
from . import _engine # type: ignore
|
12
|
+
from .convert import encode_engine_value, make_engine_value_decoder
|
13
|
+
from .typing import encode_enriched_type, resolve_forward_ref
|
15
14
|
|
16
15
|
|
17
16
|
class OpCategory(Enum):
|
@@ -1,18 +1,18 @@
|
|
1
|
-
cocoindex-0.1.
|
2
|
-
cocoindex-0.1.
|
3
|
-
cocoindex-0.1.
|
4
|
-
cocoindex-0.1.
|
1
|
+
cocoindex-0.1.58.dist-info/METADATA,sha256=0JbA9gaANI6bomrbj-zoE5B4lW19k8wco3EC0mmdL5A,10020
|
2
|
+
cocoindex-0.1.58.dist-info/WHEEL,sha256=z3VfMsM-qJy5JImiySGStVHlIvHbw0zZeZYNDsh-ynA,109
|
3
|
+
cocoindex-0.1.58.dist-info/entry_points.txt,sha256=_NretjYVzBdNTn7dK-zgwr7YfG2afz1u1uSE-5bZXF8,46
|
4
|
+
cocoindex-0.1.58.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
5
5
|
cocoindex/__init__.py,sha256=MFm-QJzrr0ODJCsAAsPUzJXh8KH1WdZod8F60B1iUYw,1877
|
6
|
-
cocoindex/_engine.cpython-312-aarch64-linux-gnu.so,sha256=
|
6
|
+
cocoindex/_engine.cpython-312-aarch64-linux-gnu.so,sha256=ilSeNlu0E9Btdtq3Vjy1vlg43og8wsLZ0cYeG6fWg04,60986952
|
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=XeSr0ykudBrB-RWRmcbdbt3WCihlLDSBIYUcDtPbTdA,10228
|
10
|
-
cocoindex/flow.py,sha256=
|
10
|
+
cocoindex/flow.py,sha256=UQviW2O6nzCKt3jf7N1xAXULvK7YRCZDAj5hy5VLkjM,33041
|
11
11
|
cocoindex/functions.py,sha256=IBwvdPpGR-S5mk53HvHpT2GVs15MI9wQznxgOdxA0ac,3202
|
12
12
|
cocoindex/index.py,sha256=j93B9jEvvLXHtpzKWL88SY6wCGEoPgpsQhEGHlyYGFg,540
|
13
13
|
cocoindex/lib.py,sha256=BeRUn3RqE_wSsVtsgCzbFFKe1LXgRyRmMOcmwWBuEXo,2940
|
14
14
|
cocoindex/llm.py,sha256=hpwvHjWiLkoV018TkC191rztq62NQeewwF3kDsHUols,430
|
15
|
-
cocoindex/op.py,sha256=
|
15
|
+
cocoindex/op.py,sha256=r_Usx7Jqh49Cck3tsYLx2vLRNUZArkQP_g7bIID6LPU,11809
|
16
16
|
cocoindex/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
17
17
|
cocoindex/runtime.py,sha256=bAdHYaXFWiiUWyAgzmKTeaAaRR0D_AmaqVCIdPO-v00,1056
|
18
18
|
cocoindex/setting.py,sha256=Zl8K86r8RVvG9c3pCsH0Ot8BHhDAQAQCjoBp7TnXMLQ,3590
|
@@ -25,4 +25,4 @@ cocoindex/tests/test_optional_database.py,sha256=snAmkNa6wtOSaxoZE1HgjvL5v_ylitt
|
|
25
25
|
cocoindex/tests/test_typing.py,sha256=t6UCYShcfonTfjBlGRWPiFGMZ8DGFfABXo6idekPoJE,14757
|
26
26
|
cocoindex/typing.py,sha256=kPMFVKs2i4SCLzW1Tn5NP_Ev9DAc-2qW6eJ68gpLexU,12580
|
27
27
|
cocoindex/utils.py,sha256=hUhX-XV6XGCtJSEIpBOuDv6VvqImwPlgBxztBTw7u0U,598
|
28
|
-
cocoindex-0.1.
|
28
|
+
cocoindex-0.1.58.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|