Wayne Lai
02/28/2024, 1:32 PMMarvin
02/28/2024, 1:33 PMpython
import asyncio
from prefect import flow
async def some_async_function():
await asyncio.sleep(1)
return "I'm an async function"
@flow(log_prints=True) # send `print` statements as INFO logs
async def my_async_workflow():
print("I can call any python code here, including prefect tasks or flows")
await some_async_function()
if __name__ == "__main__":
asyncio.run(my_async_workflow()) # run it like a normal async python function
# or serve it as a long-lived process
# my_async_workflow.serve("my-deployment-name")
Please note that this script includes async functions and can be deployed to a serverless push work pool. As for the required libraries that need to be in the requirements.txt
, you would typically list all your Python project's dependencies there, but for the Prefect-specific deployments, be sure to include 'prefect' and any other libraries that your specific tasks and flows are using.
You can find the full Prefect flow example at this link. Remember to replace "my-deployment-name"
with the name you intend to use for your deployment.Bring your towel and join one of the fastest growing data communities. Welcome to our second-generation open source orchestration platform, a completely rethought approach to dataflow automation.
Powered by