computation-graph 56__tar.gz → 58__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-58}/PKG-INFO +1 -1
- {computation_graph-56 → computation_graph-58}/computation_graph/graph_test.py +11 -0
- {computation_graph-56 → computation_graph-58}/computation_graph/run.py +43 -69
- {computation_graph-56 → computation_graph-58}/computation_graph.egg-info/PKG-INFO +1 -1
- {computation_graph-56 → computation_graph-58}/setup.py +1 -1
- {computation_graph-56 → computation_graph-58}/LICENSE.md +0 -0
- {computation_graph-56 → computation_graph-58}/README.md +0 -0
- {computation_graph-56 → computation_graph-58}/computation_graph/__init__.py +0 -0
- {computation_graph-56 → computation_graph-58}/computation_graph/base_types.py +0 -0
- {computation_graph-56 → computation_graph-58}/computation_graph/composers/__init__.py +0 -0
- {computation_graph-56 → computation_graph-58}/computation_graph/composers/composers_test.py +0 -0
- {computation_graph-56 → computation_graph-58}/computation_graph/composers/condition.py +0 -0
- {computation_graph-56 → computation_graph-58}/computation_graph/composers/condition_test.py +0 -0
- {computation_graph-56 → computation_graph-58}/computation_graph/composers/debug.py +0 -0
- {computation_graph-56 → computation_graph-58}/computation_graph/composers/duplication.py +0 -0
- {computation_graph-56 → computation_graph-58}/computation_graph/composers/lift.py +0 -0
- {computation_graph-56 → computation_graph-58}/computation_graph/composers/logic.py +0 -0
- {computation_graph-56 → computation_graph-58}/computation_graph/composers/memory.py +0 -0
- {computation_graph-56 → computation_graph-58}/computation_graph/composers/memory_test.py +0 -0
- {computation_graph-56 → computation_graph-58}/computation_graph/graph.py +0 -0
- {computation_graph-56 → computation_graph-58}/computation_graph/graph_runners.py +0 -0
- {computation_graph-56 → computation_graph-58}/computation_graph/legacy.py +0 -0
- {computation_graph-56 → computation_graph-58}/computation_graph/signature.py +0 -0
- {computation_graph-56 → computation_graph-58}/computation_graph/trace/__init__.py +0 -0
- {computation_graph-56 → computation_graph-58}/computation_graph/trace/ascii.py +0 -0
- {computation_graph-56 → computation_graph-58}/computation_graph/trace/graphviz.py +0 -0
- {computation_graph-56 → computation_graph-58}/computation_graph/trace/graphviz_test.py +0 -0
- {computation_graph-56 → computation_graph-58}/computation_graph/trace/mermaid.py +0 -0
- {computation_graph-56 → computation_graph-58}/computation_graph/trace/trace_utils.py +0 -0
- {computation_graph-56 → computation_graph-58}/computation_graph.egg-info/SOURCES.txt +0 -0
- {computation_graph-56 → computation_graph-58}/computation_graph.egg-info/dependency_links.txt +0 -0
- {computation_graph-56 → computation_graph-58}/computation_graph.egg-info/requires.txt +0 -0
- {computation_graph-56 → computation_graph-58}/computation_graph.egg-info/top_level.txt +0 -0
- {computation_graph-56 → computation_graph-58}/pyproject.toml +0 -0
- {computation_graph-56 → computation_graph-58}/setup.cfg +0 -0
|
@@ -233,6 +233,17 @@ def test_first():
|
|
|
233
233
|
)
|
|
234
234
|
|
|
235
235
|
|
|
236
|
+
def test_raise_unhandled_exception():
|
|
237
|
+
class MyExceptionError(Exception):
|
|
238
|
+
...
|
|
239
|
+
|
|
240
|
+
def raises():
|
|
241
|
+
raise MyExceptionError("BAD")
|
|
242
|
+
|
|
243
|
+
with pytest.raises(MyExceptionError, match="BAD"):
|
|
244
|
+
graph_runners.nullary_infer_sink(composers.make_first(raises, lambda: 1))
|
|
245
|
+
|
|
246
|
+
|
|
236
247
|
def test_first_all_unactionable():
|
|
237
248
|
def raises():
|
|
238
249
|
raise base_types.SkipComputationError
|
|
@@ -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(
|
|
@@ -63,6 +72,12 @@ _toposort_nodes: Callable[
|
|
|
63
72
|
),
|
|
64
73
|
_transpose_graph,
|
|
65
74
|
toposort.toposort,
|
|
75
|
+
# Make async functions come first in each layer so they'll start running before all the sync functions
|
|
76
|
+
opt_gamla.maptuple(
|
|
77
|
+
gamla.sort_by(lambda n: 0 if inspect.iscoroutinefunction(n.func) else 1)
|
|
78
|
+
),
|
|
79
|
+
gamla.concat,
|
|
80
|
+
tuple,
|
|
66
81
|
)
|
|
67
82
|
|
|
68
83
|
|
|
@@ -198,14 +213,8 @@ def _to_callable_with_side_effect_for_single_and_multiple(
|
|
|
198
213
|
topological_layers = opt_gamla.pipe(
|
|
199
214
|
edges,
|
|
200
215
|
_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,
|
|
216
|
+
gamla.remove(gamla.contains(placeholder_to_future_source)),
|
|
217
|
+
opt_gamla.maptuple(opt_gamla.pair_right(get_node_executor)),
|
|
209
218
|
)
|
|
210
219
|
|
|
211
220
|
translate_source_to_placeholder = opt_gamla.compose_left(
|
|
@@ -214,18 +223,16 @@ def _to_callable_with_side_effect_for_single_and_multiple(
|
|
|
214
223
|
)
|
|
215
224
|
all_node_side_effects_on_edges = gamla.side_effect(all_nodes_side_effect(edges))
|
|
216
225
|
|
|
217
|
-
reduce_layers = _make_reduce_layers(handled_exceptions)
|
|
218
|
-
|
|
219
226
|
if is_async:
|
|
220
227
|
|
|
221
228
|
async def final_runner(sources_to_values):
|
|
222
229
|
d = gamla.pipe(
|
|
223
230
|
topological_layers,
|
|
224
|
-
|
|
225
|
-
|
|
231
|
+
_run_graph(
|
|
232
|
+
translate_source_to_placeholder(sources_to_values),
|
|
233
|
+
handled_exceptions,
|
|
226
234
|
),
|
|
227
235
|
dict,
|
|
228
|
-
gamla.side_effect(all_node_side_effects_on_edges),
|
|
229
236
|
)
|
|
230
237
|
results_by_is_async = _group_by_is_async_result(d.items())
|
|
231
238
|
async_results = tuple(zip(*results_by_is_async.get(True, ())))
|
|
@@ -253,8 +260,9 @@ def _to_callable_with_side_effect_for_single_and_multiple(
|
|
|
253
260
|
def final_runner(sources_to_values):
|
|
254
261
|
return gamla.pipe(
|
|
255
262
|
topological_layers,
|
|
256
|
-
|
|
257
|
-
|
|
263
|
+
_run_graph(
|
|
264
|
+
translate_source_to_placeholder(sources_to_values),
|
|
265
|
+
handled_exceptions,
|
|
258
266
|
),
|
|
259
267
|
dict,
|
|
260
268
|
all_node_side_effects_on_edges,
|
|
@@ -483,18 +491,7 @@ def _make_get_node_executor(
|
|
|
483
491
|
sync_and_downstream = sync & downstream_from_async
|
|
484
492
|
sync_not_downstream = sync - downstream_from_async
|
|
485
493
|
|
|
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
|
-
]:
|
|
494
|
+
def get_executor(node: base_types.ComputationNode) -> _NodeExecutor:
|
|
498
495
|
if node in async_and_downstream:
|
|
499
496
|
return await_deps_and_await
|
|
500
497
|
if node in async_not_downstream:
|
|
@@ -509,48 +506,25 @@ def _make_get_node_executor(
|
|
|
509
506
|
return get_executor
|
|
510
507
|
|
|
511
508
|
|
|
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
|
|
509
|
+
def _run_graph(inputs: dict, handled_exceptions):
|
|
510
|
+
def run_graph(
|
|
511
|
+
nodes: tuple[tuple[base_types.ComputationNode, _NodeExecutor]]
|
|
512
|
+
) -> _NodeToResults:
|
|
513
|
+
accumulated_results = inputs.copy()
|
|
514
|
+
for node_executor in nodes:
|
|
515
|
+
try:
|
|
516
|
+
accumulated_results[node_executor[0]] = node_executor[1](
|
|
517
|
+
accumulated_results, node_executor[0]
|
|
548
518
|
)
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
519
|
+
except (
|
|
520
|
+
_DepNotFoundError,
|
|
521
|
+
base_types.SkipComputationError,
|
|
522
|
+
*handled_exceptions,
|
|
523
|
+
):
|
|
524
|
+
pass
|
|
525
|
+
return accumulated_results
|
|
526
|
+
|
|
527
|
+
return run_graph
|
|
554
528
|
|
|
555
529
|
|
|
556
530
|
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="58",
|
|
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
|
{computation_graph-56 → computation_graph-58}/computation_graph.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|