-
Notifications
You must be signed in to change notification settings - Fork 11
Implement a conditional skip marker #62
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
Merged
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
830887d
Add test for skip_if decorator for both the case where the condition …
roecla 3e81d2a
Implement skip_if decorator.
roecla 213aea4
Add documentation for skip and skip_if.
roecla 351eff1
Fix pre-commit complaints.
roecla eb39b3b
Fix CI.
tobiasraabe e4bafcc
Apply suggestions from code review
tobiasraabe 7b2b94b
Merge branch 'main' into skip-if-marker
tobiasraabe fc0b85e
fix.
tobiasraabe ef4cb24
Rename to skipif.
tobiasraabe 0f635ca
Merge branch 'main' into skip-if-marker
tobiasraabe 25abab4
Make reason mandatory.
tobiasraabe 38c84da
Any condition has to be fulfilled so that the task is skipped.
tobiasraabe ed814cf
Fix changes.
tobiasraabe b8e66ea
fix changes.
tobiasraabe 05f3a55
add better marker description.
tobiasraabe File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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,69 @@ | ||
How to skip tasks | ||
================= | ||
|
||
Tasks are skipped automatically if neither their file nor any of their dependencies have | ||
changed and all products exist. | ||
|
||
In addition, you may want pytask to skip tasks either generally or if certain conditions | ||
are fulfilled. Skipping means the task itself and all tasks that depend on it will not | ||
be executed, even if the task file or their dependencies have changed or products are | ||
missing. | ||
|
||
This can be useful for example if you are working on a task that creates the dependency | ||
of a long running task and you are not interested in the long running task's product for | ||
the moment. In that case you can simply use ``@pytask.mark.skip`` in front of the long | ||
running task to stop it from running: | ||
|
||
.. code-block:: python | ||
|
||
# Content of task_create_dependency.py | ||
|
||
|
||
@pytask.mark.produces("dependency_of_long_running_task.md") | ||
def task_you_are_working_on(produces): | ||
... | ||
|
||
.. code-block:: python | ||
|
||
# Content of task_long_running.py | ||
|
||
|
||
@pytask.mark.skip | ||
@pytask.mark.depends_on("dependency_of_long_running_task.md") | ||
def task_that_takes_really_long_to_run(depends_on): | ||
... | ||
|
||
|
||
In large projects, you may have many long running tasks that you only want to execute | ||
sporadically, e.g. when you are not working locally but running the project on a server. | ||
|
||
In that case, we recommend using ``@pytask.mark.skipif`` which lets you supply a | ||
condition and a reason as arguments: | ||
|
||
|
||
.. code-block:: python | ||
|
||
# Content of a config.py | ||
|
||
NO_LONG_RUNNING_TASKS = True | ||
|
||
.. code-block:: python | ||
|
||
# Content of task_create_dependency.py | ||
|
||
|
||
@pytask.mark.produces("run_always.md") | ||
def task_always(produces): | ||
... | ||
|
||
.. code-block:: python | ||
|
||
# Content of task_long_running.py | ||
|
||
from config import NO_LONG_RUNNING_TASKS | ||
|
||
|
||
@pytask.mark.skipif(NO_LONG_RUNNING_TASKS, "Skip long-running tasks.") | ||
@pytask.mark.depends_on("dependency_of_long_running_task.md") | ||
def task_that_takes_really_long_to_run(depends_on): | ||
... |
This file contains hidden or 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 hidden or 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 hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.