computation-graph 58__tar.gz → 59__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-58 → computation_graph-59}/PKG-INFO +1 -1
- {computation_graph-58 → computation_graph-59}/computation_graph/graph_test.py +26 -0
- {computation_graph-58 → computation_graph-59}/computation_graph/run.py +41 -51
- {computation_graph-58 → computation_graph-59}/computation_graph.egg-info/PKG-INFO +1 -1
- {computation_graph-58 → computation_graph-59}/setup.py +1 -1
- {computation_graph-58 → computation_graph-59}/LICENSE.md +0 -0
- {computation_graph-58 → computation_graph-59}/README.md +0 -0
- {computation_graph-58 → computation_graph-59}/computation_graph/__init__.py +0 -0
- {computation_graph-58 → computation_graph-59}/computation_graph/base_types.py +0 -0
- {computation_graph-58 → computation_graph-59}/computation_graph/composers/__init__.py +0 -0
- {computation_graph-58 → computation_graph-59}/computation_graph/composers/composers_test.py +0 -0
- {computation_graph-58 → computation_graph-59}/computation_graph/composers/condition.py +0 -0
- {computation_graph-58 → computation_graph-59}/computation_graph/composers/condition_test.py +0 -0
- {computation_graph-58 → computation_graph-59}/computation_graph/composers/debug.py +0 -0
- {computation_graph-58 → computation_graph-59}/computation_graph/composers/duplication.py +0 -0
- {computation_graph-58 → computation_graph-59}/computation_graph/composers/lift.py +0 -0
- {computation_graph-58 → computation_graph-59}/computation_graph/composers/logic.py +0 -0
- {computation_graph-58 → computation_graph-59}/computation_graph/composers/memory.py +0 -0
- {computation_graph-58 → computation_graph-59}/computation_graph/composers/memory_test.py +0 -0
- {computation_graph-58 → computation_graph-59}/computation_graph/graph.py +0 -0
- {computation_graph-58 → computation_graph-59}/computation_graph/graph_runners.py +0 -0
- {computation_graph-58 → computation_graph-59}/computation_graph/legacy.py +0 -0
- {computation_graph-58 → computation_graph-59}/computation_graph/signature.py +0 -0
- {computation_graph-58 → computation_graph-59}/computation_graph/trace/__init__.py +0 -0
- {computation_graph-58 → computation_graph-59}/computation_graph/trace/ascii.py +0 -0
- {computation_graph-58 → computation_graph-59}/computation_graph/trace/graphviz.py +0 -0
- {computation_graph-58 → computation_graph-59}/computation_graph/trace/graphviz_test.py +0 -0
- {computation_graph-58 → computation_graph-59}/computation_graph/trace/mermaid.py +0 -0
- {computation_graph-58 → computation_graph-59}/computation_graph/trace/trace_utils.py +0 -0
- {computation_graph-58 → computation_graph-59}/computation_graph.egg-info/SOURCES.txt +0 -0
- {computation_graph-58 → computation_graph-59}/computation_graph.egg-info/dependency_links.txt +0 -0
- {computation_graph-58 → computation_graph-59}/computation_graph.egg-info/requires.txt +0 -0
- {computation_graph-58 → computation_graph-59}/computation_graph.egg-info/top_level.txt +0 -0
- {computation_graph-58 → computation_graph-59}/pyproject.toml +0 -0
- {computation_graph-58 → computation_graph-59}/setup.cfg +0 -0
|
@@ -244,6 +244,32 @@ def test_raise_unhandled_exception():
|
|
|
244
244
|
graph_runners.nullary_infer_sink(composers.make_first(raises, lambda: 1))
|
|
245
245
|
|
|
246
246
|
|
|
247
|
+
async def test_raise_exception_in_sync_after_async():
|
|
248
|
+
def raises(x):
|
|
249
|
+
raise TypeError("BAD")
|
|
250
|
+
|
|
251
|
+
async def async_source():
|
|
252
|
+
return 4
|
|
253
|
+
|
|
254
|
+
with pytest.raises(TypeError, match="BAD"):
|
|
255
|
+
await run.to_callable_strict(
|
|
256
|
+
composers.compose_left(async_source, raises, lambda x: 1)
|
|
257
|
+
)({}, {})
|
|
258
|
+
|
|
259
|
+
|
|
260
|
+
async def test_raise_exception_in_async_after_sync():
|
|
261
|
+
async def raises(x):
|
|
262
|
+
raise TypeError("BAD")
|
|
263
|
+
|
|
264
|
+
def source():
|
|
265
|
+
return 4
|
|
266
|
+
|
|
267
|
+
with pytest.raises(TypeError, match="BAD"):
|
|
268
|
+
await run.to_callable_strict(
|
|
269
|
+
composers.compose_left(source, raises, lambda x: 1)
|
|
270
|
+
)({}, {})
|
|
271
|
+
|
|
272
|
+
|
|
247
273
|
def test_first_all_unactionable():
|
|
248
274
|
def raises():
|
|
249
275
|
raise base_types.SkipComputationError
|
|
@@ -102,7 +102,7 @@ def _profile(node, time_started: float):
|
|
|
102
102
|
)
|
|
103
103
|
|
|
104
104
|
|
|
105
|
-
|
|
105
|
+
_group_by_is_future = opt_gamla.groupby(lambda k_v: asyncio.isfuture(k_v[1]))
|
|
106
106
|
|
|
107
107
|
|
|
108
108
|
_is_graph_async = opt_gamla.compose_left(
|
|
@@ -210,7 +210,7 @@ def _to_callable_with_side_effect_for_single_and_multiple(
|
|
|
210
210
|
edges, handled_exceptions, single_node_side_effect
|
|
211
211
|
)
|
|
212
212
|
|
|
213
|
-
|
|
213
|
+
topological_sorted_nodes = opt_gamla.pipe(
|
|
214
214
|
edges,
|
|
215
215
|
_toposort_nodes,
|
|
216
216
|
gamla.remove(gamla.contains(placeholder_to_future_source)),
|
|
@@ -226,46 +226,37 @@ def _to_callable_with_side_effect_for_single_and_multiple(
|
|
|
226
226
|
if is_async:
|
|
227
227
|
|
|
228
228
|
async def final_runner(sources_to_values):
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
handled_exceptions,
|
|
234
|
-
),
|
|
235
|
-
dict,
|
|
229
|
+
node_to_task_or_result = _run_graph(
|
|
230
|
+
translate_source_to_placeholder(sources_to_values),
|
|
231
|
+
handled_exceptions,
|
|
232
|
+
topological_sorted_nodes,
|
|
236
233
|
)
|
|
237
|
-
results_by_is_async =
|
|
234
|
+
results_by_is_async = _group_by_is_future(node_to_task_or_result.items())
|
|
238
235
|
async_results = tuple(zip(*results_by_is_async.get(True, ())))
|
|
239
236
|
sync_results = dict(results_by_is_async.get(False, ()))
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
if async_results
|
|
254
|
-
else {}
|
|
255
|
-
)
|
|
256
|
-
)
|
|
237
|
+
|
|
238
|
+
all_results = sync_results
|
|
239
|
+
if async_results:
|
|
240
|
+
for (node, node_result) in zip(
|
|
241
|
+
async_results[0],
|
|
242
|
+
await asyncio.gather(*async_results[1], return_exceptions=True),
|
|
243
|
+
):
|
|
244
|
+
e = node_to_task_or_result[node].exception()
|
|
245
|
+
if e:
|
|
246
|
+
raise e from e
|
|
247
|
+
all_results[node] = node_result
|
|
248
|
+
|
|
249
|
+
return all_node_side_effects_on_edges(all_results)
|
|
257
250
|
|
|
258
251
|
else:
|
|
259
252
|
|
|
260
253
|
def final_runner(sources_to_values):
|
|
261
|
-
return
|
|
262
|
-
topological_layers,
|
|
254
|
+
return all_node_side_effects_on_edges(
|
|
263
255
|
_run_graph(
|
|
264
256
|
translate_source_to_placeholder(sources_to_values),
|
|
265
257
|
handled_exceptions,
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
all_node_side_effects_on_edges,
|
|
258
|
+
topological_sorted_nodes,
|
|
259
|
+
)
|
|
269
260
|
)
|
|
270
261
|
|
|
271
262
|
return (_async_graph_reducer if is_async else _graph_reducer)(final_runner)
|
|
@@ -506,25 +497,24 @@ def _make_get_node_executor(
|
|
|
506
497
|
return get_executor
|
|
507
498
|
|
|
508
499
|
|
|
509
|
-
def _run_graph(
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
return run_graph
|
|
500
|
+
def _run_graph(
|
|
501
|
+
inputs: dict,
|
|
502
|
+
handled_exceptions,
|
|
503
|
+
topological_sorted_nodes: tuple[tuple[base_types.ComputationNode, _NodeExecutor]],
|
|
504
|
+
) -> _NodeToResults:
|
|
505
|
+
accumulated_results = inputs.copy()
|
|
506
|
+
for node_executor in topological_sorted_nodes:
|
|
507
|
+
try:
|
|
508
|
+
accumulated_results[node_executor[0]] = node_executor[1](
|
|
509
|
+
accumulated_results, node_executor[0]
|
|
510
|
+
)
|
|
511
|
+
except (
|
|
512
|
+
_DepNotFoundError,
|
|
513
|
+
base_types.SkipComputationError,
|
|
514
|
+
*handled_exceptions,
|
|
515
|
+
):
|
|
516
|
+
pass
|
|
517
|
+
return accumulated_results
|
|
528
518
|
|
|
529
519
|
|
|
530
520
|
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="59",
|
|
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-58 → computation_graph-59}/computation_graph.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|