Last active
June 27, 2022 15:23
-
-
Save biancarosa/530f84588d44fbfc10dab706673b72b3 to your computer and use it in GitHub Desktop.
dagit scheduler to generate a random number based on an arg
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
from dagster import job, op, schedule, RunRequest, ScheduleEvaluationContext, repository | |
@op(config_schema={"number": int}) | |
def random_number(context): | |
context.log.info(context.op_config["number"]) | |
return context.op_config["number"] + 1 | |
@job | |
def do_stuff(): | |
random_number() | |
@schedule(job=do_stuff, cron_schedule="0 0 * * *") | |
def configurable_job_schedule(context: ScheduleEvaluationContext): | |
import random | |
n = random.choice(range(1,100)) | |
return RunRequest( | |
run_key=None, | |
run_config={ | |
"ops": {"configurable_op": {"config": {"number": n}}} | |
}, | |
tags={"number": n}, | |
default_status=DefaultScheduleStatus.RUNNING | |
) | |
@repository | |
def my_repo(): | |
return [do_stuff, configurable_job_schedule] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment