Dependency Resolution
Torc supports two types of dependencies. For a hands-on tutorial, see Diamond Workflow with File Dependencies.
1. Explicit Dependencies
Declared via depends_on:
jobs:
- name: preprocess
command: preprocess.sh
- name: analyze
command: analyze.sh
depends_on:
- preprocess
2. Implicit Dependencies
Inferred from file and user_data relationships.
File Dependencies
jobs:
- name: preprocess
command: process.sh
output_files:
- intermediate_data
- name: analyze
command: analyze.sh
input_files:
- intermediate_data # Implicitly depends on preprocess
User Data Dependencies
User scripts ingest JSON data into Torc’s database. This is analagous to JSON files except that they are stored in the database AND user code must understand Torc’s API.
jobs:
- name: generate_config
command: make_config.py
output_user_data:
- config
- name: run_simulation
command: simulate.py
input_user_data:
- config # Implicitly depends on generate_config
user_data:
- name: config
Resolution Process
During workflow creation, the server:
- Resolves all names to IDs
- Stores explicit dependencies in
job_depends_on - Stores file/user_data relationships in junction tables
- During
initialize_jobs, queries junction tables to add implicit dependencies
Dependency Graph Evaluation
When initialize is called:
- All jobs start in
uninitializedstate - Server builds complete dependency graph from explicit and implicit dependencies
- Jobs with no unsatisfied dependencies are marked
ready - Jobs waiting on dependencies are marked
blocked - As jobs complete, blocked jobs are re-evaluated and may become
ready
Variable Substitution Syntax
In workflow specification files (YAML, JSON5, KDL), use these patterns to reference files and user data in job commands:
| Pattern | Description |
|---|---|
${files.input.NAME} | File path this job reads (creates implicit dependency) |
${files.output.NAME} | File path this job writes (satisfies dependencies) |
${user_data.input.NAME} | User data this job reads |
${user_data.output.NAME} | User data this job writes |
Example:
jobs:
- name: process
command: "python process.py -i ${files.input.raw} -o ${files.output.result}"
See Workflow Specification Formats for complete syntax details.