Comparing the Methods

This section consists of examples of each way to create conditions to illustrate the similarities and differences.

Logic

String syntax

@app.task('true')
def do_constantly():
    ...

@app.task('false')
def do_never():
    ...

@app.task('true & false')
def do_and():
    ...

@app.task('true | false')
def do_or():
    ...

@app.task('~false')
def do_not():
    ...

@app.task('(true | false) & ~(true | false)')
def do_nested():
    ...

Condition API

from rocketry.conds import true, false

@app.task(true)
def do_constantly():
    ...

@app.task(false)
def do_never():
    ...

@app.task(true & false)
def do_and():
    ...

@app.task(true | false)
def do_or():
    ...

@app.task(~false)
def do_not():
    ...

@app.task((true | false) & ~(true | false))
def do_nested():
    ...

Periodical Scheduling

String syntax

@app.task('minutely')
def do_minutely():
    ...

@app.task('hourly')
def do_hourly():
    ...

@app.task('daily')
def do_daily():
    ...

@app.task('weekly')
def do_weekly():
    ...

@app.task('monthly')
def do_monthly():
    ...

Condition API

from rocketry.conds import minutely, hourly, daily, weekly, monthly

@app.task(minutely)
def do_minutely():
    ...

@app.task(hourly)
def do_hourly():
    ...

@app.task(daily)
def do_daily():
    ...

@app.task(weekly)
def do_weekly():
    ...

@app.task(monthly)
def do_monthly():
    ...

Periodical Restricted Scheduling

String syntax

@app.task("minutely before 45")
def do_minutely():
    ...

@app.task("hourly after 45:00")
def do_hourly():
    ...

@app.task("daily between 08:00 and 14:00")
def do_daily():
    ...

@app.task("weekly on Monday")
def do_weekly():
    ...

@app.task("monthly starting 3rd")
def do_monthly():
    ...

Condition API

from rocketry.conds import minutely, hourly, daily, weekly, monthly

@app.task(minutely.before("45"))
def do_before():
    ...

@app.task(hourly.after("45:00"))
def do_after():
    ...

@app.task(daily.between("08:00", "14:00"))
def do_between():
    ...

@app.task(daily.at("11:00"))
def do_at():
    ...

@app.task(weekly.on("Monday"))
def do_on():
    ...

@app.task(monthly.starting("3rd"))
def do_starting():
    ...

Piping

String syntax

@app.task()
def do_things():
    ...

@app.task("after task 'do_things'")
def do_after_success():
    ...

@app.task("after task 'do_things' succeeded")
def do_after_success_2():
    ...

@app.task("after task 'do_things' failed")
def do_after_fail():
    ...

@app.task("after task 'do_things' finished")
def do_after_fail_or_success():
    ...

Condition API

from rocketry.conds import after_success, after_fail, after_finish

@app.task()
def do_things():
    ...

@app.task(after_success(do_things))
def do_after_success():
    ...

@app.task(after_fail(do_things))
def do_after_fail():
    ...

@app.task(after_finish(do_things))
def do_after_fail_or_success():
    ...

Piping Multiple

String syntax

@app.task()
def do_a():
    ...

@app.task()
def do_b():
    ...


@app.task("after tasks 'do_a', 'do_b' succeeded")
def do_all_succeeded():
    ...

@app.task("after any tasks 'do_a', 'do_b' succeeded")
def do_any_succeeded():
    ...

@app.task("after any tasks 'do_a', 'do_b' failed")
def do_any_failed():
    ...

@app.task("after any tasks 'do_a', 'do_b' finished")
def do_any_failed_or_succeeded():
    ...

Condition API

from rocketry.conds import after_all_success, after_any_success, after_any_finish, after_any_fail

@app.task()
def do_a():
    ...

@app.task()
def do_b():
    ...


@app.task(after_all_success(do_a, do_b))
def do_all_succeeded():
    ...

@app.task(after_any_success(do_a, do_b))
def do_any_succeeded():
    ...

@app.task(after_any_fail(do_a, do_b))
def do_any_failed():
    ...

@app.task(after_any_finish(do_a, do_b))
def do_any_failed_or_succeeded():
    ...