dr run¶
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:
- Contains a .env file—indicates you're in a DataRobot template directory.
- Contains Taskfiles—component directories with
Taskfile.yamlorTaskfile.ymlfiles. - No dotenv conflicts—component Taskfiles cannot have their own
dotenvdirectives.
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:
- Check for .env file—verifies you're in a template directory.
- Scan for Taskfiles—finds
Taskfile.yamlorTaskfile.ymlfiles up to 2 levels deep. - Validate dotenv directives—ensures component Taskfiles don't have conflicting
dotenvdeclarations. - Generate Taskfile.gen.yaml—creates a unified task configuration.
- Execute tasks—runs the requested tasks using the
taskbinary.
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.
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.