-
-
Notifications
You must be signed in to change notification settings - Fork 108
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #44 from Miksus/dev/expose_conds
Expose conditions, easy task reference, refactor conditions & docs handbook
- Loading branch information
Showing
83 changed files
with
1,962 additions
and
891 deletions.
There are no files selected for viewing
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
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(): | ||
... |
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
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(): | ||
... |
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
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(): | ||
... |
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
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(): | ||
... |
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
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(): | ||
... |
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
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(): | ||
... |
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
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" | ||
... |
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
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(): | ||
... |
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
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.
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
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(): | ||
... |
8 changes: 8 additions & 0 deletions
8
docs/code/schedule/fixed_period.py → docs/code/conds/syntax/periodical.py
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
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
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(): | ||
... |
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
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(): | ||
... |
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
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(): | ||
... |
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
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" | ||
... |
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
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(): | ||
... |
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
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(): | ||
... |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
@app.task(name="mytask") | ||
def do_things(): | ||
... |
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
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" | ||
... |
Oops, something went wrong.