pytask.lock is the default state backend. It stores task state in a portable,
git-friendly format so runs can be resumed or shared across machines.
!!! note
SQLite is the legacy format. When no lockfile exists, pytask reads the legacy database
state and writes `pytask.lock`. The lockfile remains the primary backend for skip
decisions, and `pytask build` also keeps the legacy database updated for downgrade
compatibility.
# This file is automatically @generated by pytask.
# It is not intended for manual editing.
lock-version = "1"
[[task]]
id = "src/tasks/data.py::task_clean_data"
state = "f9e8d7c6..."
[task.depends_on]
"data/raw/input.csv" = "e5f6g7h8..."
[task.produces]
"data/processed/clean.parquet" = "m3n4o5p6..."On each run, pytask:
- Reads
pytask.lock(if present). - Compares current dependency/product/task
state()to storedstate. - Skips tasks whose states match; runs the rest.
- Updates
pytask.lockafter each completed task (atomic write). - Updates
pytask.lockafter skipping unchanged tasks (unless--dry-runor--explainare active).
There are two portability concerns:
- IDs: Lockfile IDs must be project‑relative and stable across machines.
- State values:
stateis opaque; portability depends on each node’sstate()implementation. Content hashes are portable; timestamps are not.
Use pytask lock clean to rewrite pytask.lock with
only currently collected tasks. The command removes stale task entries without executing
tasks again.
| Field | Required | Description |
|---|---|---|
lock-version |
Yes | Schema version (currently "1") |
| Field | Required | Description |
|---|---|---|
id |
Yes | Portable task identifier |
state |
Yes | Opaque state string |
depends_on |
No | Mapping from node id to state |
produces |
No | Mapping from node id to state |
Node entries are stored as key-value pairs inside depends_on and produces, where the
key is the node id and the value is the node state string.
id in the lockfile is a portable identifier used to match entries across runs and
machines. It is not the same as a node or task signature used internally in the DAG.
signature: runtime identity in the in-memory DAG.id: portable lockfile key persisted topytask.lock.
When implementing custom nodes, keep lockfile IDs stable and unique within a task.
Only lock-version "1" is supported. Older or newer versions error with a clear upgrade
message.
- The lockfile is encoded/decoded with
msgspec’s TOML support. - Writes are atomic: pytask writes a temporary file and replaces
pytask.lock.