> 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/dataos-resources/workflow/example.md).

# Example

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:
        stack: container
        stackSpec:
          image: docker.io/library/alpine:3.20
          command:
            - sh
          arguments:
            - -c
            - echo "fetch customers"

    - name: fetch-orders
      spec:
        stack: container
        stackSpec:
          image: docker.io/library/alpine:3.20
          command:
            - sh
          arguments:
            - -c
            - echo "fetch orders"

    - name: merge-data
      depends:
        - fetch-customers
        - fetch-orders
      spec:
        stack: container
        stackSpec:
          image: docker.io/library/alpine:3.20
          command:
            - sh
          arguments:
            - -c
            - echo "merge results"
```

{% endcode %}

## Workflow with projections

Use projections when the Workflow needs secrets or runtime context.

{% 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
  use:
    projection:
      secrets:
        - id: workflow-secret
          contextAlias: app
      projections:
        envVars:
          - key: WORKFLOW_ID
            value: "{{.defaultProjections.dataOsRunId}}"
          - key: API_TOKEN
            value: "{{.secrets.app.API_TOKEN}}"
  dag:
    - name: run-task
      spec:
        stack: container
        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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
