Features#
Task commands#
A task’s cmd can be a simple string or a list of strings that are joined with spaces:
[tasks]
build = "python -m build"
build-alt = { cmd = ["python", "-m", "build", "--wheel"] }
Task aliases#
Tasks with no cmd that only list dependencies act as aliases:
[tasks.check]
depends-on = ["test", "lint", "typecheck"]
description = "Run all checks"
Task arguments#
Tasks can accept named arguments with optional defaults:
[tasks.test]
cmd = "pytest {{ test_path }} -v"
args = [
{ arg = "test_path", default = "tests/" },
]
description = "Run tests on a path"
Run with:
conda task run test src/tests/
Template variables#
Commands support Jinja2 templates with conda.* context variables:
Variable |
Description |
|---|---|
|
Current platform (e.g., |
|
Active environment name |
|
|
|
conda version |
|
Path to the task file |
|
CWD when |
|
|
|
|
|
|
|
|
When reading from pixi.toml, {{ pixi.platform }} etc. also work as aliases.
Environment variables#
[tasks.test]
cmd = "pytest"
env = { PYTHONPATH = "src", DATABASE_URL = "sqlite:///test.db" }
Clean environment#
Run a task with only essential environment variables:
[tasks]
isolated-test = { cmd = "pytest", clean-env = true }
Or via CLI: conda task run test --clean-env
Caching#
When inputs and outputs are specified, conda-tasks caches results
and skips re-execution when inputs haven’t changed:
[tasks.build]
cmd = "python -m build"
inputs = ["src/**/*.py", "pyproject.toml"]
outputs = ["dist/*.whl"]
Tip
The cache uses a fast (mtime, size) pre-check before falling back to SHA-256
hashing, so the overhead on cache hits is minimal.
Platform-specific tasks#
Override task fields per platform using the target key:
[tasks]
clean = "rm -rf build/"
[target.win-64.tasks]
clean = "rd /s /q build"
[tasks]
clean = "{% if conda.is_win %}rd /s /q build{% else %}rm -rf build/{% endif %}"
Conda environments#
Tasks run inside conda environments. The environment is resolved in this order:
-n/--nameor-p/--prefixCLI flagdefault-environmentfield on the taskenvironmentin dependency entriesCurrently active environment (
CONDA_PREFIX)
[tasks.test-legacy]
cmd = "pytest"
default-environment = "py38-compat"
conda task run test -n py311-compat