Currently, we have a single driver. It's highly parametrizable, allowing you to customize:
To tune the above, pass in a Graph Adapter and or Result Builder-- see available-result-builders.md & available-graph-adapters.md.
Let's walk through how you might use the Hamilton Driver.
execute() to return. Default is to create a Pandas DataFrame.hofrom hamilton import driver from hamilton import base # 1. Setup config. See the Parameterizing the DAG section for usage config = {} # 2. we need to tell hamilton where to load function definitions from module_name = 'my_functions' module = importlib.import_module(module_name) # or simply "import my_functions" # 3. Determine the return type -- default is a pandas.DataFrame. adapter = base.SimplePythonDataFrameGraphAdapter() # See GraphAdapter docs for more details. # These all feed into creating the driver & thus DAG. dr = driver.Driver(config, module, adapter=adapter)
This approach assumes that all inputs were passed in with the config dictionary above.
output = ['output1', 'output2', ...] df = dr.execute(output)
This approach assumes that at least one input is not provided in the config dictionary provided to the constructor, and instead you provide that input to each execute invocation.
output = ['output1', 'output2', ...] for data in dataset: # if data is a dict of values. df = dr.execute(output, inputs=data)
This will force Hamilton to short circuit a particular computation path, and use the passed in override as a result of that particular node.
output = ['output1', 'output2', ...] df = dr.execute(output, overrides={'intermediate_node': intermediat_value})