In its highest aspirations, pytask tries to be pytest as a build system.
In its highest aspirations, pytask tries to be pytest as a build system. It’s main purpose is to facilitate reproducible research by automating workflows in research projects. Its features include:
- Automatic discovery of tasks.
- Lazy evaluation. If a task, its dependencies, and its products have not changed, do not execute it.
- Debug mode. Jump into the debugger if a task fails, get feedback quickly, and be more productive.
- Select tasks via expressions. Run only a subset of tasks with expressions and marker expressions known from pytest.
- Easily extensible with plugins. pytask’s architecture is based on pluggy, a plugin management framework, so that you can adjust pytask to your needs. Plugins are, for example, available for parallelization, LaTeX, R, and Stata. Read here how you can use plugins.
$ pip install pytask # or $ conda install -c conda-forge pytask
A task is a function which is detected if the module and the function name are prefixed with task_. Here is an example.
# Content of task_hello.py. import pytask @pytask.mark.produces("hello_earth.txt") def task_hello_earth(produces): produces.write_text("Hello, earth!")
Here are some details:
- Dependencies and products of a task are tracked via markers. For dependencies use @pytask.mark.depends_on and for products use @pytask.mark.produces. Use strings and pathlib.Path to specify the location. Pass multiple dependencies or products as a list.
- With produces (and depends_on) as function arguments, you get access to the dependencies and products inside the function via pathlib.Path objects. Here, produces holds the path to "hello_earth.txt".
To execute the task, type the following command on the command-line
$ pytask ========================= Start pytask session ========================= Platform: linux -- Python 3.x.y, pytask 0.x.y, pluggy 0.x.y Root: xxx Collected 1 task(s). . ====================== 1 succeeded in 1 second(s) ======================
The demo walks you through the following steps.
- Write an executable script which produces a text file like you would normally do without pytask.
- Rewrite the script to a pytask task.
- Execute the task.
- Add a task which produces a second text file and another task which merges both text files.
- Execute all three tasks.
Consult the release notes to find out about what is new.
pytask is distributed under the terms of the MIT license.
The license also includes a copyright and permission notice from pytest since some modules, classes, and functions are copied from pytest. Not to mention how pytest has inspired the development pytask in general. Without the amazing work of Holger Krekel and pytest’s many contributors, this project would not have been possible. Thank you!
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
|Filename, size||File type||Python version||Upload date||Hashes|
|Filename, size pytask-0.0.14-py3-none-any.whl (64.8 kB)||File type Wheel||Python version py3||Upload date||Hashes View|
|Filename, size pytask-0.0.14.tar.gz (71.6 kB)||File type Source||Python version None||Upload date||Hashes View|