Synopsis
Description
Thedvc dag command visualizes the structure of your DVC pipelines as a directed acyclic graph (DAG). It shows the relationships between stages, helping you understand data flow and dependencies in your project.
The DAG visualization displays:
- Stages: Nodes representing data processing steps
- Dependencies: Edges showing which stages depend on others
- Pipeline structure: Overall data flow from inputs to outputs
dvc dag produces ASCII art output suitable for terminal viewing. It can also generate output in DOT format (for Graphviz) or Mermaid format (for documentation).
A DAG is a graph with directed edges and no cycles. In DVC pipelines, stages are nodes and dependencies are edges. The acyclic nature ensures pipelines can be executed in a valid order.
Arguments
Stage name or output to show pipeline for. Finds all stages in the workspace by default.When specified, shows only the portion of the DAG related to this target.Examples:
Options
Output Formats
Print DAG in DOT format. DOT is a graph description language used by Graphviz.Output can be rendered to images using Graphviz tools:
Print DAG in Mermaid format. Mermaid is a JavaScript-based diagramming tool.The output can be used in:
- Markdown files (GitHub, GitLab)
- Documentation sites
- Mermaid Live Editor
Print DAG in Mermaid format wrapped in Markdown code block.This format is ready to paste into Markdown files:
Filtering Options
Show full DAG that the target belongs to, instead of showing only ancestors.By default, when you specify a target, DVC shows only that stage and its dependencies (ancestors). With
--full, it shows the entire pipeline including stages that don’t affect the target.Print output files instead of stages.Shows the data artifacts DAG rather than the stage execution DAG.
Cannot be used with
--collapse-foreach-matrix.Collapse stages from each foreach/matrix definition into a single node.When using foreach or matrix to generate multiple similar stages, this option groups them into a single node for cleaner visualization.
Cannot be used with
--outs.Examples
Basic DAG visualization
View the entire pipeline in ASCII format:Visualize specific stage and dependencies
train and the stages it depends on.
Show full pipeline for a stage
train (like evaluate) that don’t affect it.
Generate DOT format for Graphviz
Create pipeline diagram image
Generate a PNG image of your pipeline:Generate Mermaid diagram
Generate Mermaid diagram for documentation
Visualize data flow (outputs)
Collapse matrix stages
For pipelines usingforeach or matrix, collapse repeated stages:
Understanding Pipeline Structure
Simple linear pipeline
Branching pipeline
Converging pipeline
Use Cases
Documentation
Embed pipeline diagrams in your project documentation:Code reviews
Generate visual representation for pull requests:Debugging pipelines
Understand execution order and dependencies:Pipeline optimization
Identify opportunities for parallelization:Tracking data lineage
Visualize data flow through your pipeline:Output Format Details
ASCII Format
- Default format
- Displayed in terminal with pagination
- Boxes represent stages
- Asterisks (*) represent dependencies
- Suitable for quick checks
DOT Format
- Industry-standard graph format
- Processed by Graphviz tools
- Can generate: PNG, SVG, PDF, PS
- Highly customizable with DOT syntax
- Best for publication-quality diagrams
Mermaid Format
- Modern JavaScript-based diagramming
- Renders in Markdown (GitHub, GitLab)
- Interactive in documentation sites
- No external tools needed
- Best for documentation
- GitHub (in .md files)
- GitLab (in .md files)
- Mintlify, MkDocs, Docusaurus
- Mermaid Live Editor
- Notion, Obsidian
Integration Examples
GitHub Actions
Automatically update pipeline diagram:Pre-commit hook
Keep documentation in sync:Makefile integration
Advanced Tips
Large pipelines: For very large pipelines, consider using
--collapse-foreach-matrix or filtering with specific targets to improve readability.Troubleshooting
Empty output
Ifdvc dag produces no output:
- Ensure you have a
dvc.yamlfile with stages - Check that you’re in a DVC repository (
dvc status) - Verify the target exists if you specified one
Graphviz not found
Ifdot command is not available:
Mermaid rendering issues
If Mermaid diagrams don’t render in Markdown:- Ensure platform supports Mermaid (GitHub, GitLab do)
- Check for syntax errors in the output
- Try using the Mermaid Live Editor for testing
Complex pipeline visualization
For complex pipelines:- Use
--collapse-foreach-matrixto simplify - Filter with specific targets:
dvc dag train - Generate multiple diagrams for different sections
See Also
- dvc stage list - List stages in text format
- dvc repro - Execute pipelines
- dvc status - Check pipeline status
- dvc pipelines - Pipeline management commands