GOWRAV TATA
06/06/2023, 7:04 AMJake Kaplan
06/06/2023, 12:57 PM$ prefect server start
The prefect scheduler runs as part of that server, which creates flow runs from deploymentsGOWRAV TATA
06/06/2023, 1:03 PMJake Kaplan
06/06/2023, 1:11 PMJake Kaplan
06/06/2023, 1:25 PMGOWRAV TATA
06/06/2023, 1:30 PMJake Kaplan
06/06/2023, 1:33 PMimport os
from datetime import timedelta
from prefect import flow, task
from prefect.server.schemas.schedules import IntervalSchedule
from prefect.deployments import Deployment
@task
def hello(server):
print('hello', server)
@flow
def transformation_one():
hello('one')
@flow
def transformation_two():
hello('two')
@flow
def transformation_three():
hello('three')
transformation_one_deployment = Deployment.build_from_flow(
flow=transformation_one,
name="reporting_server-flow_one",
schedule=IntervalSchedule(interval=timedelta(seconds=30))
)
transformation_two_deployment = Deployment.build_from_flow(
flow=transformation_two,
name="reporting_server-flow_two",
schedule=IntervalSchedule(interval=timedelta(seconds=30)),
)
transformation_three_deployment = Deployment.build_from_flow(
flow=transformation_three,
name="reporting_server-flow_three",
schedule=IntervalSchedule(interval=timedelta(seconds=30))
)
if __name__ == "__main__":
transformation_one_deployment.apply()
transformation_two_deployment.apply()
transformation_three_deployment.apply()
you should see 3 deployments createdJake Kaplan
06/06/2023, 1:33 PMJake Kaplan
06/06/2023, 1:34 PMprefect server start
in another process, the scheduler will generate scheduled flow runs for your deploymentsJake Kaplan
06/06/2023, 1:34 PMJake Kaplan
06/06/2023, 1:35 PMDeployments
you'll need either the prefect server running to run the scheduler OR use a prefect cloud workspace (cloud has it's own scheduler etc.)Jake Kaplan
06/06/2023, 1:36 PMprefect agent start
to pick up those runsGOWRAV TATA
06/07/2023, 5:19 AM