import_module()

hamilton.dataflows.import_module(dataflow: str, user: str = None, version: str = 'latest', overwrite: bool = False) ModuleType

Pulls & imports dataflow code from github and returns a module.

from hamilton import dataflows, driver
# downloads into ~/.hamilton/dataflows and loads the module -- WARNING: ensure you know what code you're importing!
# NAME_OF_DATAFLOW = dataflow.import_module("NAME_OF_DATAFLOW") # if using official dataflow
NAME_OF_DATAFLOW = dataflow.import_module("NAME_OF_DATAFLOW", "NAME_OF_USER")
dr = (
  driver.Builder()
  .with_config({})  # replace with configuration as appropriate
  .with_modules(NAME_OF_DATAFLOW)
  .build()
)
# execute the dataflow, specifying what you want back. Will return a dictionary.
result = dr.execute(
  [NAME_OF_DATAFLOW.FUNCTION_NAME, ...],  # this specifies what you want back
  inputs={...}  # pass in inputs as appropriate
)
Parameters:
  • dataflow – the name of the dataflow.

  • user – Optional. If none it assumes official.

  • version – the version to get. β€œlatest” will resolve to the most recent commit. Otherwise pass a the commit SHA you want to pull.

  • overwrite – whether to overwrite the local path. Default is False.

Returns:

a Module that you can then pass to Hamilton.