computation-graph 65__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.
Files changed (36) hide show
  1. {computation_graph-65 → computation_graph-66}/PKG-INFO +1 -1
  2. {computation_graph-65 → computation_graph-66}/computation_graph/run.py +15 -32
  3. {computation_graph-65 → computation_graph-66}/computation_graph.egg-info/PKG-INFO +1 -1
  4. {computation_graph-65 → computation_graph-66}/setup.py +1 -1
  5. {computation_graph-65 → computation_graph-66}/LICENSE.md +0 -0
  6. {computation_graph-65 → computation_graph-66}/README.md +0 -0
  7. {computation_graph-65 → computation_graph-66}/computation_graph/__init__.py +0 -0
  8. {computation_graph-65 → computation_graph-66}/computation_graph/base_types.py +0 -0
  9. {computation_graph-65 → computation_graph-66}/computation_graph/composers/__init__.py +0 -0
  10. {computation_graph-65 → computation_graph-66}/computation_graph/composers/composers_test.py +0 -0
  11. {computation_graph-65 → computation_graph-66}/computation_graph/composers/condition.py +0 -0
  12. {computation_graph-65 → computation_graph-66}/computation_graph/composers/condition_test.py +0 -0
  13. {computation_graph-65 → computation_graph-66}/computation_graph/composers/debug.py +0 -0
  14. {computation_graph-65 → computation_graph-66}/computation_graph/composers/duplication.py +0 -0
  15. {computation_graph-65 → computation_graph-66}/computation_graph/composers/lift.py +0 -0
  16. {computation_graph-65 → computation_graph-66}/computation_graph/composers/lift_test.py +0 -0
  17. {computation_graph-65 → computation_graph-66}/computation_graph/composers/logic.py +0 -0
  18. {computation_graph-65 → computation_graph-66}/computation_graph/composers/memory.py +0 -0
  19. {computation_graph-65 → computation_graph-66}/computation_graph/composers/memory_test.py +0 -0
  20. {computation_graph-65 → computation_graph-66}/computation_graph/graph.py +0 -0
  21. {computation_graph-65 → computation_graph-66}/computation_graph/graph_runners.py +0 -0
  22. {computation_graph-65 → computation_graph-66}/computation_graph/graph_test.py +0 -0
  23. {computation_graph-65 → computation_graph-66}/computation_graph/legacy.py +0 -0
  24. {computation_graph-65 → computation_graph-66}/computation_graph/signature.py +0 -0
  25. {computation_graph-65 → computation_graph-66}/computation_graph/trace/__init__.py +0 -0
  26. {computation_graph-65 → computation_graph-66}/computation_graph/trace/ascii.py +0 -0
  27. {computation_graph-65 → computation_graph-66}/computation_graph/trace/graphviz.py +0 -0
  28. {computation_graph-65 → computation_graph-66}/computation_graph/trace/graphviz_test.py +0 -0
  29. {computation_graph-65 → computation_graph-66}/computation_graph/trace/mermaid.py +0 -0
  30. {computation_graph-65 → computation_graph-66}/computation_graph/trace/trace_utils.py +0 -0
  31. {computation_graph-65 → computation_graph-66}/computation_graph.egg-info/SOURCES.txt +0 -0
  32. {computation_graph-65 → computation_graph-66}/computation_graph.egg-info/dependency_links.txt +0 -0
  33. {computation_graph-65 → computation_graph-66}/computation_graph.egg-info/requires.txt +0 -0
  34. {computation_graph-65 → computation_graph-66}/computation_graph.egg-info/top_level.txt +0 -0
  35. {computation_graph-65 → computation_graph-66}/pyproject.toml +0 -0
  36. {computation_graph-65 → computation_graph-66}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: computation-graph
3
- Version: 65
3
+ Version: 66
4
4
  Requires-Python: >=3
5
5
  Description-Content-Type: text/markdown
6
6
  License-File: LICENSE.md
@@ -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 await gather(
354
- tuple(_to_awaitable(accumulated_results[a]) for a in args_spec),
334
+ return (
335
+ tuple([await x if inspect.isawaitable(x) else x for x in args]),
355
336
  {
356
- k: _to_awaitable(accumulated_results[v])
357
- for k, v in kwargs_spec.items()
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
1
  Metadata-Version: 2.4
2
2
  Name: computation-graph
3
- Version: 65
3
+ Version: 66
4
4
  Requires-Python: >=3
5
5
  Description-Content-Type: text/markdown
6
6
  License-File: LICENSE.md
@@ -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="65",
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