Skip to content

Commit

Permalink
Merge pull request #44 from Miksus/dev/expose_conds
Browse files Browse the repository at this point in the history
Expose conditions, easy task reference, refactor conditions & docs handbook
  • Loading branch information
Miksus authored Jul 11, 2022
2 parents 766fd57 + 3761e2b commit d43c9d3
Show file tree
Hide file tree
Showing 83 changed files with 1,962 additions and 891 deletions.
21 changes: 21 additions & 0 deletions docs/code/conds/api/every.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
from rocketry.conds import every

@app.task(every('10 seconds'))
def do_constantly():
...

@app.task(every('1 minute'))
def do_minutely():
...

@app.task(every('1 hour'))
def do_hourly():
...

@app.task(every('1 day'))
def do_daily():
...

@app.task(every('2 days 2 hours 20 seconds'))
def do_custom():
...
25 changes: 25 additions & 0 deletions docs/code/conds/api/logic.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
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():
...
21 changes: 21 additions & 0 deletions docs/code/conds/api/periodical.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
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():
...
21 changes: 21 additions & 0 deletions docs/code/conds/api/periodical_restricted.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
from rocketry.conds import minutely, hourly, daily, weekly, monthly

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

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

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

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

@app.task(monthly.starting("3rd"))
def do_monthly():
...
26 changes: 26 additions & 0 deletions docs/code/conds/api/pipe_multiple.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
from rocketry.conds import after_all_success, after_any_success, after_any_finish

@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():
...
17 changes: 17 additions & 0 deletions docs/code/conds/api/pipe_single.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
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():
...
12 changes: 12 additions & 0 deletions docs/code/conds/api/pipe_with_return.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from rocketry.conds import daily, after_success
from rocketry.args import Return

@app.task(daily)
def do_first():
...
return 'Hello World'

@app.task(after_success(do_first))
def do_second(arg=Return(do_first)):
# arg's value is "Hello World"
...
25 changes: 25 additions & 0 deletions docs/code/conds/api/simple.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
from rocketry.conds import (
every, hourly, daily,
after_success,
true, false
)

@app.task(every('10 seconds'))
def do_constantly():
...

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

@app.task(daily.between('08:00', '14:00'))
def do_daily():
...

@app.task(after_success(do_daily))
def do_after():
...

@app.task(true & false & ~(true | false))
def do_logic():
...
17 changes: 17 additions & 0 deletions docs/code/conds/api/time_of.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from rocketry.conds import time_of_minute, time_of_hour, time_of_day, time_of_week, time_of_month

@app.task(time_of_minute.before("45"))
def do_constantly_minute_before():
...

@app.task(time_of_hour.after("45:00"))
def do_constantly_hour_after():
...

@app.task(time_of_day.between("08:00", "14:00"))
def do_constantly_day_between():
...

@app.task(time_of_week.on("Monday"))
def do_constantly_week_on():
...
File renamed without changes.
23 changes: 23 additions & 0 deletions docs/code/conds/syntax/logic.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
@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():
...
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
@app.task('minutely')
def do_minutely():
...

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

@app.task('daily')
def do_daily():
...
Expand Down
19 changes: 19 additions & 0 deletions docs/code/conds/syntax/periodical_restricted.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
@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():
...
24 changes: 24 additions & 0 deletions docs/code/conds/syntax/pipe_multiple.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
@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():
...
19 changes: 19 additions & 0 deletions docs/code/conds/syntax/pipe_single.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
@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():
...
11 changes: 11 additions & 0 deletions docs/code/conds/syntax/pipe_with_return.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from rocketry.args import Return

@app.task("daily")
def do_first():
...
return 'Hello World'

@app.task("after task 'do_first'")
def do_second(arg=Return('do_first')):
# arg's value is "Hello World"
...
19 changes: 19 additions & 0 deletions docs/code/conds/syntax/simple.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
@app.task('every 10 seconds')
def do_constantly():
...

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

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

@app.task("after task 'do_daily'")
def do_after():
...

@app.task('true & false & ~(true | false)')
def do_logic():
...
15 changes: 15 additions & 0 deletions docs/code/conds/syntax/time_of.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
@app.task("time of minute before 45")
def do_constantly_minute_before():
...

@app.task("time of hour after 45:00")
def do_constantly_hour_after():
...

@app.task("time of day between 08:00 and 14:00")
def do_constantly_day_between():
...

@app.task("time of week on Monday")
def do_constantly_week_on():
...
3 changes: 3 additions & 0 deletions docs/code/naming.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@app.task(name="mytask")
def do_things():
...
11 changes: 11 additions & 0 deletions docs/code/params/return.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from rocketry.args import Return

@app.task()
def do_first():
...
return 'Hello World'

@app.task()
def do_second(arg=Return(do_first)):
# arg's value is "Hello World"
...
Loading

0 comments on commit d43c9d3

Please sign in to comment.