Patrick Wspanialy
04/29/2024, 8:22 PMimport time
from prefect import flow, serve
@flow
def slow_flow(sleep: int = 60):
"Sleepy flow - sleeps the provided amount of time (in seconds)."
time.sleep(sleep)
@flow
def fast_flow():
"Fastest flow this side of the Mississippi."
return
if __name__ == "__main__":
slow_deploy = slow_flow.to_deployment(name="sleeper", interval=45)
fast_deploy = fast_flow.to_deployment(name="fast")
serve(slow_deploy, fast_deploy)
I get errors about Result of async function call is not used
and
Argument of type "Coroutine[Any, Any, RunnerDeployment]" cannot be assigned to parameter "args" of type "RunnerDeployment" in function "serve"
"Coroutine[Any, Any, RunnerDeployment]" is incompatible with "RunnerDeployment"
Is this the recommended way to fix it?
import time
from prefect import flow, serve
import asyncio
@flow
def slow_flow(sleep: int = 60):
"Sleepy flow - sleeps the provided amount of time (in seconds)."
time.sleep(sleep)
@flow
def fast_flow():
"Fastest flow this side of the Mississippi."
return
async def deploy_flows():
slow_deploy = await slow_flow.to_deployment(name="sleeper", interval=45)
fast_deploy = await fast_flow.to_deployment(name="fast")
await serve(slow_deploy, fast_deploy)
if __name__ == "__main__":
asyncio.run(deploy_flows())
Nate
04/29/2024, 8:55 PMprefect version
⢠the entire stack trace?
thank you!Patrick Wspanialy
04/29/2024, 8:59 PMNate
04/29/2024, 9:00 PM