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

More pylint fixes #133

Merged
merged 19 commits into from
Nov 20, 2022
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
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
4 changes: 4 additions & 0 deletions Contributors.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Contributors

Mikael Koli - creator of Rocketry
Mark Mayo - fixes
1 change: 0 additions & 1 deletion docs/code/conds/api/cron.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,3 @@ def do_minutely():
@app.task(cron('*/2 12-18 * Oct Fri'))
def do_complex():
"Run at every 2nd minute past every hour from 12 through 18 on Friday in October."
...
marksmayo marked this conversation as resolved.
Show resolved Hide resolved
3 changes: 1 addition & 2 deletions docs/code/conds/api/cron_kwargs.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
@app.task(cron(minute="*/5"))
def do_simple():
"Run at every 5th minute"
...

marksmayo marked this conversation as resolved.
Show resolved Hide resolved

@app.task(cron(minute="*/2", hour="7-18", day_of_month="1,2,3", month="Feb-Aug/2"))
def do_complex():
Expand All @@ -13,4 +13,3 @@ def do_complex():
- On 1st, 2nd and 3rd day of month
- From February to August every second month
"""
...
marksmayo marked this conversation as resolved.
Show resolved Hide resolved
1 change: 0 additions & 1 deletion docs/code/conds/api/crontime.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,3 @@ def do_minutely():
@app.task(crontime('*/2 12-18 * Oct Fri'))
def do_complex():
"Run at every 2nd minute past every hour from 12 through 18 on Friday in October."
...
marksmayo marked this conversation as resolved.
Show resolved Hide resolved
3 changes: 1 addition & 2 deletions docs/code/conds/api/crontime_kwargs.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
@app.task(crontime(minute="*/5"))
def do_simple():
"Run at every 5th minute"
...
marksmayo marked this conversation as resolved.
Show resolved Hide resolved


@app.task(crontime(minute="*/2", hour="7-18", day_of_month="1,2,3", month="Feb-Aug/2"))
def do_complex():
Expand All @@ -13,4 +13,3 @@ def do_complex():
- On 1st, 2nd and 3rd day of month
- From February to August every second month
"""
...
marksmayo marked this conversation as resolved.
Show resolved Hide resolved
1 change: 0 additions & 1 deletion docs/code/conds/api/pipe_with_return.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

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

@app.task(after_success(do_first))
Expand Down
4 changes: 2 additions & 2 deletions docs/code/conds/api/task_running.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ def do_if_runs_less_than():

@app.task(running(do_things).between("2 mins", "5 mins"))
def do_if_runs_between():
...
# Starts if do_things is running
...
# Starts if do_things is running
# less than 2 mins but no more than 5 minutes
4 changes: 2 additions & 2 deletions docs/code/conds/api/task_running_multi.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

@app.task(running <= 4, multilanch=True)
def do_parallel_limited():
... # Allows 4 parallel runs
... # Allows 4 parallel runs

@app.task(~running, multilanch=True)
def do_non_parallel():
... # Allows no parallel runs

@app.task(running(do_parallel_limited) >= 2)
def do_if_runs_parallel():
... # Runs if the other has at least two parallel runs
... # Runs if the other has at least two parallel runs
2 changes: 1 addition & 1 deletion docs/code/conds/syntax/pipe_with_return.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

@app.task("daily")
def do_first():
...

return 'Hello World'

@app.task("after task 'do_first'")
Expand Down
6 changes: 3 additions & 3 deletions docs/code/demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,19 @@
@app.task('daily')
def do_daily():
"This function runs once a day"
...
marksmayo marked this conversation as resolved.
Show resolved Hide resolved


@app.task('daily between 07:00 and 10:00 | daily between 16:00 and 20:00')
def do_twice_a_day():
"This function runs twice a day (in the morning and in the afternoon)"
# The '|' means OR operator. Fully supports logical operations.
...
marksmayo marked this conversation as resolved.
Show resolved Hide resolved


@app.task("after task 'do_daily'")
def do_after_another(arg=Return('do_daily')):
"Run after 'do_daily' task"
# The parameter 'arg' has the return value of the function 'do_daily'
...
marksmayo marked this conversation as resolved.
Show resolved Hide resolved


if __name__ == "__main__":
# Start the scheduler
Expand Down
9 changes: 3 additions & 6 deletions docs/code/demos/advanced.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
@app.cond('is foo')
def is_foo():
# This is a custom condition
...

return True

# Parameters
Expand All @@ -20,7 +20,7 @@ def is_foo():
@app.param('item')
def get_item():
# This is a custom condition
...

return 'world'

# Tasks
Expand All @@ -29,7 +29,7 @@ def get_item():
@app.task('daily', execution="process")
def do_on_process():
"This task runs once a day and runs on separate process"
...

return ...

