Generic

Result builders help you augment what is returned by the driver’s execute() function. Here are the generic ones.

class hamilton.base.ResultMixin

Legacy result builder – see lifecycle methods for more information.

class hamilton.base.DictResult

Simple function that returns the dict of column -> value results.

It returns the results as a dictionary, where the keys map to outputs requested, and values map to what was computed for those values.

Use this when you want to:

  1. debug dataflows.

  2. have heterogeneous return types.

  3. Want to manually transform the result into something of your choosing.

from hamilton import base, driver
dict_builder = base.DictResult()
adapter = base.SimplePythonGraphAdapter(dict_builder)
dr =  driver.Driver(config, *modules, adapter=adapter)
dict_result = dr.execute([...], inputs=...)

Note, if you just want the dict result + the SimplePythonGraphAdapter, you can use the DefaultAdapter

adapter = base.DefaultAdapter()
static build_result(**outputs: Dict[str, Any]) Dict

This function builds a simple dict of output -> computed values.

input_types() List[Type[Type]] | None

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