Miksus / rocketry

Modern scheduling library for Python
https://rocketry.readthedocs.io
MIT License
3.25k stars 105 forks source link

ENH: App config #140

Closed Miksus closed 1 year ago

Miksus commented 1 year ago

This PR should make the configuring and setting up the app more obvious.

This PR includes:

Now the app should be configured:

from rocketry.args import TaskLogger
from rocketry.log import LogRecord
from redbird.repos import MemoryRepo

@app.setup()
def set_repo(logger=TaskLogger()):
    logger.set_repo(MemoryRepo(model=LogRecord))

Moreover, the func conditions and func arguments are now more intuitive if the app is in a different file.

For example, let's say this is components.py:

from rocketry.args import argument
from rocketry.conds import condition

@argument()
def report_date(file):
    return "2022-11-26"

@condition()
def is_foo():
    return True or False

Then in main.py:

from rocketry import Rocketry
from components import report_date, is_foo

app = Rocketry()

@app.task(is_foo)
def do_things(arg=report_date):
    ...
codecov-commenter commented 1 year ago

Codecov Report

Base: 94.87% // Head: 94.90% // Increases project coverage by +0.03% :tada:

Coverage data is based on head (827d0b6) compared to base (551de45). Patch coverage: 98.50% of modified lines in pull request are covered.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #140 +/- ## ========================================== + Coverage 94.87% 94.90% +0.03% ========================================== Files 80 80 Lines 4466 4515 +49 ========================================== + Hits 4237 4285 +48 - Misses 229 230 +1 ``` | [Impacted Files](https://codecov.io/gh/Miksus/rocketry/pull/140?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Mikael+Koli) | Coverage Δ | | |---|---|---| | [rocketry/conds/\_\_init\_\_.py](https://codecov.io/gh/Miksus/rocketry/pull/140/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Mikael+Koli#diff-cm9ja2V0cnkvY29uZHMvX19pbml0X18ucHk=) | `100.00% <ø> (ø)` | | | [rocketry/args/builtin.py](https://codecov.io/gh/Miksus/rocketry/pull/140/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Mikael+Koli#diff-cm9ja2V0cnkvYXJncy9idWlsdGluLnB5) | `98.18% <97.29%> (-0.33%)` | :arrow_down: | | [rocketry/application.py](https://codecov.io/gh/Miksus/rocketry/pull/140/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Mikael+Koli#diff-cm9ja2V0cnkvYXBwbGljYXRpb24ucHk=) | `100.00% <100.00%> (ø)` | | | [rocketry/conditions/api.py](https://codecov.io/gh/Miksus/rocketry/pull/140/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Mikael+Koli#diff-cm9ja2V0cnkvY29uZGl0aW9ucy9hcGkucHk=) | `98.38% <100.00%> (+0.02%)` | :arrow_up: | | [rocketry/conditions/task/task.py](https://codecov.io/gh/Miksus/rocketry/pull/140/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Mikael+Koli#diff-cm9ja2V0cnkvY29uZGl0aW9ucy90YXNrL3Rhc2sucHk=) | `93.87% <100.00%> (ø)` | | | [rocketry/conditions/task/utils.py](https://codecov.io/gh/Miksus/rocketry/pull/140/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Mikael+Koli#diff-cm9ja2V0cnkvY29uZGl0aW9ucy90YXNrL3V0aWxzLnB5) | `90.12% <100.00%> (ø)` | | | [rocketry/core/hook.py](https://codecov.io/gh/Miksus/rocketry/pull/140/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Mikael+Koli#diff-cm9ja2V0cnkvY29yZS9ob29rLnB5) | `100.00% <100.00%> (ø)` | | | [rocketry/core/log/adapter.py](https://codecov.io/gh/Miksus/rocketry/pull/140/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Mikael+Koli#diff-cm9ja2V0cnkvY29yZS9sb2cvYWRhcHRlci5weQ==) | `100.00% <100.00%> (ø)` | | | [rocketry/core/parameters/parameters.py](https://codecov.io/gh/Miksus/rocketry/pull/140/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Mikael+Koli#diff-cm9ja2V0cnkvY29yZS9wYXJhbWV0ZXJzL3BhcmFtZXRlcnMucHk=) | `97.00% <100.00%> (+0.09%)` | :arrow_up: | | [rocketry/core/schedule.py](https://codecov.io/gh/Miksus/rocketry/pull/140/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Mikael+Koli#diff-cm9ja2V0cnkvY29yZS9zY2hlZHVsZS5weQ==) | `93.50% <100.00%> (ø)` | | | ... and [1 more](https://codecov.io/gh/Miksus/rocketry/pull/140/diff?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Mikael+Koli) | | Help us with your feedback. Take ten seconds to tell us [how you rate us](https://about.codecov.io/nps?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Mikael+Koli). Have a feature suggestion? [Share it here.](https://app.codecov.io/gh/feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Mikael+Koli)

:umbrella: View full report at Codecov.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.