Spry LogoSpry Docs

Task Orchestration

Understand how Spry orchestrates and executes tasks with dependency management

Understand how Spry orchestrates and executes tasks with dependency management.

Overview

Spry automatically builds a Directed Acyclic Graph (DAG) of your tasks based on their dependencies. Tasks are executed in the optimal order, with independent tasks running in parallel when possible.

Dependency Declaration

Use the --dep flag to declare dependencies between tasks:

# setup-db
sqlite3 app.db < schema.sql
# seed-data --dep setup-db
sqlite3 app.db < seed.sql
# deploy --dep seed-data
echo "Ready to deploy!"

This creates a chain: setup-dbseed-datadeploy.

Parallel Execution

Tasks without dependencies or with satisfied dependencies can run in parallel:

# fetch-users
curl api.example.com/users > users.json
# fetch-products
curl api.example.com/products > products.json
# process-data --dep fetch-users --dep fetch-products
deno run process.ts

fetch-users and fetch-products run in parallel, then process-data runs after both complete.

Execution Order

Spry uses topological sorting to determine the execution order:

  1. Analyze all task dependencies to build a DAG
  2. Identify tasks with no dependencies (entry points)
  3. Execute entry-point tasks (in parallel if possible)
  4. As tasks complete, execute dependent tasks whose prerequisites are met
  5. Continue until all tasks are complete

💡 Optimized Execution: Spry automatically parallelizes independent tasks for faster execution. No configuration needed!

Error Handling

If a task fails, all dependent tasks are skipped:

Task "setup-db" failed with exit code 1
Skipping dependent tasks: seed-data, deploy

Running Tasks

Run Specific Task

Execute a single task and its dependencies:

./spry.ts task deploy

Run All Tasks

Execute all tasks in the Spryfile:

./spry.ts runbook

⚠️ Warning: Circular dependencies are not allowed and will cause an error during DAG construction.

Next Steps

How is this guide?

Last updated on

On this page