Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose conditions #44

Merged
merged 53 commits into from
Jul 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
779f969
add: exposed daily, weekly etc.
Miksus Jul 7, 2022
f6353d6
Merge branch 'master' into dev/expose_conds
Miksus Jul 9, 2022
52bdaff
fix: import
Miksus Jul 9, 2022
913f717
add: the time period itself to parser (ie. daily)
Miksus Jul 9, 2022
70c356c
upd: Now conditions work with new-style params
Miksus Jul 9, 2022
488ba97
upd: FuncTask to use the same param method
Miksus Jul 9, 2022
0bf129a
upd: scheduler and tasks to use new cond style
Miksus Jul 9, 2022
cb934ae
upd: changed some conds to use the new style
Miksus Jul 9, 2022
8caa633
fix: args with the new cond style
Miksus Jul 9, 2022
44528cb
upd: task conds to use the new style
Miksus Jul 9, 2022
c13c8c7
upd: cond parsing with the new style
Miksus Jul 9, 2022
ea474a5
test: fix tests with new-style conditions
Miksus Jul 9, 2022
ebe1b52
test: removed unnecessary task in a cond
Miksus Jul 9, 2022
c42d588
test: fix string parsing for some new-style conds
Miksus Jul 9, 2022
f80c542
upd: commented out statement default setting
Miksus Jul 9, 2022
dd15c62
rem: Removed Condition metaclass
Miksus Jul 10, 2022
2fc654c
fix: BaseCondition __eq__
Miksus Jul 10, 2022
4977def
fix: better BaseComparable __eq__
Miksus Jul 10, 2022
88f2154
fix: BaseComparable get_state magic
Miksus Jul 10, 2022
4e0d0b3
fix: missing task and session in FuncTask params
Miksus Jul 10, 2022
903094f
fix: Statements kwargs to simple attrs
Miksus Jul 10, 2022
7075e3a
fix: TaskExecutable isin_period
Miksus Jul 10, 2022
98c3deb
add: rocketry.conds subpackage
Miksus Jul 10, 2022
8365b78
upd: imports to rocketry.conds
Miksus Jul 10, 2022
0f7de4c
fix: Statement style kwargs to new style
Miksus Jul 10, 2022
51e6def
upd: string parsing now under rocketry.parse
Miksus Jul 10, 2022
180a63e
fix: SchedulerCycle parsing
Miksus Jul 10, 2022
c09b017
test: fix imports
Miksus Jul 10, 2022
2d80a4e
test: fix to new style conditions
Miksus Jul 10, 2022
c0c7c31
test: removed cond default tests
Miksus Jul 10, 2022
426c53f
rem: Condition parser attributes
Miksus Jul 10, 2022
3a19889
test: add test for rocketry.conds
Miksus Jul 10, 2022
6f90e86
fix: TaskCond missing key session
Miksus Jul 10, 2022
2fe5a00
rem: Statement, Comparable and Historical
Miksus Jul 10, 2022
63911b7
upd: now crash if fail in scheduler.shut_cond
Miksus Jul 10, 2022
f54b38c
fix: if scheduler shut_cond is None
Miksus Jul 10, 2022
af5857d
rem: removed unnecessary imports
Miksus Jul 10, 2022
c34a4ad
add: now cond API works with func references
Miksus Jul 10, 2022
b61468a
add: after any/all fail/success/finish to cond API
Miksus Jul 10, 2022
42b6289
upd: session handles if task referenced by func
Miksus Jul 11, 2022
4c61102
add: allow func cond to be referenced by the func
Miksus Jul 11, 2022
a6eff70
test: add return tests for func/task reference
Miksus Jul 11, 2022
71b0294
test: add more parse tests
Miksus Jul 11, 2022
f517a6e
test: add more API tests
Miksus Jul 11, 2022
a94057b
docs: updated code examples
Miksus Jul 11, 2022
cd4c493
docs: add handbook and conditions section
Miksus Jul 11, 2022
d9ac073
docs: updated conditions sections in tutorials
Miksus Jul 11, 2022
a63e84e
docs: updated intermediate tutorial, parametrizing
Miksus Jul 11, 2022
68b9a3d
test: change order of some session tasks
Miksus Jul 11, 2022
6fb3a0d
test: add session.__getitem__ tests
Miksus Jul 11, 2022
94cfd36
depr: Deprecated session.task_exists
Miksus Jul 11, 2022
309c64e
test: add task_exists test
Miksus Jul 11, 2022
3761e2b
docs: updated for 2.1.0 about conditions
Miksus Jul 11, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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