hamilton icon indicating copy to clipboard operation
hamilton copied to clipboard

Easy way to scrape local functions

Open elijahbenizzy opened this issue 1 year ago • 0 comments

Can we get all fns that are defined in the local module and insert them into a driver?

Two workarounds for now:

  1. create_temporary_module
  2. __main__ hack
def foo() -> int:
    return 1


from hamilton import driver

if __name__ == '__main__':
    import __main__
    dr = driver.Builder().with_modules(__main__).build()
    print(dr.execute(["foo"]))

Thinking:

driver.Builder().with_local_modules().build()
driver.Builder().with_modules(hamilton.find_local()).build()

elijahbenizzy avatar Feb 08 '24 19:02 elijahbenizzy