computation-graph 58__tar.gz → 60__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-60}/PKG-INFO +1 -1
- {computation_graph-58 → computation_graph-60}/computation_graph/graph_test.py +38 -0
- {computation_graph-58 → computation_graph-60}/computation_graph/run.py +48 -51
- {computation_graph-58 → computation_graph-60}/computation_graph.egg-info/PKG-INFO +1 -1
- {computation_graph-58 → computation_graph-60}/setup.py +1 -1
- {computation_graph-58 → computation_graph-60}/LICENSE.md +0 -0
- {computation_graph-58 → computation_graph-60}/README.md +0 -0
- {computation_graph-58 → computation_graph-60}/computation_graph/__init__.py +0 -0
- {computation_graph-58 → computation_graph-60}/computation_graph/base_types.py +0 -0
- {computation_graph-58 → computation_graph-60}/computation_graph/composers/__init__.py +0 -0
- {computation_graph-58 → computation_graph-60}/computation_graph/composers/composers_test.py +0 -0
- {computation_graph-58 → computation_graph-60}/computation_graph/composers/condition.py +0 -0
- {computation_graph-58 → computation_graph-60}/computation_graph/composers/condition_test.py +0 -0
- {computation_graph-58 → computation_graph-60}/computation_graph/composers/debug.py +0 -0
- {computation_graph-58 → computation_graph-60}/computation_graph/composers/duplication.py +0 -0
- {computation_graph-58 → computation_graph-60}/computation_graph/composers/lift.py +0 -0
- {computation_graph-58 → computation_graph-60}/computation_graph/composers/logic.py +0 -0
- {computation_graph-58 → computation_graph-60}/computation_graph/composers/memory.py +0 -0
- {computation_graph-58 → computation_graph-60}/computation_graph/composers/memory_test.py +0 -0
- {computation_graph-58 → computation_graph-60}/computation_graph/graph.py +0 -0
- {computation_graph-58 → computation_graph-60}/computation_graph/graph_runners.py +0 -0
- {computation_graph-58 → computation_graph-60}/computation_graph/legacy.py +0 -0
- {computation_graph-58 → computation_graph-60}/computation_graph/signature.py +0 -0
- {computation_graph-58 → computation_graph-60}/computation_graph/trace/__init__.py +0 -0
- {computation_graph-58 → computation_graph-60}/computation_graph/trace/ascii.py +0 -0
- {computation_graph-58 → computation_graph-60}/computation_graph/trace/graphviz.py +0 -0
- {computation_graph-58 → computation_graph-60}/computation_graph/trace/graphviz_test.py +0 -0
- {computation_graph-58 → computation_graph-60}/computation_graph/trace/mermaid.py +0 -0
- {computation_graph-58 → computation_graph-60}/computation_graph/trace/trace_utils.py +0 -0
- {computation_graph-58 → computation_graph-60}/computation_graph.egg-info/SOURCES.txt +0 -0
- {computation_graph-58 → computation_graph-60}/computation_graph.egg-info/dependency_links.txt +0 -0
- {computation_graph-58 → computation_graph-60}/computation_graph.egg-info/requires.txt +0 -0
- {computation_graph-58 → computation_graph-60}/computation_graph.egg-info/top_level.txt +0 -0
- {computation_graph-58 → computation_graph-60}/pyproject.toml +0 -0
- {computation_graph-58 → computation_graph-60}/setup.cfg +0 -0
|
@@ -233,6 +233,18 @@ def test_first():
|
|
|
233
233
|
)
|
|
234
234
|
|
|
235
235
|
|
|
236
|
+
async def test_raise_handled_from_async():
|
|
237
|
+
async def raises():
|
|
238
|
+
raise base_types.SkipComputationError
|
|
239
|
+
|
|
240
|
+
assert (
|
|
241
|
+
await graph_runners.nullary_infer_sink(
|
|
242
|
+
composers.make_first(raises, lambda: 1, lambda: 2)
|
|
243
|
+
)
|
|
244
|
+
== 1
|
|
245
|
+
)
|
|
246
|
+
|
|
247
|
+
|
|
236
248
|
def test_raise_unhandled_exception():
|
|
237
249
|
class MyExceptionError(Exception):
|
|
238
250
|
...
|
|
@@ -244,6 +256,32 @@ def test_raise_unhandled_exception():
|
|
|
244
256
|
graph_runners.nullary_infer_sink(composers.make_first(raises, lambda: 1))
|
|
245
257
|
|
|
246
258
|
|
|
259
|
+
async def test_raise_exception_in_sync_after_async():
|
|
260
|
+
def raises(x):
|
|
261
|
+
raise TypeError("BAD")
|
|
262
|
+
|
|
263
|
+
async def async_source():
|
|
264
|
+
return 4
|
|
265
|
+
|
|
266
|
+
with pytest.raises(TypeError, match="BAD"):
|
|
267
|
+
await run.to_callable_strict(
|
|
268
|
+
composers.compose_left(async_source, raises, lambda x: 1)
|
|
269
|
+
)({}, {})
|
|
270
|
+
|
|
271
|
+
|
|
272
|
+
async def test_raise_exception_in_async_after_sync():
|
|
273
|
+
async def raises(x):
|
|
274
|
+
raise TypeError("BAD")
|
|
275
|
+
|
|
276
|
+
def source():
|
|
277
|
+
return 4
|
|
278
|
+
|
|
279
|
+
with pytest.raises(TypeError, match="BAD"):
|
|
280
|
+
await run.to_callable_strict(
|
|
281
|
+
composers.compose_left(source, raises, lambda x: 1)
|
|
282
|
+
)({}, {})
|
|
283
|
+
|
|
284
|
+
|
|
247
285
|
def test_first_all_unactionable():
|
|
248
286
|
def raises():
|
|
249
287
|
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,44 @@ 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
|
-
|
|
254
|
-
|
|
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 and not isinstance(
|
|
246
|
+
e,
|
|
247
|
+
(
|
|
248
|
+
_DepNotFoundError,
|
|
249
|
+
base_types.SkipComputationError,
|
|
250
|
+
*handled_exceptions,
|
|
251
|
+
),
|
|
252
|
+
):
|
|
253
|
+
raise e from e
|
|
254
|
+
all_results[node] = node_result
|
|
255
|
+
|
|
256
|
+
return all_node_side_effects_on_edges(all_results)
|
|
257
257
|
|
|
258
258
|
else:
|
|
259
259
|
|
|
260
260
|
def final_runner(sources_to_values):
|
|
261
|
-
return
|
|
262
|
-
topological_layers,
|
|
261
|
+
return all_node_side_effects_on_edges(
|
|
263
262
|
_run_graph(
|
|
264
263
|
translate_source_to_placeholder(sources_to_values),
|
|
265
264
|
handled_exceptions,
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
all_node_side_effects_on_edges,
|
|
265
|
+
topological_sorted_nodes,
|
|
266
|
+
)
|
|
269
267
|
)
|
|
270
268
|
|
|
271
269
|
return (_async_graph_reducer if is_async else _graph_reducer)(final_runner)
|
|
@@ -506,25 +504,24 @@ def _make_get_node_executor(
|
|
|
506
504
|
return get_executor
|
|
507
505
|
|
|
508
506
|
|
|
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
|
|
507
|
+
def _run_graph(
|
|
508
|
+
inputs: dict,
|
|
509
|
+
handled_exceptions,
|
|
510
|
+
topological_sorted_nodes: tuple[tuple[base_types.ComputationNode, _NodeExecutor]],
|
|
511
|
+
) -> _NodeToResults:
|
|
512
|
+
accumulated_results = inputs.copy()
|
|
513
|
+
for node_executor in topological_sorted_nodes:
|
|
514
|
+
try:
|
|
515
|
+
accumulated_results[node_executor[0]] = node_executor[1](
|
|
516
|
+
accumulated_results, node_executor[0]
|
|
517
|
+
)
|
|
518
|
+
except (
|
|
519
|
+
_DepNotFoundError,
|
|
520
|
+
base_types.SkipComputationError,
|
|
521
|
+
*handled_exceptions,
|
|
522
|
+
):
|
|
523
|
+
pass
|
|
524
|
+
return accumulated_results
|
|
528
525
|
|
|
529
526
|
|
|
530
527
|
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="60",
|
|
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-60}/computation_graph.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|