Louwrens
10/08/2024, 7:50 PMvisualize_execution of my async_module. But I hit an issue, what am I doing wrong here?
async def driver_visualize_execution(foo:str="foo"):
input_data = {"foo": foo, "bar": "bar", "some_data": dict(lol=42)}
dr = await builder.build()
await dr.visualize_execution(["pipeline"], output_file_path=f"dag_execute_{foo}.png", inputs=input_data)
... gives me this error:
Traceback (most recent call last):
File "dataflow_async_run.py", line 59, in <module>
asyncio.run(main())
File "C:\Users\User\.pyenv\pyenv-win\versions\3.8.10\lib\asyncio\runners.py", line 44, in run
return loop.run_until_complete(main)
File "C:\Users\User\.pyenv\pyenv-win\versions\3.8.10\lib\asyncio\base_events.py", line 616, in run_until_complete
return future.result()
File "dataflow_async_run.py", line 39, in main
await driver_visualize_execution("foo")
File "dataflow_async_run.py", line 21, in driver_visualize_execution
await dr.visualize_execution(["pipeline"], output_file_path=output_file_path, inputs=input_data)
TypeError: object Digraph can't be used in 'await' expressionElijah Ben Izzy
10/08/2024, 7:51 PMawait in visualize_execution β itβs not a coroutine!Elijah Ben Izzy
10/08/2024, 7:51 PMasync def driver_visualize_execution(foo:str="foo"):
input_data = {"foo": foo, "bar": "bar", "some_data": dict(lol=42)}
dr = await builder.build()
dr.visualize_execution(["pipeline"], output_file_path=f"dag_execute_{foo}.png", inputs=input_data)Louwrens
10/08/2024, 7:52 PMLouwrens
10/08/2024, 7:55 PMdr outside the scope of this (or another) function, like a global object? I guess it has to be `await`ed, from within an async function...Stefan Krawczyk
10/08/2024, 8:02 PMdr outside the scope of this (or another) function, like a global object? I guess it has to be `await`ed, from within an async function...
@Louwrens yep correct. (though I think asyncio.run(β¦) might work β as well as what Elijah mentions below). Are you using it within a web-service? or?eLouwrens
10/08/2024, 8:09 PMasyncio.run() now, I'm not really looking to integrate it in a web service. I want to try to use Hamilton in doing a classification of photos produced by a robot, there is a lot of home made existing code and I want to disentangle it and begin with a small clean projectLouwrens
10/08/2024, 8:12 PMshared_memory objects correctly with Hamilton? The photos are currently stored there, and I was thinking I might need to write a dataloader decorator or something...Stefan Krawczyk
10/08/2024, 8:13 PMLouwrens
10/08/2024, 8:16 PMLouwrens
10/08/2024, 8:22 PMasyncio instead. The robot has one PC, so celery seems overkill.
In Hamilton, the data passed between nodes remains in-memory right? Maybe using shared_memory might also be redundant?Stefan Krawczyk
10/08/2024, 8:30 PMStefan Krawczyk
10/08/2024, 8:31 PMStefan Krawczyk
10/08/2024, 8:31 PMElijah Ben Izzy
10/08/2024, 8:40 PMdef driver_visualize_execution(foo:str="foo"):
input_data = {"foo": foo, "bar": "bar", "some_data": dict(lol=42)}
dr = builder.build_without_init()
await dr.visualize_execution(["pipeline"], output_file_path=f"dag_execute_{foo}.png", inputs=input_data)
Note that, if you have any async initialization (E.G. the Hamilton UI), youβll want to call await dr.ainit() later onLouwrens
10/08/2024, 10:19 PMawait π )Elijah Ben Izzy
10/08/2024, 10:35 PM