@app.task("after task 'do_things'")
Expand All @@ -40,18 +40,15 @@ def do_pipeline(arg1=Return('do_on_process'),
Argument 'arg1' gets the return value of 'do_on_process'
Argument 'arg2' gets the return value of function 'get_item'
Argument 'arg3' is simply the value of a session parameter 'my_arg'"""
...
marksmayo marked this conversation as resolved.
Show resolved Hide resolved

@app.task('daily & is foo', execution="thread")
def do_custom():
"""This task runs once a day and when is_foo returns True
This task runs on separate thread"""
...
marksmayo marked this conversation as resolved.
Show resolved Hide resolved

@app.task('(true & true) | (false & True & ~True)')
def do_complex():
"""Notice the logical expression in the task start condition"""
...
marksmayo marked this conversation as resolved.
Show resolved Hide resolved

if __name__ == "__main__":
app.run()
8 changes: 3 additions & 5 deletions docs/code/demos/intermediate.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,33 +7,31 @@
@app.cond()
def is_foo():
"This is a custom condition"
...
marksmayo marked this conversation as resolved.
Show resolved Hide resolved
return True

@app.task(daily & is_foo)
def do_daily():
"This task runs once a day when foo is true"
...
marksmayo marked this conversation as resolved.
Show resolved Hide resolved
return ...

@app.task((daily.at("10:00") | daily.at("19:00")) & time_of_week.between("Mon", "Fri"),
execution="process")
def do_complex():
"This task runs on complex interval and on separate process"
...
marksmayo marked this conversation as resolved.
Show resolved Hide resolved

return ...


@app.task(after_success(do_daily))
def do_after_another(arg=Return(do_daily)):
"""This task runs after 'do_daily' and it has its the
return argument as an input"""
...
marksmayo marked this conversation as resolved.
Show resolved Hide resolved


@app.task(daily)
def do_with_params(arg1=FuncArg(lambda: ...), arg2=Arg("myparam")):
"""This task runs with variety of arguments"""
...
marksmayo marked this conversation as resolved.
Show resolved Hide resolved


@app.task(daily, execution="thread")
def do_on_session(session=Session()):
Expand Down
2 changes: 1 addition & 1 deletion docs/code/demos/minimal_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ async def do_things():
async def main():
"Launch Rocketry app (and possibly something else)"
rocketry_task = asyncio.create_task(app.serve())
... # Start possibly other async apps
# Start possibly other async apps
await rocketry_task

if __name__ == "__main__":
Expand Down
6 changes: 3 additions & 3 deletions docs/code/parameter/parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,20 @@

@app.task("every 10 seconds")
def do_things(arg=Arg('my_arg')):
...

# Argument 'arg' has value 'hello'
assert arg == 'hello'
return 'stuff'

@app.task("after task 'do_things'")
def do_with_return(arg=Return('do_things')):
...

# Argument 'arg' is the return value of the task 'do_things'
assert arg == 'stuff'

@app.task("after task 'do_things'")
def do_with_funcarg(arg=FuncArg(lambda: 'hello world')):
...

# Argument 'arg' is the return value of the task 'do_things'
assert arg == 'stuff'

Expand Down
6 changes: 3 additions & 3 deletions docs/code/parameter/pipelining.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@

@app.task("every 10 seconds")
def do_things():
...

return 'hello'

@app.task("after task 'do_things'")
def do_after(arg=Return('do_things')):
...

assert arg == 'hello'
return 'world'

@app.task("after task 'do_things', 'do_stuff'")
def do_after_all(arg1=Return('do_things'), arg2=Return('do_stuff')):
...

assert arg1 == 'hello'
assert arg2 == 'world'
2 changes: 1 addition & 1 deletion docs/code/params/return.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

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

return 'Hello World'

@app.task()
Expand Down
2 changes: 1 addition & 1 deletion docs/code/snippets/custom_condition.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def file_exists(file):
@app.task(daily & file_exists("data.csv"))
def do_things():
"Task that runs once a day when data.csv exists"
...
marksmayo marked this conversation as resolved.
Show resolved Hide resolved


if __name__ == "__main__":
app.run()
4 changes: 2 additions & 2 deletions docs/code/snippets/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@

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

return 'Hello World'

@app.task(after_success(do_first))
def do_second(arg=Return(do_first)):
...

return 'Hello Python'
2 changes: 1 addition & 1 deletion rocketry/args/builtin.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def get_value(self, task=None, session=None, **kwargs) -> Any:
return task.session

def __repr__(self):
return f'session'
return 'session'

class Task(BaseArgument):
"An argument that represents a task"
Expand Down
5 changes: 2 additions & 3 deletions rocketry/conditions/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,16 +138,15 @@ def observe(self, **kwargs):
def __call__(self, task=None, more_than=None, less_than=None):
if more_than is not None or less_than is not None or task is None:
warnings.warn(
"running(more_than=..., less_than=...) and running() are derpecated. "
"running(more_than=..., less_than=...) and running() are derpecated. "
"Please use running.more_than, running.less_than, running.between or just running instead.",
DeprecationWarning
)
period = None
if more_than is not None or less_than is not None:
period = TimeSpanDelta(near=more_than, far=less_than)
return TaskRunning(task=task, period=period)
else:
return RunningWrapper(task)
return RunningWrapper(task)

def more_than(self, delta):
"Get condition the wrapper represents"
Expand Down
Loading