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-db → seed-data → deploy.
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.tsfetch-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:
- Analyze all task dependencies to build a DAG
- Identify tasks with no dependencies (entry points)
- Execute entry-point tasks (in parallel if possible)
- As tasks complete, execute dependent tasks whose prerequisites are met
- 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, deployRunning Tasks
Run Specific Task
Execute a single task and its dependencies:
./spry.ts task deployRun 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
Executable Markdown
Learn how to transform code blocks into executable cells with powerful directives
SQLPage Integration
Discover how Spry generates and manages SQLPage applications
How is this guide?
Last updated on