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.

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
    

    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.1.0.tar.gz (14.7 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.1.0-py3-none-any.whl (15.5 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for taskcond-0.1.0.tar.gz
Algorithm Hash digest
SHA256 c6c57afee6cf5502eb11595b5dae8b9c3831879df2dd542ff986e35412aa9c9e
MD5 cd0cd85e29ddfb2eb83f7b27bd674237
BLAKE2b-256 db61f2425c4ee1ee186efa72608a0d840408e1629bc412fb628c383dd0b0a523

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for taskcond-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7f258d2aa0b6ce3844262238baa6e5216dce7c36507d3bc8bed474c07cd37769
MD5 ae6be9d6941319773a3eb270ac2d80c1
BLAKE2b-256 cb4b8bc4064eafffee208a21d2063f8e719ef2ddb3b7710f7c1c6260a71967f1

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