Created
January 12, 2022 22:05
-
-
Save cdeil/b8482ad18cbae12177f19b979b48c809 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""Prefect scheduling example in Orion""" | |
import datetime | |
import subprocess | |
from prefect import task, flow | |
from prefect.client import OrionClient | |
from prefect.deployments import DeploymentSpec, create_deployment_from_spec | |
from prefect.orion.services.scheduler import Scheduler | |
from prefect.orion.schemas.schedules import IntervalSchedule | |
@task | |
def say_hello(): | |
print("Hello, world!") | |
@flow(name="greetings") | |
def greetings_flow(): | |
print("greetings flow") | |
say_hello() | |
def main(): | |
schedule = IntervalSchedule(interval=datetime.timedelta(seconds=10)) | |
deployment_spec = DeploymentSpec(name="hola", flow=greetings_flow, schedule=schedule) | |
client = OrionClient() | |
deployment_id = create_deployment_from_spec(spec=deployment_spec, client=client) | |
subprocess.run("prefect orion start", shell=True) | |
# Not working yet: | |
# deployment = client.create_deployment(deployment_spec) | |
# client.create_flow_run_from_deployment(deployment_spec) | |
# greetings_flow() | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment