computation-graph 56__tar.gz → 57__tar.gz
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.
- {computation_graph-56 → computation_graph-57}/PKG-INFO +1 -1
- {computation_graph-56 → computation_graph-57}/computation_graph/run.py +38 -70
- {computation_graph-56 → computation_graph-57}/computation_graph.egg-info/PKG-INFO +1 -1
- {computation_graph-56 → computation_graph-57}/setup.py +1 -1
- {computation_graph-56 → computation_graph-57}/LICENSE.md +0 -0
- {computation_graph-56 → computation_graph-57}/README.md +0 -0
- {computation_graph-56 → computation_graph-57}/computation_graph/__init__.py +0 -0
- {computation_graph-56 → computation_graph-57}/computation_graph/base_types.py +0 -0
- {computation_graph-56 → computation_graph-57}/computation_graph/composers/__init__.py +0 -0
- {computation_graph-56 → computation_graph-57}/computation_graph/composers/composers_test.py +0 -0
- {computation_graph-56 → computation_graph-57}/computation_graph/composers/condition.py +0 -0
- {computation_graph-56 → computation_graph-57}/computation_graph/composers/condition_test.py +0 -0
- {computation_graph-56 → computation_graph-57}/computation_graph/composers/debug.py +0 -0
- {computation_graph-56 → computation_graph-57}/computation_graph/composers/duplication.py +0 -0
- {computation_graph-56 → computation_graph-57}/computation_graph/composers/lift.py +0 -0
- {computation_graph-56 → computation_graph-57}/computation_graph/composers/logic.py +0 -0
- {computation_graph-56 → computation_graph-57}/computation_graph/composers/memory.py +0 -0
- {computation_graph-56 → computation_graph-57}/computation_graph/composers/memory_test.py +0 -0
- {computation_graph-56 → computation_graph-57}/computation_graph/graph.py +0 -0
- {computation_graph-56 → computation_graph-57}/computation_graph/graph_runners.py +0 -0
- {computation_graph-56 → computation_graph-57}/computation_graph/graph_test.py +0 -0
- {computation_graph-56 → computation_graph-57}/computation_graph/legacy.py +0 -0
- {computation_graph-56 → computation_graph-57}/computation_graph/signature.py +0 -0
- {computation_graph-56 → computation_graph-57}/computation_graph/trace/__init__.py +0 -0
- {computation_graph-56 → computation_graph-57}/computation_graph/trace/ascii.py +0 -0
- {computation_graph-56 → computation_graph-57}/computation_graph/trace/graphviz.py +0 -0
- {computation_graph-56 → computation_graph-57}/computation_graph/trace/graphviz_test.py +0 -0
- {computation_graph-56 → computation_graph-57}/computation_graph/trace/mermaid.py +0 -0
- {computation_graph-56 → computation_graph-57}/computation_graph/trace/trace_utils.py +0 -0
- {computation_graph-56 → computation_graph-57}/computation_graph.egg-info/SOURCES.txt +0 -0
- {computation_graph-56 → computation_graph-57}/computation_graph.egg-info/dependency_links.txt +0 -0
- {computation_graph-56 → computation_graph-57}/computation_graph.egg-info/requires.txt +0 -0
- {computation_graph-56 → computation_graph-57}/computation_graph.egg-info/top_level.txt +0 -0
- {computation_graph-56 → computation_graph-57}/pyproject.toml +0 -0
- {computation_graph-56 → computation_graph-57}/setup.cfg +0 -0
|
@@ -29,7 +29,6 @@ import typeguard
|
|
|
29
29
|
from gamla.optimized import sync as opt_gamla
|
|
30
30
|
|
|
31
31
|
from computation_graph import base_types, composers, graph, signature
|
|
32
|
-
from computation_graph.composers import debug
|
|
33
32
|
|
|
34
33
|
CG_NO_RESULT = "CG_NO_RESULT"
|
|
35
34
|
|
|
@@ -44,6 +43,16 @@ _SingleNodeSideEffect = Callable[[base_types.ComputationNode, Any], None]
|
|
|
44
43
|
_ComputationInputSpec = Tuple[
|
|
45
44
|
Tuple[base_types.ComputationNode, ...], Dict[str, base_types.ComputationNode]
|
|
46
45
|
]
|
|
46
|
+
_NodeExecutor = Callable[
|
|
47
|
+
[
|
|
48
|
+
Mapping[
|
|
49
|
+
base_types.ComputationNode,
|
|
50
|
+
base_types.Result | Awaitable[base_types.Result],
|
|
51
|
+
],
|
|
52
|
+
base_types.ComputationNode,
|
|
53
|
+
],
|
|
54
|
+
base_types.Result,
|
|
55
|
+
]
|
|
47
56
|
|
|
48
57
|
|
|
49
58
|
def _transpose_graph(
|
|
@@ -62,7 +71,7 @@ _toposort_nodes: Callable[
|
|
|
62
71
|
opt_gamla.compose_left(opt_gamla.map(base_types.edge_destination), set)
|
|
63
72
|
),
|
|
64
73
|
_transpose_graph,
|
|
65
|
-
toposort.
|
|
74
|
+
lambda g: toposort.toposort_flatten(g, sort=False),
|
|
66
75
|
)
|
|
67
76
|
|
|
68
77
|
|
|
@@ -198,14 +207,8 @@ def _to_callable_with_side_effect_for_single_and_multiple(
|
|
|
198
207
|
topological_layers = opt_gamla.pipe(
|
|
199
208
|
edges,
|
|
200
209
|
_toposort_nodes,
|
|
201
|
-
gamla.
|
|
202
|
-
|
|
203
|
-
gamla.remove(gamla.contains(placeholder_to_future_source)),
|
|
204
|
-
opt_gamla.map(opt_gamla.pair_right(get_node_executor)),
|
|
205
|
-
frozenset,
|
|
206
|
-
)
|
|
207
|
-
),
|
|
208
|
-
tuple,
|
|
210
|
+
gamla.remove(gamla.contains(placeholder_to_future_source)),
|
|
211
|
+
opt_gamla.maptuple(opt_gamla.pair_right(get_node_executor)),
|
|
209
212
|
)
|
|
210
213
|
|
|
211
214
|
translate_source_to_placeholder = opt_gamla.compose_left(
|
|
@@ -214,18 +217,16 @@ def _to_callable_with_side_effect_for_single_and_multiple(
|
|
|
214
217
|
)
|
|
215
218
|
all_node_side_effects_on_edges = gamla.side_effect(all_nodes_side_effect(edges))
|
|
216
219
|
|
|
217
|
-
reduce_layers = _make_reduce_layers(handled_exceptions)
|
|
218
|
-
|
|
219
220
|
if is_async:
|
|
220
221
|
|
|
221
222
|
async def final_runner(sources_to_values):
|
|
222
223
|
d = gamla.pipe(
|
|
223
224
|
topological_layers,
|
|
224
|
-
|
|
225
|
-
|
|
225
|
+
_run_graph(
|
|
226
|
+
translate_source_to_placeholder(sources_to_values),
|
|
227
|
+
handled_exceptions,
|
|
226
228
|
),
|
|
227
229
|
dict,
|
|
228
|
-
gamla.side_effect(all_node_side_effects_on_edges),
|
|
229
230
|
)
|
|
230
231
|
results_by_is_async = _group_by_is_async_result(d.items())
|
|
231
232
|
async_results = tuple(zip(*results_by_is_async.get(True, ())))
|
|
@@ -253,8 +254,9 @@ def _to_callable_with_side_effect_for_single_and_multiple(
|
|
|
253
254
|
def final_runner(sources_to_values):
|
|
254
255
|
return gamla.pipe(
|
|
255
256
|
topological_layers,
|
|
256
|
-
|
|
257
|
-
|
|
257
|
+
_run_graph(
|
|
258
|
+
translate_source_to_placeholder(sources_to_values),
|
|
259
|
+
handled_exceptions,
|
|
258
260
|
),
|
|
259
261
|
dict,
|
|
260
262
|
all_node_side_effects_on_edges,
|
|
@@ -483,18 +485,7 @@ def _make_get_node_executor(
|
|
|
483
485
|
sync_and_downstream = sync & downstream_from_async
|
|
484
486
|
sync_not_downstream = sync - downstream_from_async
|
|
485
487
|
|
|
486
|
-
def get_executor(
|
|
487
|
-
node: base_types.ComputationNode,
|
|
488
|
-
) -> Callable[
|
|
489
|
-
[
|
|
490
|
-
Mapping[
|
|
491
|
-
base_types.ComputationNode,
|
|
492
|
-
base_types.Result | Awaitable[base_types.Result],
|
|
493
|
-
],
|
|
494
|
-
base_types.ComputationNode,
|
|
495
|
-
],
|
|
496
|
-
base_types.Result,
|
|
497
|
-
]:
|
|
488
|
+
def get_executor(node: base_types.ComputationNode) -> _NodeExecutor:
|
|
498
489
|
if node in async_and_downstream:
|
|
499
490
|
return await_deps_and_await
|
|
500
491
|
if node in async_not_downstream:
|
|
@@ -509,48 +500,25 @@ def _make_get_node_executor(
|
|
|
509
500
|
return get_executor
|
|
510
501
|
|
|
511
502
|
|
|
512
|
-
def
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
*handled_exceptions,
|
|
522
|
-
):
|
|
523
|
-
# We delete the references to the upstream tasks to avoid circular reference (task->exception->traceback->task) and improve memory performance
|
|
524
|
-
del accumulated_results
|
|
525
|
-
return None
|
|
526
|
-
|
|
527
|
-
single_layer_reducer = debug.name_callable(
|
|
528
|
-
gamla.compose_left(
|
|
529
|
-
gamla.pack,
|
|
530
|
-
gamla.juxt(
|
|
531
|
-
gamla.head,
|
|
532
|
-
gamla.compose_left(
|
|
533
|
-
gamla.explode(1),
|
|
534
|
-
opt_gamla.map(
|
|
535
|
-
lambda results__node_executor: apply_executor(
|
|
536
|
-
results__node_executor[0],
|
|
537
|
-
results__node_executor[1][0],
|
|
538
|
-
results__node_executor[1][1],
|
|
539
|
-
)
|
|
540
|
-
),
|
|
541
|
-
opt_gamla.filter(bool),
|
|
542
|
-
tuple,
|
|
543
|
-
),
|
|
544
|
-
),
|
|
545
|
-
opt_gamla.star(
|
|
546
|
-
lambda prev_results, current_results: prev_results.update(
|
|
547
|
-
current_results
|
|
503
|
+
def _run_graph(inputs: dict, handled_exceptions):
|
|
504
|
+
def run_graph(
|
|
505
|
+
nodes: tuple[tuple[base_types.ComputationNode, _NodeExecutor]]
|
|
506
|
+
) -> _NodeToResults:
|
|
507
|
+
accumulated_results = inputs.copy()
|
|
508
|
+
for node_executor in nodes:
|
|
509
|
+
try:
|
|
510
|
+
accumulated_results[node_executor[0]] = node_executor[1](
|
|
511
|
+
accumulated_results, node_executor[0]
|
|
548
512
|
)
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
513
|
+
except (
|
|
514
|
+
_DepNotFoundError,
|
|
515
|
+
base_types.SkipComputationError,
|
|
516
|
+
*handled_exceptions,
|
|
517
|
+
):
|
|
518
|
+
pass
|
|
519
|
+
return accumulated_results
|
|
520
|
+
|
|
521
|
+
return run_graph
|
|
554
522
|
|
|
555
523
|
|
|
556
524
|
def _graph_reducer(graph_callable):
|
|
@@ -7,7 +7,7 @@ with open("README.md", "r") as fh:
|
|
|
7
7
|
setuptools.setup(
|
|
8
8
|
name="computation-graph",
|
|
9
9
|
python_requires=">=3",
|
|
10
|
-
version="
|
|
10
|
+
version="57",
|
|
11
11
|
long_description=_LONG_DESCRIPTION,
|
|
12
12
|
long_description_content_type="text/markdown",
|
|
13
13
|
packages=setuptools.find_namespace_packages(),
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{computation_graph-56 → computation_graph-57}/computation_graph.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|