|
| 1 | +<a href="https://pytask-dev.readthedocs.io/en/stable"> |
| 2 | + <p align="center"> |
| 3 | + <img src="https://raw.githubusercontent.com/pytask-dev/pytask/main/docs/source/_static/images/pytask_w_text.png" width=50% alt="pytask"> |
| 4 | + </p> |
| 5 | +</a> |
| 6 | + |
| 7 | +------------------------------------------------------------------------ |
| 8 | + |
| 9 | +<!-- Keep in sync with docs/source/index.md --> |
| 10 | + |
| 11 | +[](https://pypi.org/project/pytask) |
| 12 | +[](https://pypi.org/project/pytask) |
| 13 | +[](https://anaconda.org/conda-forge/pytask) |
| 14 | +[](https://anaconda.org/conda-forge/pytask) |
| 15 | +[](https://pypi.org/project/pytask) |
| 16 | +[](https://pytask-dev.readthedocs.io/en/stable) |
| 17 | +[](https://github.com/pytask-dev/pytask/actions?query=branch%3Amain) |
| 18 | +[](https://codecov.io/gh/pytask-dev/pytask) |
| 19 | +[](https://results.pre-commit.ci/latest/github/pytask-dev/pytask/main) |
| 20 | +[](https://github.com/psf/black) |
| 21 | + |
| 22 | +<!-- Keep in sync with docs/source/index.md --> |
| 23 | + |
| 24 | +In its highest aspirations, pytask tries to be pytest as a build system. It\'s main |
| 25 | +purpose is to facilitate reproducible research by automating workflows in research |
| 26 | +projects. Its features include: |
| 27 | + |
| 28 | +- **Automatic discovery of tasks.** |
| 29 | +- **Lazy evaluation.** If a task, its dependencies, and its products have not changed, |
| 30 | + do not execute it. |
| 31 | +- **Debug mode.** [Jump into the |
| 32 | + debugger](https://pytask-dev.readthedocs.io/en/stable/tutorials/how_to_debug.html) if |
| 33 | + a task fails, get feedback quickly, and be more productive. |
| 34 | +- **Repeat a task with different inputs.** [Loop over task |
| 35 | + functions](https://pytask-dev.readthedocs.io/en/stable/tutorials/repeating_tasks_with_different_inputs.html) |
| 36 | + to run the same task with different inputs. |
| 37 | +- **Select tasks via expressions.** Run only a subset of tasks with [expressions and |
| 38 | + marker |
| 39 | + expressions](https://pytask-dev.readthedocs.io/en/stable/tutorials/selecting_tasks.html) |
| 40 | + known from pytest. |
| 41 | +- **Easily extensible with plugins**. pytask is built on top of |
| 42 | + [pluggy](https://pluggy.readthedocs.io/en/latest/), a plugin management framework, |
| 43 | + which allows you to adjust pytask to your needs. Plugins are available for |
| 44 | + [parallelization](https://github.com/pytask-dev/pytask-parallel), |
| 45 | + [LaTeX](https://github.com/pytask-dev/pytask-latex), |
| 46 | + [R](https://github.com/pytask-dev/pytask-r), and |
| 47 | + [Stata](https://github.com/pytask-dev/pytask-stata) and more can be found |
| 48 | + [here](https://github.com/topics/pytask). Read in [this |
| 49 | + tutorial](https://pytask-dev.readthedocs.io/en/stable/tutorials/how_to_use_plugins.html) |
| 50 | + how to use and create plugins with a |
| 51 | + [cookiecutter](https://github.com/pytask-dev/cookiecutter-pytask-plugin). |
| 52 | + |
| 53 | +# Installation |
| 54 | + |
| 55 | +<!-- Keep in sync with docs/source/tutorials/installation.md --> |
| 56 | + |
| 57 | +pytask is available on [PyPI](https://pypi.org/project/pytask) and on |
| 58 | +[Anaconda.org](https://anaconda.org/conda-forge/pytask). Install the package with |
| 59 | + |
| 60 | +```console |
| 61 | +$ pip install pytask |
| 62 | +``` |
| 63 | + |
| 64 | +or |
| 65 | + |
| 66 | +```console |
| 67 | +$ conda install -c conda-forge pytask |
| 68 | +``` |
| 69 | + |
| 70 | +Color support is automatically available on non-Windows platforms. On Windows, please, |
| 71 | +use [Windows Terminal](https://github.com/microsoft/terminal) which can be, for example, |
| 72 | +installed via the [Microsoft Store](https://aka.ms/terminal). |
| 73 | + |
| 74 | +To quickly set up a new project, use the |
| 75 | +[cookiecutter-pytask-project](https://github.com/pytask-dev/cookiecutter-pytask-project) |
| 76 | +template or start from [other templates or example |
| 77 | +projects](https://pytask-dev.readthedocs.io/en/stable/how_to_guides/bp_templates_and_projects.html). |
| 78 | + |
| 79 | +# Usage |
| 80 | + |
| 81 | +A task is a function which is detected if the module and the function name are prefixed |
| 82 | +with `task_`. Here is an example. |
| 83 | + |
| 84 | +```python |
| 85 | +# Content of task_hello.py. |
| 86 | + |
| 87 | +import pytask |
| 88 | + |
| 89 | + |
| 90 | +@pytask.mark.produces("hello_earth.txt") |
| 91 | +def task_hello_earth(produces): |
| 92 | + produces.write_text("Hello, earth!") |
| 93 | +``` |
| 94 | + |
| 95 | +Here are some details: |
| 96 | + |
| 97 | +- Dependencies and products of a task are tracked via markers. For dependencies use |
| 98 | + `@pytask.mark.depends_on` and for products use `@pytask.mark.produces`. Use strings |
| 99 | + and `pathlib.Path` to specify the location. Pass multiple dependencies or products |
| 100 | + as a list or a dictionary for positional or key-based access. |
| 101 | +- With `produces` (and `depends_on`) as function arguments, you get access to the |
| 102 | + dependencies and products inside the function via `pathlib.Path` objects. Here, |
| 103 | + `produces` holds the path to `"hello_earth.txt"`. |
| 104 | + |
| 105 | +To execute the task, enter `pytask` on the command-line |
| 106 | + |
| 107 | + |
| 108 | + |
| 109 | +# Documentation |
| 110 | + |
| 111 | +The documentation can be found under <https://pytask-dev.readthedocs.io/en/stable> with |
| 112 | +[tutorials](https://pytask-dev.readthedocs.io/en/stable/tutorials/index.html) and guides |
| 113 | +for [best |
| 114 | +practices](https://pytask-dev.readthedocs.io/en/stable/how_to_guides/index.html). |
| 115 | + |
| 116 | +# Changes |
| 117 | + |
| 118 | +Consult the [release notes](https://pytask-dev.readthedocs.io/en/stable/changes.html) to |
| 119 | +find out about what is new. |
| 120 | + |
| 121 | +# License |
| 122 | + |
| 123 | +pytask is distributed under the terms of the [MIT license](LICENSE). |
| 124 | + |
| 125 | +# Acknowledgment |
| 126 | + |
| 127 | +The license also includes a copyright and permission notice from pytest since some |
| 128 | +modules, classes, and functions are copied from pytest. Not to mention how pytest has |
| 129 | +inspired the development of pytask in general. Without the amazing work of Holger Krekel |
| 130 | +and pytest\'s many contributors, this project would not have been possible. Thank you! |
| 131 | + |
| 132 | +# Citation |
| 133 | + |
| 134 | +If you rely on pytask to manage your research project, please cite it with the following |
| 135 | +key to help others to discover the tool. |
| 136 | + |
| 137 | +```bibtex |
| 138 | +@Unpublished{Raabe2020, |
| 139 | + Title = {A Python tool for managing scientific workflows.}, |
| 140 | + Author = {Tobias Raabe}, |
| 141 | + Year = {2020}, |
| 142 | + Url = {https://github.com/pytask-dev/pytask} |
| 143 | +} |
| 144 | +``` |
0 commit comments