h_async.AsyncGraphAdapter¶

class hamilton.async_driver.AsyncGraphAdapter(result_builder: ResultMixin = None, async_lifecycle_adapters: LifecycleAdapterSet | None = None)¶

Graph adapter for use with the AsyncDriver class.

__init__(result_builder: ResultMixin = None, async_lifecycle_adapters: LifecycleAdapterSet | None = None)¶

Creates an AsyncGraphAdapter class. Note this will only work with the AsyncDriver class.

Some things to note:

  1. This executes everything at the end (recursively). E.G. the final DAG nodes are awaited

  2. This does not work with decorators when the async function is being decorated. That is because that function is called directly within the decorator, so we cannot await it.

build_result(**outputs: Any) Any¶

Given a set of outputs, build the result.

Parameters:

outputs – the outputs from the execution of the graph.

Returns:

the result of the execution of the graph.

do_build_result(outputs: Dict[str, Any]) Any¶

Implements the do_build_result method from the BaseDoBuildResult class. This is kept from the user as the public-facing API is build_result, allowing us to change the API/implementation of the internal set of hooks

do_node_execute(*, run_id: str, node_: Node, kwargs: Dict[str, Any], task_id: str | None = None) Any¶

Executes a node. Note this doesn’t actually execute it – rather, it returns a task. This does not use async def, as we want it to be awaited on later – this await is done in processing parameters of downstream functions/final results. We can ensure that as we also run the driver that this corresponds to.

Note that this assumes that everything is awaitable, even if it isn’t. In that case, it just wraps it in one.

Parameters:
  • task_id

  • node

  • run_id

  • node – Node to wrap

  • kwargs – Keyword arguments (either coroutines or raw values) to call it with

Returns:

A task

input_types() List[Type[Type]]¶

Gives the applicable types to this result builder. This is optional for backwards compatibility, but is recommended.

Returns:

A list of types that this can apply to.

output_type() Type¶

Returns the output type of this result builder :return: the type that this creates