cocoindex 0.1.27__cp313-cp313-macosx_11_0_arm64.whl → 0.1.29__cp313-cp313-macosx_11_0_arm64.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-313-darwin.so +0 -0
- cocoindex/cli.py +7 -3
- cocoindex/flow.py +54 -1
- cocoindex/storages.py +15 -8
- {cocoindex-0.1.27.dist-info → cocoindex-0.1.29.dist-info}/METADATA +2 -1
- {cocoindex-0.1.27.dist-info → cocoindex-0.1.29.dist-info}/RECORD +8 -8
- {cocoindex-0.1.27.dist-info → cocoindex-0.1.29.dist-info}/WHEEL +0 -0
- {cocoindex-0.1.27.dist-info → cocoindex-0.1.29.dist-info}/licenses/LICENSE +0 -0
Binary file
|
cocoindex/cli.py
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
import asyncio
|
2
2
|
import click
|
3
3
|
import datetime
|
4
|
+
from rich.console import Console
|
4
5
|
|
5
6
|
from . import flow, lib
|
6
7
|
from .setup import sync_setup, drop_setup, flow_names_with_setup, apply_setup_changes
|
@@ -52,11 +53,14 @@ def ls(show_all: bool):
|
|
52
53
|
|
53
54
|
@cli.command()
|
54
55
|
@click.argument("flow_name", type=str, required=False)
|
55
|
-
|
56
|
+
@click.option("--color/--no-color", default=True)
|
57
|
+
def show(flow_name: str | None, color: bool):
|
56
58
|
"""
|
57
|
-
Show the flow spec.
|
59
|
+
Show the flow spec in a readable format with colored output.
|
58
60
|
"""
|
59
|
-
|
61
|
+
flow = _flow_by_name(flow_name)
|
62
|
+
console = Console(no_color=not color)
|
63
|
+
console.print(flow._render_text())
|
60
64
|
|
61
65
|
@cli.command()
|
62
66
|
def setup():
|
cocoindex/flow.py
CHANGED
@@ -8,11 +8,14 @@ import asyncio
|
|
8
8
|
import re
|
9
9
|
import inspect
|
10
10
|
import datetime
|
11
|
+
import json
|
11
12
|
|
12
13
|
from typing import Any, Callable, Sequence, TypeVar
|
13
14
|
from threading import Lock
|
14
15
|
from enum import Enum
|
15
16
|
from dataclasses import dataclass
|
17
|
+
from rich.text import Text
|
18
|
+
from rich.console import Console
|
16
19
|
|
17
20
|
from . import _engine
|
18
21
|
from . import index
|
@@ -451,8 +454,58 @@ class Flow:
|
|
451
454
|
return engine_flow
|
452
455
|
self._lazy_engine_flow = _lazy_engine_flow
|
453
456
|
|
457
|
+
def _format_flow(self, flow_dict: dict) -> Text:
|
458
|
+
output = Text()
|
459
|
+
|
460
|
+
def add_line(content, indent=0, style=None, end="\n"):
|
461
|
+
output.append(" " * indent)
|
462
|
+
output.append(content, style=style)
|
463
|
+
output.append(end)
|
464
|
+
|
465
|
+
def format_key_value(key, value, indent):
|
466
|
+
if isinstance(value, (dict, list)):
|
467
|
+
add_line(f"- {key}:", indent, style="green")
|
468
|
+
format_data(value, indent + 2)
|
469
|
+
else:
|
470
|
+
add_line(f"- {key}:", indent, style="green", end="")
|
471
|
+
add_line(f" {value}", style="yellow")
|
472
|
+
|
473
|
+
def format_data(data, indent=0):
|
474
|
+
if isinstance(data, dict):
|
475
|
+
for key, value in data.items():
|
476
|
+
format_key_value(key, value, indent)
|
477
|
+
elif isinstance(data, list):
|
478
|
+
for i, item in enumerate(data):
|
479
|
+
format_key_value(f"[{i}]", item, indent)
|
480
|
+
else:
|
481
|
+
add_line(str(data), indent, style="yellow")
|
482
|
+
|
483
|
+
# Header
|
484
|
+
flow_name = flow_dict.get("name", "Unnamed")
|
485
|
+
add_line(f"Flow: {flow_name}", style="bold cyan")
|
486
|
+
|
487
|
+
# Section
|
488
|
+
for section_title, section_key in [
|
489
|
+
("Sources:", "import_ops"),
|
490
|
+
("Processing:", "reactive_ops"),
|
491
|
+
("Targets:", "export_ops"),
|
492
|
+
]:
|
493
|
+
add_line("")
|
494
|
+
add_line(section_title, style="bold cyan")
|
495
|
+
format_data(flow_dict.get(section_key, []), indent=0)
|
496
|
+
|
497
|
+
return output
|
498
|
+
|
499
|
+
def _render_text(self) -> Text:
|
500
|
+
flow_spec_str = str(self._lazy_engine_flow())
|
501
|
+
try:
|
502
|
+
flow_dict = json.loads(flow_spec_str)
|
503
|
+
return self._format_flow(flow_dict)
|
504
|
+
except json.JSONDecodeError:
|
505
|
+
return Text(flow_spec_str)
|
506
|
+
|
454
507
|
def __str__(self):
|
455
|
-
return str(self.
|
508
|
+
return str(self._render_text())
|
456
509
|
|
457
510
|
def __repr__(self):
|
458
511
|
return repr(self._lazy_engine_flow())
|
cocoindex/storages.py
CHANGED
@@ -37,7 +37,7 @@ class TargetFieldMapping:
|
|
37
37
|
target: str | None = None
|
38
38
|
|
39
39
|
@dataclass
|
40
|
-
class
|
40
|
+
class NodeFromFields:
|
41
41
|
"""Spec for a referenced graph node, usually as part of a relationship."""
|
42
42
|
label: str
|
43
43
|
fields: list[TargetFieldMapping]
|
@@ -50,30 +50,37 @@ class ReferencedNode:
|
|
50
50
|
vector_indexes: Sequence[index.VectorIndexDef] = ()
|
51
51
|
|
52
52
|
@dataclass
|
53
|
-
class
|
53
|
+
class Nodes:
|
54
54
|
"""Spec to map a row to a graph node."""
|
55
55
|
kind = "Node"
|
56
56
|
|
57
57
|
label: str
|
58
58
|
|
59
59
|
@dataclass
|
60
|
-
class
|
60
|
+
class Relationships:
|
61
61
|
"""Spec to map a row to a graph relationship."""
|
62
62
|
kind = "Relationship"
|
63
63
|
|
64
64
|
rel_type: str
|
65
|
-
source:
|
66
|
-
target:
|
65
|
+
source: NodeFromFields
|
66
|
+
target: NodeFromFields
|
67
|
+
|
68
|
+
# For backwards compatibility only
|
69
|
+
NodeMapping = Nodes
|
70
|
+
RelationshipMapping = Relationships
|
71
|
+
NodeReferenceMapping = NodeFromFields
|
67
72
|
|
68
73
|
class Neo4j(op.StorageSpec):
|
69
74
|
"""Graph storage powered by Neo4j."""
|
70
75
|
|
71
76
|
connection: AuthEntryReference
|
72
|
-
mapping:
|
77
|
+
mapping: Nodes | Relationships
|
73
78
|
|
74
|
-
class
|
79
|
+
class Neo4jDeclaration(op.DeclarationSpec):
|
75
80
|
"""Declarations for Neo4j."""
|
76
81
|
|
77
82
|
kind = "Neo4j"
|
78
83
|
connection: AuthEntryReference
|
79
|
-
|
84
|
+
nodes_label: str
|
85
|
+
primary_key_fields: Sequence[str]
|
86
|
+
vector_indexes: Sequence[index.VectorIndexDef] = ()
|
@@ -1,8 +1,9 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: cocoindex
|
3
|
-
Version: 0.1.
|
3
|
+
Version: 0.1.29
|
4
4
|
Requires-Dist: sentence-transformers>=3.3.1
|
5
5
|
Requires-Dist: click>=8.1.8
|
6
|
+
Requires-Dist: rich>=14.0.0
|
6
7
|
Requires-Dist: pytest ; extra == 'test'
|
7
8
|
Provides-Extra: test
|
8
9
|
License-File: LICENSE
|
@@ -1,6 +1,6 @@
|
|
1
|
-
cocoindex-0.1.
|
2
|
-
cocoindex-0.1.
|
3
|
-
cocoindex-0.1.
|
1
|
+
cocoindex-0.1.29.dist-info/METADATA,sha256=EaJe6Rk9ypW5dZ8kqAFrId-sl_hKfbBi0cSyyHyVqa0,8107
|
2
|
+
cocoindex-0.1.29.dist-info/WHEEL,sha256=_czbP61TsBkf9T201RekHMHlqESnWn7yJwXBJC9P-w0,104
|
3
|
+
cocoindex-0.1.29.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
4
4
|
cocoindex/functions.py,sha256=clnpHCYSsjUnc8Spbc1-5sQedG-60fmibodv9LpHgqo,1647
|
5
5
|
cocoindex/query.py,sha256=8_3Lb_EVjZtl2ZyJNZGX16LoKXEd-PL8OjY-zs9GQeA,3205
|
6
6
|
cocoindex/index.py,sha256=LssEOuZi6AqhwKtZM3QFeQpa9T-0ELi8G5DsrYKECvc,534
|
@@ -10,15 +10,15 @@ cocoindex/convert.py,sha256=mBUTa_Ag39_ut-yE_jc1wqS3zLjtOm6QKet-bqJ-RWc,5947
|
|
10
10
|
cocoindex/tests/__init__.py,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
|
11
11
|
cocoindex/tests/test_convert.py,sha256=WPRKp0jv_uSEM81RGWEAmsax-J-FtXt90mZ0yEnvGLs,11236
|
12
12
|
cocoindex/__init__.py,sha256=8atBT1HjclUOeiXd7TSzZWaqOR4x_qr5epvCKB7Z7oY,661
|
13
|
-
cocoindex/flow.py,sha256=
|
13
|
+
cocoindex/flow.py,sha256=5W0tuDy_oc54lEmELvQAujx9f_20CSynZCF5vuNlbYw,22919
|
14
14
|
cocoindex/llm.py,sha256=_3rtahuKcqcEHPkFSwhXOSrekZyGxVApPoYtlU_chcA,348
|
15
15
|
cocoindex/runtime.py,sha256=jqRnWkkIlAhE04gi4y0Y5bzuq9FX4j0aVNU-nengLJk,980
|
16
16
|
cocoindex/op.py,sha256=ICCKZw6peCFu-CtMeIEaz6vlBxrf5dZwgUs9R4ALYNU,10604
|
17
17
|
cocoindex/sources.py,sha256=wZFU8lwSXjyofJR-syySH9fTyPnBlAPJ6-1hQNX8fGA,936
|
18
18
|
cocoindex/setup.py,sha256=W1HshwYk_K2aeLOVn_e62ZOXBO9yWsoUboRiH4SjF48,496
|
19
|
-
cocoindex/cli.py,sha256=
|
19
|
+
cocoindex/cli.py,sha256=PU5xeP9rWiRP-6_05aikFcRZ5Pmhn39DvIvl31Se23M,7269
|
20
20
|
cocoindex/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
21
21
|
cocoindex/typing.py,sha256=p3FEUnoQc6zmiG8YwO4T155sgZtyc_1AufiJe3bNol8,8458
|
22
|
-
cocoindex/storages.py,sha256=
|
23
|
-
cocoindex/_engine.cpython-313-darwin.so,sha256=
|
24
|
-
cocoindex-0.1.
|
22
|
+
cocoindex/storages.py,sha256=JjWDKF4R-_3XJq0t8ejlb9JlUsh2Iv4nKokl7PsAPmA,2107
|
23
|
+
cocoindex/_engine.cpython-313-darwin.so,sha256=AvCA3cfKCGMQYJ7WSI4PVNJg92QoBeZxfGNEDQMJjzs,59488992
|
24
|
+
cocoindex-0.1.29.dist-info/RECORD,,
|
File without changes
|
File without changes
|