Skip to main content

More affectionately known as jogger.

jogger is a simple Python-based command line tool that isn’t quite a fully-fledged task runner. In addition to supporting arbitrary tasks, run either directly on the command line or as Python scripts, it ships with some common, useful, Django-aware tasks that can adapt their behaviour based on which packages are available in the system.

Full documentation at: https://task-jogger.readthedocs.io/

Installation

Install the latest stable version from PyPI:

pip install task-jogger

Quick start

1. Create jog.py

The jog.py file, created in the project root directory, stores the tasks defined for the project. It is a regular Python module, the only requirement being that it defines a tasks variable as a dictionary.

2. Define tasks

Keys in the jog.py file’s tasks dictionary form each task’s name, and values describe the tasks themselves. At their simplest, a task can be a string defining a command to execute on the command line:

# jog.py
tasks = {
    'hello': 'echo "Hello, World!"',
    'test': 'coverage run python manage.py test'
}

Alternatively, a task can be a Python function that returns a command to execute on the command line. This can be useful if the command is more complex to construct or depends on dynamic values:

# jog.py
def run_tests(settings, stdout, stderr):
    """
    Run the Django test suite, with coverage.py if installed.
    """

    try:
        import coverage
    except ImportError:
        stdout.write('Warning: coverage.py not installed.', style='warning')
        return 'python manage.py test'
    else:
        return 'coverage run python manage.py test'

tasks = {
    'test': run_tests
}

Finally, particularly complex tasks can be defined as classes. Such tasks can define their own custom arguments:

# jog.py
from jogger.tasks import Task


class TestTask(Task):

    help = 'Run the Django test suite, with coverage.py if installed.'

    def add_arguments(self, parser):

        parser.add_argument(
            '-q', '--quick',
            action='store_true',
            help=(
                'Run a "quick" variant of the task: no coverage analysis and '
                'running tests in parallel.'
            )
        )

    def handle(self, *args, **options):

        command = 'python manage.py test'

        if options['quick']:
            command = f'{command} --parallel'
        else:
            try:
                import coverage
            except ImportError:
                self.stdout.write('Warning: coverage.py not installed.', style='warning')
            else:
                command = f'coverage run {command}'

        self.cli(command)

tasks = {
    'test': TestTask
}

3. Run jog

The jog command is the interface to the tasks defined in jog.py.

Given the name of a task, jog will run that task:

$ jog test

If the task accepts arguments, they can also be provided:

$ jog test --quick

Executed with no arguments, jog will display a list of all available tasks. Tasks defined as functions or classes can define a description to be displayed in this listing. Tasks defined as strings simply display the command they will run. The following shows the output of a jog.py file containing a mixture of string-based, function-based, and class-based tasks:

$ jog
Available tasks:
string: echo "Hello, World!"
function: A task defined as a function.
class: A task defined as a class.
    See "jog class --help" for usage details

Release files for task-jogger 2.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for task-jogger 2.0.2
File Size Uploaded
task_jogger-2.0.2.tar.gz 29.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for task-jogger 2.0.2
File Interpreter ABI Platform
task_jogger-2.0.2-py3-none-any.whl Python 3 none any Details

Total release size: 61.2 kB

Release files / task_jogger-2.0.2.tar.gz

Download URL task_jogger-2.0.2.tar.gz
Size 29.0 kB
Tags Source
SHA-256 checksum
How to use checksums
2223cdcedd05daf4adf01db33f846b2ec97a50acb8dfb142aa15ada8fb553073
BLAKE2b-256 checksum
How to use checksums
ed96d5d0ee0fb0f6ebe914a5c60d60a791b01bac6dfc430e29a04dd54f535a80
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.12.2

Release files / task_jogger-2.0.2-py3-none-any.whl

Download URL task_jogger-2.0.2-py3-none-any.whl
Size 32.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3bb3a6af3277f16b9379d4b480d3478a5a8e46fb2efd5e69a6f8dd67839d51eb
BLAKE2b-256 checksum
How to use checksums
5163393b363c4b95b38a8b4a05c774b9e4abf7b4fcf4f4b17c19bb044113fd67
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.12.2
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page