# dr run

> dr run - Execute tasks defined in application templates.

This Markdown file sits beside the HTML page at the same path (with a `.md` suffix). It summarizes the topic and lists links for tools and LLM context.

Companion generated at `2026-05-06T18:17:09.546704+00:00` (UTC).

## Primary page

- [dr run](https://docs.datarobot.com/en/docs/agentic-ai/cli/commands/run.html): Full documentation for this topic (HTML).

## Sections on this page

- [Synopsis](https://docs.datarobot.com/en/docs/agentic-ai/cli/commands/run.html#synopsis): In-page section heading.
- [Description](https://docs.datarobot.com/en/docs/agentic-ai/cli/commands/run.html#description): In-page section heading.
- [Template requirements](https://docs.datarobot.com/en/docs/agentic-ai/cli/commands/run.html#template-requirements): In-page section heading.
- [Options](https://docs.datarobot.com/en/docs/agentic-ai/cli/commands/run.html#options): In-page section heading.
- [Global options](https://docs.datarobot.com/en/docs/agentic-ai/cli/commands/run.html#global-options): In-page section heading.
- [Examples](https://docs.datarobot.com/en/docs/agentic-ai/cli/commands/run.html#examples): In-page section heading.
- [List available tasks](https://docs.datarobot.com/en/docs/agentic-ai/cli/commands/run.html#list-available-tasks): In-page section heading.
- [Run a single task](https://docs.datarobot.com/en/docs/agentic-ai/cli/commands/run.html#run-a-single-task): In-page section heading.
- [Run multiple tasks sequentially](https://docs.datarobot.com/en/docs/agentic-ai/cli/commands/run.html#run-multiple-tasks-sequentially): In-page section heading.
- [Run multiple tasks in parallel](https://docs.datarobot.com/en/docs/agentic-ai/cli/commands/run.html#run-multiple-tasks-in-parallel): In-page section heading.
- [Run with watch mode](https://docs.datarobot.com/en/docs/agentic-ai/cli/commands/run.html#run-with-watch-mode): In-page section heading.
- [Control concurrency](https://docs.datarobot.com/en/docs/agentic-ai/cli/commands/run.html#control-concurrency): In-page section heading.
- [Silent execution](https://docs.datarobot.com/en/docs/agentic-ai/cli/commands/run.html#silent-execution): In-page section heading.
- [Pass-through exit codes](https://docs.datarobot.com/en/docs/agentic-ai/cli/commands/run.html#pass-through-exit-codes): In-page section heading.
- [Task discovery](https://docs.datarobot.com/en/docs/agentic-ai/cli/commands/run.html#task-discovery): In-page section heading.
- [Directory structure](https://docs.datarobot.com/en/docs/agentic-ai/cli/commands/run.html#directory-structure): In-page section heading.
- [Generated Taskfile](https://docs.datarobot.com/en/docs/agentic-ai/cli/commands/run.html#generated-taskfile): In-page section heading.
- [Error handling](https://docs.datarobot.com/en/docs/agentic-ai/cli/commands/run.html#error-handling): In-page section heading.
- [Not in a template directory](https://docs.datarobot.com/en/docs/agentic-ai/cli/commands/run.html#not-in-a-template-directory): In-page section heading.
- [Dotenv directive conflict](https://docs.datarobot.com/en/docs/agentic-ai/cli/commands/run.html#dotenv-directive-conflict): In-page section heading.
- [Task binary not found](https://docs.datarobot.com/en/docs/agentic-ai/cli/commands/run.html#task-binary-not-found): In-page section heading.
- [No tasks found](https://docs.datarobot.com/en/docs/agentic-ai/cli/commands/run.html#no-tasks-found): In-page section heading.
- [Task definitions](https://docs.datarobot.com/en/docs/agentic-ai/cli/commands/run.html#task-definitions): In-page section heading.
- [Basic task](https://docs.datarobot.com/en/docs/agentic-ai/cli/commands/run.html#basic-task): In-page section heading.
- [Task with dependencies](https://docs.datarobot.com/en/docs/agentic-ai/cli/commands/run.html#task-with-dependencies): In-page section heading.
- [Task with environment variables](https://docs.datarobot.com/en/docs/agentic-ai/cli/commands/run.html#task-with-environment-variables): In-page section heading.
- [Task with preconditions](https://docs.datarobot.com/en/docs/agentic-ai/cli/commands/run.html#task-with-preconditions): In-page section heading.
- [Best practices](https://docs.datarobot.com/en/docs/agentic-ai/cli/commands/run.html#best-practices): In-page section heading.
- [Descriptive task names](https://docs.datarobot.com/en/docs/agentic-ai/cli/commands/run.html#descriptive-task-names): In-page section heading.
- [Useful descriptions](https://docs.datarobot.com/en/docs/agentic-ai/cli/commands/run.html#useful-descriptions): In-page section heading.
- [Common task names](https://docs.datarobot.com/en/docs/agentic-ai/cli/commands/run.html#common-task-names): In-page section heading.
- [Environment variable usage](https://docs.datarobot.com/en/docs/agentic-ai/cli/commands/run.html#environment-variable-usage): In-page section heading.
- [Silent tasks](https://docs.datarobot.com/en/docs/agentic-ai/cli/commands/run.html#silent-tasks): In-page section heading.
- [Integration with other commands](https://docs.datarobot.com/en/docs/agentic-ai/cli/commands/run.html#integration-with-other-commands): In-page section heading.
- [With dr templates](https://docs.datarobot.com/en/docs/agentic-ai/cli/commands/run.html#with-dr-templates): In-page section heading.
- [With dr dotenv](https://docs.datarobot.com/en/docs/agentic-ai/cli/commands/run.html#with-dr-dotenv): In-page section heading.
- [In CI/CD pipelines](https://docs.datarobot.com/en/docs/agentic-ai/cli/commands/run.html#in-cicd-pipelines): In-page section heading.
- [Troubleshooting](https://docs.datarobot.com/en/docs/agentic-ai/cli/commands/run.html#troubleshooting): In-page section heading.
- [Tasks not found](https://docs.datarobot.com/en/docs/agentic-ai/cli/commands/run.html#tasks-not-found): In-page section heading.
- [Environment variables not loading](https://docs.datarobot.com/en/docs/agentic-ai/cli/commands/run.html#environment-variables-not-loading): In-page section heading.
- [Task execution fails](https://docs.datarobot.com/en/docs/agentic-ai/cli/commands/run.html#task-execution-fails): In-page section heading.
- [Permission denied errors](https://docs.datarobot.com/en/docs/agentic-ai/cli/commands/run.html#permission-denied-errors): In-page section heading.
- [See also](https://docs.datarobot.com/en/docs/agentic-ai/cli/commands/run.html#see-also): In-page section heading.

## Related documentation

- [Agentic AI](https://docs.datarobot.com/en/docs/agentic-ai/index.html): Linked from this page.
- [CLI](https://docs.datarobot.com/en/docs/agentic-ai/cli/index.html): Linked from this page.
- [Command reference](https://docs.datarobot.com/en/docs/agentic-ai/cli/commands/index.html): Linked from this page.
- [Template system overview](https://docs.datarobot.com/en/docs/agentic-ai/cli/template-system/index.html): Linked from this page.
- [Task definitions](https://docs.datarobot.com/en/docs/agentic-ai/cli/template-system/structure.html#task-definitions): Linked from this page.
- [Environment variables](https://docs.datarobot.com/en/docs/agentic-ai/cli/template-system/environment-variables.html): Linked from this page.
- [dr dotenv](https://docs.datarobot.com/en/docs/agentic-ai/cli/commands/dotenv.html): Linked from this page.

## Documentation content

Execute tasks defined in application templates.

## Synopsis

The `dr run` command executes tasks defined in Taskfiles within DataRobot application templates. It automatically discovers component Taskfiles and aggregates them into a unified task execution environment.

```
dr run [TASK_NAME...] [flags]
```

## Description

The `run` command provides a convenient way to execute common application tasks such as starting development servers, running tests, building containers, and deploying applications. It works by discovering Taskfiles in your template directory and generating a consolidated task runner configuration.

Key features:

- Automatic discovery —finds and aggregates Taskfiles from template components.
- Template validation —verifies you're in a DataRobot template directory.
- Conflict detection —prevents dotenv directive conflicts in nested Taskfiles.
- Parallel execution —run multiple tasks simultaneously.
- Watch mode —automatically re-run tasks when files change.

## Template requirements

To use `dr run`, your directory must meet these requirements:

1. Contains a .env file —indicates you're in a DataRobot template directory.
2. Contains Taskfiles —component directories with Taskfile.yaml or Taskfile.yml files.
3. No dotenv conflicts —component Taskfiles cannot have their own dotenv directives.

If these requirements aren't met, the command provides clear error messages explaining the issue.

## Options

```
  -l, --list              List all available tasks
  -d, --dir string        Directory to look for tasks (default ".")
  -p, --parallel          Run tasks in parallel
  -C, --concurrency int   Number of concurrent tasks to run (default 2)
  -w, --watch             Enable watch mode for the given task
  -y, --yes               Assume "yes" as answer to all prompts
  -x, --exit-code         Pass-through the exit code of the task command
  -s, --silent            Disable echoing
  -h, --help              Help for run
```

## Global options

```
  -v, --verbose    Enable verbose output
      --debug      Enable debug output
```

## Examples

### List available tasks

```
dr run --list
```

Output:

```
Available tasks:
* dev        Start development server
* test       Run tests
* lint       Run linters
* build      Build Docker container
* deploy     Deploy to DataRobot
```

### Run a single task

```
dr run dev
```

Starts the development server defined in your template's Taskfile.

### Run multiple tasks sequentially

```
dr run lint test
```

Runs the lint task, then the test task in sequence.

### Run multiple tasks in parallel

```
dr run lint test --parallel
```

Runs lint and test tasks simultaneously.

### Run with watch mode

```
dr run dev --watch
```

Runs the development server and automatically restarts it when source files change.

### Control concurrency

```
dr run task1 task2 task3 --parallel --concurrency 3
```

Runs up to 3 tasks concurrently.

### Silent execution

```
dr run build --silent
```

Runs the build task without echoing commands.

### Pass-through exit codes

```
dr run test --exit-code
```

Exits with the same code as the task command (useful in CI/CD).

## Task discovery

The `dr run` command discovers tasks in this order:

1. Check for .env file —verifies you're in a template directory.
2. Scan for Taskfiles —finds Taskfile.yaml or Taskfile.yml files up to 2 levels deep.
3. Validate dotenv directives —ensures component Taskfiles don't have conflicting dotenv declarations.
4. Generate Taskfile.gen.yaml —creates a unified task configuration.
5. Execute tasks —runs the requested tasks using the task binary.

### Directory structure

```
my-template/
├── .env                          # Required: template marker
├── Taskfile.gen.yaml            # Generated: consolidated tasks
├── backend/
│   ├── Taskfile.yaml            # Component tasks (no dotenv)
│   └── src/
└── frontend/
    ├── Taskfile.yaml            # Component tasks (no dotenv)
    └── src/
```

### Generated Taskfile

The CLI generates `Taskfile.gen.yaml` with this structure:

```
version: '3'

dotenv: [".env"]

includes:
  backend:
    taskfile: ./backend/Taskfile.yaml
    dir: ./backend
  frontend:
    taskfile: ./frontend/Taskfile.yaml
    dir: ./frontend
```

This allows you to run component tasks with prefixes:

```
dr run backend:build
dr run frontend:dev
```

## Error handling

### Not in a template directory

If you run `dr run` outside a DataRobot template:

```
You don't seem to be in a DataRobot Template directory.
This command requires a .env file to be present.
```

Solution: Navigate to a template directory or run `dr templates setup` to create one.

### Dotenv directive conflict

If a component Taskfile has its own `dotenv` directive:

```
Error: Cannot generate Taskfile because an existing Taskfile already has a dotenv directive.
existing Taskfile already has dotenv directive: backend/Taskfile.yaml
```

Solution: Remove the `dotenv` directive from component Taskfiles. The generated `Taskfile.gen.yaml` handles environment variables.

### Task binary not found

If the `task` binary isn't installed:

```
"task" binary not found in PATH. Please install Task from https://taskfile.dev/installation/
```

Solution: Install Task following the instructions at [taskfile.dev/installation](https://taskfile.dev/installation/).

### No tasks found

If no Taskfiles exist in component directories:

```
file does not exist
Error: failed to list tasks: exit status 1
```

Solution: Add Taskfiles to your template components or use `dr templates clone` to start with a pre-configured template.

## Task definitions

Tasks are defined in component `Taskfile.yaml` files using Task's syntax.

### Basic task

```
version: '3'

tasks:
  dev:
    desc: Start development server
    cmds:
      - python -m uvicorn src.app.main:app --reload
```

### Task with dependencies

```
tasks:
  build:
    desc: Build Docker container
    cmds:
      - docker build -t {{.APP_NAME}} .

  deploy:
    desc: Deploy application
    deps: [build]
    cmds:
      - docker push {{.APP_NAME}}
      - kubectl apply -f deploy.yaml
```

### Task with environment variables

```
tasks:
  test:
    desc: Run tests with coverage
    env:
      PYTEST_ARGS: "--cov=src --cov-report=html"
    cmds:
      - pytest {{.PYTEST_ARGS}}
```

### Task with preconditions

```
tasks:
  deploy:
    desc: Deploy to production
    preconditions:
      - sh: test -f .env
        msg: ".env file is required"
      - sh: test -n "$DATAROBOT_ENDPOINT"
        msg: "DATAROBOT_ENDPOINT must be set"
    cmds:
      - ./deploy.sh
```

## Best practices

### Descriptive task names

Use clear, action-oriented task names:

```
tasks:
  dev:           # ✅ Clear and concise
    desc: Start development server

  test:unit:     # ✅ Namespaced for organization
    desc: Run unit tests

  lint:python:   # ✅ Specific and descriptive
    desc: Run Python linters
```

### Useful descriptions

Provide helpful task descriptions:

```
tasks:
  deploy:
    desc: Deploy application to DataRobot (requires authentication)
    cmds:
      - ./deploy.sh
```

### Common task names

Use standard names for common operations:

- dev —start development server.
- build —build application or container.
- test —run test suite.
- lint —run linters and formatters.
- deploy —deploy to target environment.
- clean —clean build artifacts.

### Environment variable usage

Reference `.env` variables in tasks:

```
tasks:
  deploy:
    desc: Deploy {{.APP_NAME}} to {{.DEPLOYMENT_TARGET}}
    cmds:
      - echo "Deploying to $DATAROBOT_ENDPOINT"
      - ./deploy.sh
```

### Silent tasks

Use `silent: true` for tasks that don't need output:

```
tasks:
  check:version:
    desc: Check CLI version
    silent: true
    cmds:
      - dr version
```

## Integration with other commands

### With dr templates

```
# Clone and set up template
dr templates clone python-streamlit my-app
cd my-app

# Configure environment
dr dotenv setup

# Run tasks
dr run dev
```

### With dr dotenv

```
# Update environment variables
dr dotenv setup

# Run with updated configuration
dr run deploy
```

### In CI/CD pipelines

```
#!/bin/bash
# ci-pipeline.sh

set -e

# Run tests
dr run test --exit-code --silent

# Run linters
dr run lint --exit-code --silent

# Build
dr run build --silent
```

## Troubleshooting

### Tasks not found

Problem: `dr run --list` shows no tasks.

Causes: - No Taskfiles in component directories.
- Taskfiles at wrong depth (deeper than 2 levels).

Solution:

```
# Check for Taskfiles
find . -name "Taskfile.y*ml" -maxdepth 3

# Ensure Taskfiles are in component directories
# Correct: ./backend/Taskfile.yaml
# Wrong: ./backend/src/Taskfile.yaml
```

### Environment variables not loading

Problem: Tasks can't access environment variables.

Causes: - Missing `.env` file.
- Variables not exported.

Solution:

```
# Verify .env exists
ls -la .env

# Check variables are set
source .env
env | grep DATAROBOT
```

### Task execution fails

Problem: Task runs but fails with errors.

Solution:

```
# Enable verbose output
dr run task-name --verbose

# Enable debug output
dr run task-name --debug

# Check task definition
cat component/Taskfile.yaml
```

### Permission denied errors

Problem: Tasks fail with permission errors.

Solution:

```
# Make scripts executable
chmod +x scripts/*.sh

# Check file permissions
ls -l scripts/
```

## See also

- Template system overview —understanding templates.
- Task definitions —creating Taskfiles.
- Environment variables —managing configuration.
- dr dotenv —environment variable management.
- Task documentation —official Task runner docs.
