cocoindex 0.2.3__cp311-abi3-macosx_10_12_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 +92 -0
- cocoindex/_engine.abi3.so +0 -0
- cocoindex/auth_registry.py +51 -0
- cocoindex/cli.py +697 -0
- cocoindex/convert.py +621 -0
- cocoindex/flow.py +1205 -0
- cocoindex/functions.py +357 -0
- cocoindex/index.py +29 -0
- cocoindex/lib.py +32 -0
- cocoindex/llm.py +46 -0
- cocoindex/op.py +628 -0
- cocoindex/py.typed +0 -0
- cocoindex/runtime.py +37 -0
- cocoindex/setting.py +181 -0
- cocoindex/setup.py +92 -0
- cocoindex/sources.py +102 -0
- cocoindex/subprocess_exec.py +279 -0
- cocoindex/targets.py +135 -0
- cocoindex/tests/__init__.py +0 -0
- cocoindex/tests/conftest.py +38 -0
- cocoindex/tests/test_convert.py +1543 -0
- cocoindex/tests/test_optional_database.py +249 -0
- cocoindex/tests/test_transform_flow.py +207 -0
- cocoindex/tests/test_typing.py +429 -0
- cocoindex/tests/test_validation.py +134 -0
- cocoindex/typing.py +473 -0
- cocoindex/user_app_loader.py +51 -0
- cocoindex/utils.py +20 -0
- cocoindex/validation.py +104 -0
- cocoindex-0.2.3.dist-info/METADATA +262 -0
- cocoindex-0.2.3.dist-info/RECORD +34 -0
- cocoindex-0.2.3.dist-info/WHEEL +4 -0
- cocoindex-0.2.3.dist-info/entry_points.txt +2 -0
- cocoindex-0.2.3.dist-info/licenses/LICENSE +201 -0
cocoindex/targets.py
ADDED
@@ -0,0 +1,135 @@
|
|
1
|
+
"""All builtin targets."""
|
2
|
+
|
3
|
+
from dataclasses import dataclass
|
4
|
+
from typing import Sequence
|
5
|
+
|
6
|
+
from . import op
|
7
|
+
from . import index
|
8
|
+
from .auth_registry import AuthEntryReference
|
9
|
+
from .setting import DatabaseConnectionSpec
|
10
|
+
|
11
|
+
|
12
|
+
class Postgres(op.TargetSpec):
|
13
|
+
"""Target powered by Postgres and pgvector."""
|
14
|
+
|
15
|
+
database: AuthEntryReference[DatabaseConnectionSpec] | None = None
|
16
|
+
table_name: str | None = None
|
17
|
+
|
18
|
+
|
19
|
+
@dataclass
|
20
|
+
class QdrantConnection:
|
21
|
+
"""Connection spec for Qdrant."""
|
22
|
+
|
23
|
+
grpc_url: str
|
24
|
+
api_key: str | None = None
|
25
|
+
|
26
|
+
|
27
|
+
@dataclass
|
28
|
+
class Qdrant(op.TargetSpec):
|
29
|
+
"""Target powered by Qdrant - https://qdrant.tech/."""
|
30
|
+
|
31
|
+
collection_name: str
|
32
|
+
connection: AuthEntryReference[QdrantConnection] | None = None
|
33
|
+
|
34
|
+
|
35
|
+
@dataclass
|
36
|
+
class TargetFieldMapping:
|
37
|
+
"""Mapping for a graph element (node or relationship) field."""
|
38
|
+
|
39
|
+
source: str
|
40
|
+
# Field name for the node in the Knowledge Graph.
|
41
|
+
# If unspecified, it's the same as `field_name`.
|
42
|
+
target: str | None = None
|
43
|
+
|
44
|
+
|
45
|
+
@dataclass
|
46
|
+
class NodeFromFields:
|
47
|
+
"""Spec for a referenced graph node, usually as part of a relationship."""
|
48
|
+
|
49
|
+
label: str
|
50
|
+
fields: list[TargetFieldMapping]
|
51
|
+
|
52
|
+
|
53
|
+
@dataclass
|
54
|
+
class ReferencedNode:
|
55
|
+
"""Target spec for a graph node."""
|
56
|
+
|
57
|
+
label: str
|
58
|
+
primary_key_fields: Sequence[str]
|
59
|
+
vector_indexes: Sequence[index.VectorIndexDef] = ()
|
60
|
+
|
61
|
+
|
62
|
+
@dataclass
|
63
|
+
class Nodes:
|
64
|
+
"""Spec to map a row to a graph node."""
|
65
|
+
|
66
|
+
kind = "Node"
|
67
|
+
|
68
|
+
label: str
|
69
|
+
|
70
|
+
|
71
|
+
@dataclass
|
72
|
+
class Relationships:
|
73
|
+
"""Spec to map a row to a graph relationship."""
|
74
|
+
|
75
|
+
kind = "Relationship"
|
76
|
+
|
77
|
+
rel_type: str
|
78
|
+
source: NodeFromFields
|
79
|
+
target: NodeFromFields
|
80
|
+
|
81
|
+
|
82
|
+
# For backwards compatibility only
|
83
|
+
NodeMapping = Nodes
|
84
|
+
RelationshipMapping = Relationships
|
85
|
+
NodeReferenceMapping = NodeFromFields
|
86
|
+
|
87
|
+
|
88
|
+
@dataclass
|
89
|
+
class Neo4jConnection:
|
90
|
+
"""Connection spec for Neo4j."""
|
91
|
+
|
92
|
+
uri: str
|
93
|
+
user: str
|
94
|
+
password: str
|
95
|
+
db: str | None = None
|
96
|
+
|
97
|
+
|
98
|
+
class Neo4j(op.TargetSpec):
|
99
|
+
"""Graph storage powered by Neo4j."""
|
100
|
+
|
101
|
+
connection: AuthEntryReference[Neo4jConnection]
|
102
|
+
mapping: Nodes | Relationships
|
103
|
+
|
104
|
+
|
105
|
+
class Neo4jDeclaration(op.DeclarationSpec):
|
106
|
+
"""Declarations for Neo4j."""
|
107
|
+
|
108
|
+
kind = "Neo4j"
|
109
|
+
connection: AuthEntryReference[Neo4jConnection]
|
110
|
+
nodes_label: str
|
111
|
+
primary_key_fields: Sequence[str]
|
112
|
+
vector_indexes: Sequence[index.VectorIndexDef] = ()
|
113
|
+
|
114
|
+
|
115
|
+
@dataclass
|
116
|
+
class KuzuConnection:
|
117
|
+
"""Connection spec for Kuzu."""
|
118
|
+
|
119
|
+
api_server_url: str
|
120
|
+
|
121
|
+
|
122
|
+
class Kuzu(op.TargetSpec):
|
123
|
+
"""Graph storage powered by Kuzu."""
|
124
|
+
|
125
|
+
connection: AuthEntryReference[KuzuConnection]
|
126
|
+
mapping: Nodes | Relationships
|
127
|
+
|
128
|
+
|
129
|
+
class KuzuDeclaration(op.DeclarationSpec):
|
130
|
+
"""Declarations for Kuzu."""
|
131
|
+
|
132
|
+
kind = "Kuzu"
|
133
|
+
connection: AuthEntryReference[KuzuConnection]
|
134
|
+
nodes_label: str
|
135
|
+
primary_key_fields: Sequence[str]
|
File without changes
|
@@ -0,0 +1,38 @@
|
|
1
|
+
import pytest
|
2
|
+
import typing
|
3
|
+
import os
|
4
|
+
import signal
|
5
|
+
import sys
|
6
|
+
|
7
|
+
|
8
|
+
@pytest.fixture(scope="session", autouse=True)
|
9
|
+
def _cocoindex_windows_env_fixture(
|
10
|
+
request: pytest.FixtureRequest,
|
11
|
+
) -> typing.Generator[None, None, None]:
|
12
|
+
"""Shutdown the subprocess pool at exit on Windows."""
|
13
|
+
|
14
|
+
yield
|
15
|
+
|
16
|
+
if not sys.platform.startswith("win"):
|
17
|
+
return
|
18
|
+
|
19
|
+
try:
|
20
|
+
import cocoindex.subprocess_exec
|
21
|
+
|
22
|
+
original_sigint_handler = signal.getsignal(signal.SIGINT)
|
23
|
+
try:
|
24
|
+
signal.signal(signal.SIGINT, signal.SIG_IGN)
|
25
|
+
cocoindex.subprocess_exec.shutdown_pool_at_exit()
|
26
|
+
|
27
|
+
# If any test failed, let pytest exit normally with nonzero code
|
28
|
+
if request.session.testsfailed == 0:
|
29
|
+
os._exit(0) # immediate success exit (skips atexit/teardown)
|
30
|
+
|
31
|
+
finally:
|
32
|
+
try:
|
33
|
+
signal.signal(signal.SIGINT, original_sigint_handler)
|
34
|
+
except ValueError: # noqa: BLE001
|
35
|
+
pass
|
36
|
+
|
37
|
+
except (ImportError, AttributeError): # noqa: BLE001
|
38
|
+
pass
|