Hi, I'd like to ask if the `@inject` works with `C...
# hamilton-help
r
Hi, I'd like to ask if the
@inject
works with `CacheAdapter`:
Copy code
@inject(foo=source("foo"))
def worker(seconds: int, foo: int) -> int:
    print(f"start work {seconds}s")
    start = perf_counter()
    print(f"foo: {foo}")
    end = perf_counter()
    print(f"end stop {end - start:.2f}s work")
    return seconds

logic = create_temporary_module(
    worker,
)

if __name__ == "__main__":
    dr = (
        driver.Builder()
        .with_modules(logic)
        .enable_dynamic_execution(allow_experimental_mode=True)
        .with_local_executor(executors.SynchronousLocalTaskExecutor())
        .with_remote_executor(
            executors.MultiThreadingExecutor(max_tasks=4)
        ) 
        # !!! error when uncomment this line !!!
        # TypeError: module, class, method, function, traceback, frame, or code object was expected, got partial
        .with_adapters(CacheAdapter(cache_path="cache"))
        .with_config({"foo": 42})
        .build()
    )
    start = perf_counter()
    dr.execute(["worker"], inputs={"seconds": 3})
    print(f"Time taken: {perf_counter() - start: .2f} seconds")
s
yep so it seems the cache adapter has a bug here that it should handle
r
😂 so fast to respond! i will follow this issue since my decorator also needs to check
partial
type:
isgeneratorfunction
can not inspect
partial
, and the order of decorators should also need to take care
👍 1