https://prefect.io logo
j

justabill

08/31/2023, 9:01 PM
deploy button Introducing
Flow.serve()
, the "it just works" way to deploy flows.
The new
Flow.serve()
method allows you to automatically create a flow deployment so that you can schedule or trigger runs via the Prefect UI and CLI. Check it out:
Copy code
python
from prefect import flow

@flow
def hello(name = "Marvin"):
    print(f"Hello {name}!")

if __name__ == "__main__":
    # Creates a deployment named 'hello/hourly-greeting'
    # which will run the 'hello' flow once an hour
    hello.serve(name="hourly-greeting", interval=3600)
The script will stay running so that it can listen for scheduled or triggered runs of this flow; once a run is found, it will be executed within a subprocess.
Copy code
> python hello.py
╭─────────────────────────────────────────────────────────────────────────────────────╮
│ Your flow 'hello' is being served and polling for scheduled runs!                   │
│                                                                                     │
│ To trigger a run for this flow, use the following command:                          │
│                                                                                     │
│         $ prefect deployment run 'hello/hourly-greeting'                            │
│                                                                                     │
╰─────────────────────────────────────────────────────────────────────────────────────╯
To start serving your flows, check out our newly updated quickstart and tutorial.
🙌 15