Skip to main content

pythonic task runner.

Project description

taskcond

taskcond is a Pythonic task runner that executes tasks based on dependencies and file modification times, similar to make.

Features

  • Pythonic Task Definition: Define tasks as Python functions or shell commands in a TaskFile.py.
  • Dependency Management: Specify dependencies between tasks to ensure they run in the correct order.
  • Incremental Builds: Tasks are skipped if their output files are newer than their input files, saving execution time.
  • Parallel Execution: Run independent tasks concurrently using threads or processes to speed up workflows.
  • Command-Line Interface: A simple and intuitive CLI powered by click for running and listing tasks.
  • Flexible Configuration: Configure default behaviors in your pyproject.toml file.
  • Cycle Detection: Automatically detects and reports cyclic dependencies in your task graph.
  • Hidden Tasks: Tasks can be hidden from the list command by setting displayed=False, allowing for internal or helper tasks that don't clutter the task list.

Quick Start

  1. Installation

    pip install taskcond
    
  2. Create a TaskFile.py Create a file named TaskFile.py in your project root and define your tasks.

    from pathlib import Path
    from taskcond import Task, register
    
    # Define a task that creates a file
    register(
        Task(
            name="create_file",
            description="Create an output file.",
            shell_command="echo 'Hello, taskcond!' > output.txt",
            output_files=(Path("output.txt"),),
        )
    )
    
    # Define a task that depends on the first one
    register(
        Task(
            name="process_file",
            description="Process the created file.",
            shell_command="cat output.txt",
            depends=("create_file",),
            input_files=(Path("output.txt"),),
        )
    )
    
  3. Run Tasks Use the taskcond CLI to run your tasks.

    # List available tasks
    taskcond list
    
    # Run a specific task and its dependencies
    taskcond run process_file
    
    # Run a task with arguments
    taskcond run "test --verbose"
    

    The process_file task will only run if output.txt has been modified or is missing.

Configuration

You can configure taskcond by adding a [tool.taskcond] section to your pyproject.toml:

[tool.taskcond]
taskfile = "TaskFile.py"  # Path to the task definition file
force = false             # Force execution of all tasks
n_jobs = 1                # Number of parallel jobs (-1 for all cores)
use_processes = false     # Use ProcessPoolExecutor instead of ThreadPoolExecutor
visible_progressbar = true # Show a progress bar during execution

CLI options will always override the settings in pyproject.toml.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

taskcond-0.2.1.tar.gz (15.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

taskcond-0.2.1-py3-none-any.whl (16.0 kB view details)

Uploaded Python 3

File details

Details for the file taskcond-0.2.1.tar.gz.

File metadata

  • Download URL: taskcond-0.2.1.tar.gz
  • Upload date:
  • Size: 15.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.5

File hashes

Hashes for taskcond-0.2.1.tar.gz
Algorithm Hash digest
SHA256 b4b6ac7a5b5ee7b423a94f64ff7db181efe322c5d1a629c58af14ad5ebe6444f
MD5 c855879d32d25ab0676291d867e6dd93
BLAKE2b-256 d1eb3822f4f782aa3cec381bd8a4e2cf33f08539b2a1354e9109222f7ea25864

See more details on using hashes here.

File details

Details for the file taskcond-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: taskcond-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 16.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.5

File hashes

Hashes for taskcond-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 24f2e702df6338f576222669dd726e9e528aaaeef5ff152e2404fd6cdb68cd23
MD5 0fd370e988511d049f4ff767c469471a
BLAKE2b-256 79ef0e41c096163a5eaf2689de432d1ae917974f1e8c2884cdd985d0cd9b8393

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page