dvc-task

0.40.2 · active · verified Sat Apr 11

dvc-task is an extensible Python library for queuing, running, and managing background jobs (processes) from standalone applications. It is built on Celery but leverages a pre-configured filesystem transport, eliminating the need for a full AMQP messaging server. As of April 2026, the current version is 0.40.2, with active development and somewhat frequent, though irregular, releases.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to initialize a filesystem-based Celery application (FSApp), define a task to run a background process using ProcessManager, and then start a temporary worker to process the task. It showcases how to queue a simple 'echo' command.

from dvc_task.app import FSApp
from dvc_task.proc import ProcessManager
import time
import os

# Create a filesystem-based Celery app
# For a real application, consider a more persistent wdir
app = FSApp(wdir="./dvc-task-data")

@app.task
def run_command_task(command_args, task_name):
    manager = ProcessManager(wdir=os.path.join(app.wdir, 'processes'))
    # Run a simple command as a background process
    # The '.delay()' call queues the task
    signature = manager.run(command_args, name=task_name).delay()
    return signature.id

# Example usage:
if __name__ == "__main__":
    print("Starting dvc-task example...")
    task_id = run_command_task.delay(command_args=["echo", "Hello, dvc-task!"], task_name="greet_task")
    print(f"Task 'greet_task' queued with ID: {task_id}")

    print("Starting temporary worker...")
    # In a real scenario, the worker would run in a separate process/daemon
    # For quickstart, we run a temporary worker that exits when the queue is empty
    worker = app.TemporaryWorker()
    worker.start() # This blocks until the queue is empty or timeout

    # Clean up (optional, but good for quickstart)
    app.clean()
    print("dvc-task example finished and cleaned up.")

view raw JSON →