Slackbot
08/02/2022, 5:59 PMStefan Krawczyk
08/02/2022, 6:17 PMSimon Helmig
08/02/2022, 6:29 PMElijah Ben Izzy
08/02/2022, 6:37 PMStefan Krawczyk
08/02/2022, 6:45 PMfrom hamilton import driver
dag = driver.Driver({...}, modules, adapter=...)
@app.get("/endpoint")
async def compute( ... ):
data = await pull_from_db(...)
result = dag.execute([output], inputs=data)
# transform result for fastapi
return result
Simon Helmig
08/02/2022, 6:46 PMStefan Krawczyk
08/02/2022, 6:50 PMasyncio.run(…)
.
Otherwise Hamilton can be run within a running event loop only if the underlying DAG has no async functions - which is what I’m suggesting as the stop gap measure.Stefan Krawczyk
08/02/2022, 7:02 PMStefan Krawczyk
08/02/2022, 7:04 PMSimon Helmig
08/02/2022, 7:15 PMElijah Ben Izzy
08/02/2022, 7:25 PMSimon Helmig
08/02/2022, 7:44 PMStefan Krawczyk
08/02/2022, 7:48 PMRuntimeError: asyncio.run() cannot be called from a running event loop
Stefan Krawczyk
08/02/2022, 7:51 PMSimon Helmig
08/02/2022, 7:53 PMStefan Krawczyk
08/02/2022, 8:06 PMSimon Helmig
08/03/2022, 4:36 AMStefan Krawczyk
08/03/2022, 2:20 PMSimon Helmig
08/03/2022, 3:30 PMSimon Helmig
08/03/2022, 6:57 PMpipeline
, which orchestrates component1
and component2
, either of which could be requesting data from external sources, and all of which log data into the db at the beginning and end of each function.
Hope it makes sense, let me know if anything is unclear / I can support somehow!Elijah Ben Izzy
08/05/2022, 8:00 PMcomputation1
(and presumably computation2
), you do three things — log, calculate, then log. is the idea of breaking up logging into two pieces for the purpose of measuring (E.G. time), or could it be one piece?
Likely going to try to prototype an async hamilton implementation (I’ve actually done it in the past so I have some code I can dig up), but it will add a bit of complexity, so it’ll be on a branch for now (happy to walk you through installing it). OTOH, separating the compute from the externalities might help out with your use-case, especially when you want to log differently in bulk…Elijah Ben Izzy
08/05/2022, 8:01 PMElijah Ben Izzy
08/05/2022, 8:01 PMElijah Ben Izzy
08/07/2022, 7:45 PMpip install -e .
• install directly from git pip install "git+<https://github.com/stitchfix/hamilton@async-prototype>"
Elijah Ben Izzy
08/07/2022, 7:51 PMElijah Ben Izzy
08/16/2022, 3:42 AMasync
implementation! Looking forward to how it works for your case. https://hamilton-opensource.slack.com/archives/C03M34FM058/p1660621246625529