graphai-lib 0.0.9rc1__py3-none-any.whl → 0.0.9rc2__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.
- graphai/graph.py +3 -15
- {graphai_lib-0.0.9rc1.dist-info → graphai_lib-0.0.9rc2.dist-info}/METADATA +1 -1
- {graphai_lib-0.0.9rc1.dist-info → graphai_lib-0.0.9rc2.dist-info}/RECORD +5 -5
- {graphai_lib-0.0.9rc1.dist-info → graphai_lib-0.0.9rc2.dist-info}/WHEEL +0 -0
- {graphai_lib-0.0.9rc1.dist-info → graphai_lib-0.0.9rc2.dist-info}/top_level.txt +0 -0
graphai/graph.py
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
from __future__ import annotations
|
2
|
-
from typing import Any, Protocol
|
3
|
-
from graphlib import TopologicalSorter, CycleError
|
2
|
+
from typing import Any, Protocol
|
4
3
|
from graphai.callback import Callback
|
5
4
|
from graphai.utils import logger
|
6
5
|
|
@@ -63,7 +62,7 @@ class Graph:
|
|
63
62
|
self.edges: list[Any] = []
|
64
63
|
self.start_node: NodeProtocol | None = None
|
65
64
|
self.end_nodes: list[NodeProtocol] = []
|
66
|
-
self.Callback:
|
65
|
+
self.Callback: type[Callback] = Callback
|
67
66
|
self.max_steps = max_steps
|
68
67
|
self.state = initial_state or {}
|
69
68
|
|
@@ -288,17 +287,6 @@ class Graph:
|
|
288
287
|
"(src, Iterable[dst]), mapping{'source'/'destination'}, or objects with .source/.destination"
|
289
288
|
)
|
290
289
|
|
291
|
-
# cycle detection
|
292
|
-
preds: dict[str, set[str]] = {n: set() for n in nodes.keys()}
|
293
|
-
for s, ds in adj.items():
|
294
|
-
for d in ds:
|
295
|
-
preds[d].add(s)
|
296
|
-
|
297
|
-
try:
|
298
|
-
list(TopologicalSorter(preds).static_order())
|
299
|
-
except CycleError as e:
|
300
|
-
raise GraphCompileError("Cycle detected in graph") from e
|
301
|
-
|
302
290
|
# reachability from start
|
303
291
|
seen: set[str] = set()
|
304
292
|
stack = [start_name]
|
@@ -388,7 +376,7 @@ class Graph:
|
|
388
376
|
as the default callback when no callback is passed to the `execute` method.
|
389
377
|
|
390
378
|
:param callback_class: The callback class to use as the default callback.
|
391
|
-
:type callback_class:
|
379
|
+
:type callback_class: type[Callback]
|
392
380
|
"""
|
393
381
|
self.Callback = callback_class
|
394
382
|
return self
|
@@ -1,11 +1,11 @@
|
|
1
1
|
graphai/__init__.py,sha256=UbqXq7iGIYe1GyTPcpgLSXbgWovggFsAbTMtr4JQm3M,160
|
2
2
|
graphai/callback.py,sha256=Wl0JCmE8NcFifKmP9-a5bFa0WKVHTdrSClHVRmIEPpc,7323
|
3
|
-
graphai/graph.py,sha256=
|
3
|
+
graphai/graph.py,sha256=O0hZ_29ln8oTYnk5EX5bdhO6-Cr9pm-6IVCq-ZPWbgY,18526
|
4
4
|
graphai/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
5
5
|
graphai/utils.py,sha256=LIFg-fQalU9sB5DCuk6is48OdpEgNX95i9h-YddFbvM,11717
|
6
6
|
graphai/nodes/__init__.py,sha256=IaMUryAqTZlcEqh-ZS6A4NIYG18JZwzo145dzxsYjAk,74
|
7
7
|
graphai/nodes/base.py,sha256=SoKfOdRu5EIJ_z8xIz5zbNXcxPI2l9MKTQDeaQI-2no,7494
|
8
|
-
graphai_lib-0.0.
|
9
|
-
graphai_lib-0.0.
|
10
|
-
graphai_lib-0.0.
|
11
|
-
graphai_lib-0.0.
|
8
|
+
graphai_lib-0.0.9rc2.dist-info/METADATA,sha256=_3lwoAyLzSSgFq8GQHW_FAGd6A0kKiGQB3XWCnirJRs,913
|
9
|
+
graphai_lib-0.0.9rc2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
10
|
+
graphai_lib-0.0.9rc2.dist-info/top_level.txt,sha256=TXlqmhLViX-3xGH2g5w6cavRd-QMf229Hl88jdMOGt8,8
|
11
|
+
graphai_lib-0.0.9rc2.dist-info/RECORD,,
|
File without changes
|
File without changes
|