hamilton icon indicating copy to clipboard operation
hamilton copied to clipboard

Async support for `PDBDebugger`

Open sT0v opened this issue 1 year ago • 1 comments

Is your feature request related to a problem? Please describe. sf-hamitlon=1.80.0 I would like to use PDBDebugger with async_driver.Builder().

from hamilton.lifecycle import PDBDebugger

dr =  asyncio.run(
    async_driver.Builder()
    .with_modules(__main__)
    .with_config({"env": "dev"})
    .with_adapters(
        # base.PandasDataFrameResult(), 
        # PDBDebugger("raw_loaded_report_data", after=True),
        PDBDebugger("raw_trades.missing_trade_attributes", during=True),
    )
    .build()
)

Raises : ValueError: Multiple adapters cannot (currently) implement the same lifecycle method. Sync methods: ['do_node_execute']. Async methods: [] even though there was only one adapter provided. I think this error is a bit imprecise?

Describe the solution you'd like A clear and concise description of what you want to happen. I would like to use PDBDebugger with async_driver.Builder(). If it makes sense, I'd also like to

Describe alternatives you've considered Using pdb.set_trace() on lines I want to inspect.

Additional context The async_driver requires the use of .with_adapters() but does not support multiple adapters.

 .with_adapters(
       base.PandasDataFrameResult(), 
       PDBDebugger("raw_trades.missing_trade_attributes", during=True),
    )

Raises: ValueError: Multiple adapters cannot (currently) implement the same lifecycle method. Sync methods: ['do_node_execute']. Async methods: []

sT0v avatar Oct 23 '24 17:10 sT0v

Thanks for reporting the issue. Currently, PDBDebugger isn't supported for async .

You're right that the error message can be ambiguous:

ValueError: Multiple adapters cannot (currently) implement the same lifecycle method. Sync methods: ['do_node_execute']. Async methods: []

In this case, the relevant part of the error is that the do_node_execute doesn't have an async version. It's definitely on our roadmap and we note your interest!

zilto avatar Oct 25 '24 17:10 zilto