> For the complete documentation index, see [llms.txt](https://v2.dataos.info/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://v2.dataos.info/references/resources/workflow/example.md).

# Example DAG patterns

End-to-end Workflow examples for common orchestration patterns.

Use this page for complete Workflow manifests and common DAG patterns.

## Single-step container Workflow

Use a single step when the job has no internal dependencies.

{% code title="daily-report.yaml" expandable="true" collapsedlinecount="14" %}

```yaml
version: v2alpha
name: daily-report
type: workflow
tags:
  - report
  - container
description: "Generate a daily report in one batch step."
spec:
  dag:
    - name: generate-report
      title: Generate report
      spec:
        compute: runnable-default
        resources:
          requests:
            cpu: 100m
            memory: 128Mi
          limits:
            cpu: 500m
            memory: 512Mi
        stack: container
        stackSpec:
          image: docker.io/library/alpine:3.20
          command:
            - sh
          arguments:
            - -c
            - |
              echo "Generating report"
              date -u
              echo '{"status":"ok"}'
```

{% endcode %}

## Multi-step DAG with a container stack

Use multiple steps when work must happen in order.

This example introduces the DAG first:

* `extract` prepares input files.
* `validate` checks the result.
* `publish` runs only after validation passes.

{% code title="customer-batch-pipeline.yaml" expandable="true" collapsedlinecount="18" %}

```yaml
version: v2alpha
name: customer-batch-pipeline
type: workflow
tags:
  - batch
  - container
description: "Run extract, validate, and publish as a DAG"
spec:
  dag:
    - name: extract
      title: Extract source data
      spec:
        compute: runnable-default
        use:
          volumes:
            - id: ${SHARED_VOLUME_ID}
              directory: /workspace
              readOnly: false
        stack: container
        stackSpec:
          image: docker.io/library/python:3.12-alpine
          command:
            - sh
          arguments:
            - -c
            - |
              mkdir -p /workspace/raw
              printf '{"customers": 42}\n' > /workspace/raw/customers.json

    - name: validate
      title: Validate extracted data
      depends:
        - extract
      spec:
        compute: runnable-default
        use:
          volumes:
            - id: ${SHARED_VOLUME_ID}
              directory: /workspace
              readOnly: false
        stack: container
        stackSpec:
          image: docker.io/library/alpine:3.20
          command:
            - sh
          arguments:
            - -c
            - |
              test -s /workspace/raw/customers.json
              echo "validation passed"

    - name: publish
      title: Publish validated output
      depends:
        - validate
      spec:
        compute: runnable-default
        use:
          volumes:
            - id: ${SHARED_VOLUME_ID}
              directory: /workspace
              readOnly: false
        stack: container
        stackSpec:
          image: docker.io/library/alpine:3.20
          command:
            - sh
          arguments:
            - -c
            - |
              mkdir -p /workspace/published
              cp /workspace/raw/customers.json /workspace/published/customers.json
              echo "publish complete"
```

{% endcode %}

## Parallel branches in a DAG

Use parallel branches when steps do not depend on each other.

In this example, `fetch-customers` and `fetch-orders` run independently. `merge-data` waits for both.

{% code title="parallel-batch-pipeline.yaml" expandable="true" collapsedlinecount="16" %}

```yaml
version: v2alpha
name: parallel-batch-pipeline
type: workflow
tags:
  - batch
  - dag
description: "Run independent branches, then merge results"
spec:
  dag:
    - name: fetch-customers
      spec:
        runAsUser: ${RUN_AS_USER}
        stack: container
        compute: runnable-default
        stackSpec:
          image: docker.io/library/alpine:3.20
          command:
            - sh
          arguments:
            - -c
            - echo "fetch customers"

    - name: fetch-orders
      spec:
        runAsUser: ${RUN_AS_USER}
        stack: container
        compute: runnable-default
        stackSpec:
          image: docker.io/library/alpine:3.20
          command:
            - sh
          arguments:
            - -c
            - echo "fetch orders"

    - name: merge-data
      depends:
        - fetch-customers
        - fetch-orders
      spec:
        runAsUser: ${RUN_AS_USER}
        stack: container
        compute: runnable-default
        stackSpec:
          image: docker.io/library/alpine:3.20
          command:
            - sh
          arguments:
            - -c
            - echo "merge results"
```

{% endcode %}

## Workflow with projections

Use projections when a step needs secrets or runtime context. Define `use.projection` inside the step's `spec`, not under the Workflow's top-level `spec`. Each step that needs the values declares its own projection.

{% code title="projected-workflow\.yaml" expandable="true" collapsedlinecount="16" %}

```yaml
version: v2alpha
name: projected-workflow
type: workflow
description: "Inject runtime values into a batch step"
spec:
  type: instance
  dag:
    - name: run-task
      spec:
        stack: container
        compute: runnable-default
        use:
          projection:
            secrets:
              - id: workflow-secret
                contextAlias: app
            projections:
              envVars:
                - key: WORKFLOW_ID
                  template: "{{ defaultProjections.dataOsRunId }}"
                - key: API_TOKEN
                  template: "{{ secrets['app']['API_TOKEN'] | base64_decode }}"
        stackSpec:
          image: docker.io/library/alpine:3.20
          command:
            - sh
          arguments:
            - -c
            - |
              echo "Workflow: $WORKFLOW_ID"
              test -n "$API_TOKEN"
```

{% endcode %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://v2.dataos.info/references/resources/workflow/example.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
