Custom Result Builders#

How to build your own Result Builder

Before starting#

We suggest reaching out on slackor via a github issue, if you have a use case for a custom result builder. Knowing about your use case and talkingthrough it can help ensure we aren’t duplicating effort, and we can help steer you in the right direction.

What you need to do#

You need to implement a class that implements a single function - see github code:

class ResultMixin(object):
    """Base class housing the static function.

    Why a static function? That's because certain frameworks can only pickle a static function, not an entire
    def build_result(**outputs: typing.Dict[str, typing.Any]) -> typing.Any:
        """This function builds the result given the computed values."""


import typing
from hamilton import base
class MyCustomBuilder(base.ResultMixin):
     # add a constructor if you need to
     def build_result(**outputs: typing.Dict[str, typing.Any]) -> YOUR_RETURN_TYPE:
         """Custom function you fill in"""
         # your logic would go here

How to use it#

You would then pair that with a graph adapter that takes in a ResultMixin object. E.g. SimplePythonGraphAdapter. See GraphAdapters for which ones take in a custom ResultMixin object.