computation-graph 64__tar.gz → 66__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-64 → computation_graph-66}/PKG-INFO +8 -2
- {computation_graph-64 → computation_graph-66}/computation_graph/composers/lift.py +9 -1
- computation_graph-66/computation_graph/composers/lift_test.py +42 -0
- {computation_graph-64 → computation_graph-66}/computation_graph/run.py +15 -32
- {computation_graph-64 → computation_graph-66}/computation_graph.egg-info/PKG-INFO +8 -2
- {computation_graph-64 → computation_graph-66}/computation_graph.egg-info/SOURCES.txt +1 -0
- {computation_graph-64 → computation_graph-66}/setup.py +1 -1
- {computation_graph-64 → computation_graph-66}/LICENSE.md +0 -0
- {computation_graph-64 → computation_graph-66}/README.md +0 -0
- {computation_graph-64 → computation_graph-66}/computation_graph/__init__.py +0 -0
- {computation_graph-64 → computation_graph-66}/computation_graph/base_types.py +0 -0
- {computation_graph-64 → computation_graph-66}/computation_graph/composers/__init__.py +0 -0
- {computation_graph-64 → computation_graph-66}/computation_graph/composers/composers_test.py +0 -0
- {computation_graph-64 → computation_graph-66}/computation_graph/composers/condition.py +0 -0
- {computation_graph-64 → computation_graph-66}/computation_graph/composers/condition_test.py +0 -0
- {computation_graph-64 → computation_graph-66}/computation_graph/composers/debug.py +0 -0
- {computation_graph-64 → computation_graph-66}/computation_graph/composers/duplication.py +0 -0
- {computation_graph-64 → computation_graph-66}/computation_graph/composers/logic.py +0 -0
- {computation_graph-64 → computation_graph-66}/computation_graph/composers/memory.py +0 -0
- {computation_graph-64 → computation_graph-66}/computation_graph/composers/memory_test.py +0 -0
- {computation_graph-64 → computation_graph-66}/computation_graph/graph.py +0 -0
- {computation_graph-64 → computation_graph-66}/computation_graph/graph_runners.py +0 -0
- {computation_graph-64 → computation_graph-66}/computation_graph/graph_test.py +0 -0
- {computation_graph-64 → computation_graph-66}/computation_graph/legacy.py +0 -0
- {computation_graph-64 → computation_graph-66}/computation_graph/signature.py +0 -0
- {computation_graph-64 → computation_graph-66}/computation_graph/trace/__init__.py +0 -0
- {computation_graph-64 → computation_graph-66}/computation_graph/trace/ascii.py +0 -0
- {computation_graph-64 → computation_graph-66}/computation_graph/trace/graphviz.py +0 -0
- {computation_graph-64 → computation_graph-66}/computation_graph/trace/graphviz_test.py +0 -0
- {computation_graph-64 → computation_graph-66}/computation_graph/trace/mermaid.py +0 -0
- {computation_graph-64 → computation_graph-66}/computation_graph/trace/trace_utils.py +0 -0
- {computation_graph-64 → computation_graph-66}/computation_graph.egg-info/dependency_links.txt +0 -0
- {computation_graph-64 → computation_graph-66}/computation_graph.egg-info/requires.txt +0 -0
- {computation_graph-64 → computation_graph-66}/computation_graph.egg-info/top_level.txt +0 -0
- {computation_graph-64 → computation_graph-66}/pyproject.toml +0 -0
- {computation_graph-64 → computation_graph-66}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: computation-graph
|
|
3
|
-
Version:
|
|
3
|
+
Version: 66
|
|
4
4
|
Requires-Python: >=3
|
|
5
5
|
Description-Content-Type: text/markdown
|
|
6
6
|
License-File: LICENSE.md
|
|
@@ -12,6 +12,12 @@ Requires-Dist: termcolor
|
|
|
12
12
|
Provides-Extra: test
|
|
13
13
|
Requires-Dist: pygraphviz; extra == "test"
|
|
14
14
|
Requires-Dist: pytest>=5.4.0; extra == "test"
|
|
15
|
+
Dynamic: description
|
|
16
|
+
Dynamic: description-content-type
|
|
17
|
+
Dynamic: license-file
|
|
18
|
+
Dynamic: provides-extra
|
|
19
|
+
Dynamic: requires-dist
|
|
20
|
+
Dynamic: requires-python
|
|
15
21
|
|
|
16
22
|
[](https://travis-ci.com/hyroai/computation-graph)
|
|
17
23
|
|
|
@@ -5,11 +5,19 @@ import gamla
|
|
|
5
5
|
from computation_graph import base_types, composers
|
|
6
6
|
|
|
7
7
|
|
|
8
|
+
def _short_name(x) -> str:
|
|
9
|
+
if x is None or isinstance(x, (int, float, str)):
|
|
10
|
+
return f"{x!s:.30}"
|
|
11
|
+
if isinstance(x, (dict, list, tuple, set, frozenset)):
|
|
12
|
+
return f"{type(x).__name__}[{len(x)}]"
|
|
13
|
+
return type(x).__name__
|
|
14
|
+
|
|
15
|
+
|
|
8
16
|
def always(x):
|
|
9
17
|
def always():
|
|
10
18
|
return x
|
|
11
19
|
|
|
12
|
-
always.__name__ = f"always {x
|
|
20
|
+
always.__name__ = f"always {_short_name(x)}"
|
|
13
21
|
return always
|
|
14
22
|
|
|
15
23
|
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
from computation_graph.composers import lift
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
def test_always_returns_the_value():
|
|
5
|
+
assert lift.always(5)() == 5
|
|
6
|
+
obj = {"a": 1}
|
|
7
|
+
assert lift.always(obj)() is obj
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def test_always_name_keeps_scalars_readable():
|
|
11
|
+
assert lift.always(5).__name__ == "always 5"
|
|
12
|
+
assert lift.always(3.5).__name__ == "always 3.5"
|
|
13
|
+
assert lift.always("cardiology").__name__ == "always cardiology"
|
|
14
|
+
assert lift.always(None).__name__ == "always None"
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def test_always_name_summarizes_containers_by_type_and_length():
|
|
18
|
+
assert lift.always({"a": 1, "b": 2}).__name__ == "always dict[2]"
|
|
19
|
+
assert lift.always([1, 2, 3]).__name__ == "always list[3]"
|
|
20
|
+
assert lift.always((1, 2)).__name__ == "always tuple[2]"
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def test_always_name_does_not_render_large_container_contents():
|
|
24
|
+
# The point of the summary: naming a node must not stringify a huge value.
|
|
25
|
+
name = lift.always({i: i for i in range(10_000)}).__name__
|
|
26
|
+
assert name == "always dict[10000]"
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def test_always_name_falls_back_to_type_for_other_objects():
|
|
30
|
+
class Custom:
|
|
31
|
+
pass
|
|
32
|
+
|
|
33
|
+
assert lift.always(Custom()).__name__ == "always Custom"
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def test_distinct_always_calls_produce_distinct_nodes_despite_equal_names():
|
|
37
|
+
# Names are display-only; node identity is hash(func), and every always()
|
|
38
|
+
# call is a fresh function, so equal names must not collapse two nodes.
|
|
39
|
+
a, b = lift.always({"x": 1}), lift.always({"y": 2})
|
|
40
|
+
assert a.__name__ == b.__name__ == "always dict[1]"
|
|
41
|
+
assert a is not b
|
|
42
|
+
assert hash(a) != hash(b)
|
|
@@ -276,14 +276,6 @@ def _node_incoming_edges_to_input_spec(
|
|
|
276
276
|
)
|
|
277
277
|
|
|
278
278
|
|
|
279
|
-
def _to_awaitable(v) -> Awaitable:
|
|
280
|
-
if inspect.isawaitable(v):
|
|
281
|
-
return v
|
|
282
|
-
f = asyncio.get_event_loop().create_future()
|
|
283
|
-
f.set_result(v)
|
|
284
|
-
return f
|
|
285
|
-
|
|
286
|
-
|
|
287
279
|
def _make_get_node_executor(
|
|
288
280
|
edges, handled_exceptions, single_node_side_effect: _SingleNodeSideEffect
|
|
289
281
|
):
|
|
@@ -301,25 +293,6 @@ def _make_get_node_executor(
|
|
|
301
293
|
)
|
|
302
294
|
)
|
|
303
295
|
|
|
304
|
-
async def gather(
|
|
305
|
-
args: Tuple[Awaitable, ...], kwargs: Mapping[str, Awaitable]
|
|
306
|
-
) -> tuple[tuple[Any, ...], dict[str, Any]]:
|
|
307
|
-
if args or kwargs:
|
|
308
|
-
try:
|
|
309
|
-
gathered = await asyncio.gather(*args, *kwargs.values())
|
|
310
|
-
return gathered[: len(args)], dict(
|
|
311
|
-
zip(kwargs.keys(), gathered[len(args) :])
|
|
312
|
-
)
|
|
313
|
-
except (
|
|
314
|
-
_DepNotFoundError,
|
|
315
|
-
base_types.SkipComputationError,
|
|
316
|
-
*handled_exceptions,
|
|
317
|
-
):
|
|
318
|
-
# We delete the references to the upstream tasks to avoid circular reference (task->exception->traceback->task) and improve memory performance
|
|
319
|
-
del args, kwargs
|
|
320
|
-
raise _DepNotFoundError() from None
|
|
321
|
-
return (), {}
|
|
322
|
-
|
|
323
296
|
def node_to_input_sync(
|
|
324
297
|
accumulated_results: Mapping[base_types.ComputationNode, base_types.Result],
|
|
325
298
|
input_options: Iterable[_ComputationInputSpec],
|
|
@@ -349,12 +322,20 @@ def _make_get_node_executor(
|
|
|
349
322
|
accumulated_results.get(kwarg, CG_NO_RESULT) is not CG_NO_RESULT
|
|
350
323
|
for kwarg in kwargs_spec.values()
|
|
351
324
|
):
|
|
325
|
+
# Resolve inputs in place: await only the still-pending ones
|
|
326
|
+
# (already-scheduled tasks, so concurrency is preserved) and pass
|
|
327
|
+
# concrete values straight through. This avoids allocating a
|
|
328
|
+
# resolved Future per concrete input and the asyncio.gather
|
|
329
|
+
# machinery; the comprehension does zero awaits when nothing is
|
|
330
|
+
# pending, so it completes without suspending.
|
|
331
|
+
args = [accumulated_results[a] for a in args_spec]
|
|
332
|
+
kwargs = {k: accumulated_results[v] for k, v in kwargs_spec.items()}
|
|
352
333
|
try:
|
|
353
|
-
return
|
|
354
|
-
tuple(
|
|
334
|
+
return (
|
|
335
|
+
tuple([await x if inspect.isawaitable(x) else x for x in args]),
|
|
355
336
|
{
|
|
356
|
-
k:
|
|
357
|
-
for k,
|
|
337
|
+
k: (await x if inspect.isawaitable(x) else x)
|
|
338
|
+
for k, x in kwargs.items()
|
|
358
339
|
},
|
|
359
340
|
)
|
|
360
341
|
except (
|
|
@@ -362,7 +343,9 @@ def _make_get_node_executor(
|
|
|
362
343
|
base_types.SkipComputationError,
|
|
363
344
|
*handled_exceptions,
|
|
364
345
|
):
|
|
365
|
-
|
|
346
|
+
# Drop refs to the upstream tasks to avoid a
|
|
347
|
+
# task -> exception -> traceback -> task reference cycle.
|
|
348
|
+
del args, kwargs
|
|
366
349
|
return None
|
|
367
350
|
|
|
368
351
|
@opt_gamla.after(asyncio.create_task)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: computation-graph
|
|
3
|
-
Version:
|
|
3
|
+
Version: 66
|
|
4
4
|
Requires-Python: >=3
|
|
5
5
|
Description-Content-Type: text/markdown
|
|
6
6
|
License-File: LICENSE.md
|
|
@@ -12,6 +12,12 @@ Requires-Dist: termcolor
|
|
|
12
12
|
Provides-Extra: test
|
|
13
13
|
Requires-Dist: pygraphviz; extra == "test"
|
|
14
14
|
Requires-Dist: pytest>=5.4.0; extra == "test"
|
|
15
|
+
Dynamic: description
|
|
16
|
+
Dynamic: description-content-type
|
|
17
|
+
Dynamic: license-file
|
|
18
|
+
Dynamic: provides-extra
|
|
19
|
+
Dynamic: requires-dist
|
|
20
|
+
Dynamic: requires-python
|
|
15
21
|
|
|
16
22
|
[](https://travis-ci.com/hyroai/computation-graph)
|
|
17
23
|
|
|
@@ -22,6 +22,7 @@ computation_graph/composers/condition_test.py
|
|
|
22
22
|
computation_graph/composers/debug.py
|
|
23
23
|
computation_graph/composers/duplication.py
|
|
24
24
|
computation_graph/composers/lift.py
|
|
25
|
+
computation_graph/composers/lift_test.py
|
|
25
26
|
computation_graph/composers/logic.py
|
|
26
27
|
computation_graph/composers/memory.py
|
|
27
28
|
computation_graph/composers/memory_test.py
|
|
@@ -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="66",
|
|
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
|
{computation_graph-64 → computation_graph-66}/computation_graph.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|