1- # Reconciling Lockfile State
1+ # Update the Lockfile to Match Project State
22
33Use [ ` pytask lock ` ] ( ../reference_guides/commands.md#pytask-lock ) when the current files
4- in the project are already correct and only the recorded state in ` pytask.lock ` needs to
5- catch up.
4+ and outputs in the project are already correct, but the recorded state in ` pytask.lock `
5+ needs to catch up. This can happen after refactoring task files, moving or renaming
6+ tasks, producing outputs outside of pytask, or deleting tasks.
67
7- ## When is this useful?
8+ ## Accept current files and outputs
89
9- Typical situations are:
10-
11- - You reformatted or reorganized a task file and do not want to rerun an expensive task.
12- - You renamed or moved a task and want to accept the current outputs for the new task.
13- - You produced outputs outside of pytask and now want to register the task along the
14- outputs in the lockfile.
15- - You deleted or renamed tasks and want to remove their stale lockfile entries.
10+ Use [ ` pytask lock accept ` ] ( ../reference_guides/commands.md#pytask-lock-accept ) when the
11+ current dependencies, products, and task definition are already correct and should
12+ become the new recorded state.
1613
17- ## Preview changes first
14+ Preview the changes without writing them with ` --dry-run ` :
1815
19- By default, ` pytask lock ` runs interactively. It shows the planned changes and then asks
20- for confirmation one by one. Only entries which would actually change appear in the
21- prompt sequence.
16+ --8<-- "docs/source/_ static/md/lock-accept-dry-run.md"
2217
23- To preview changes without writing them, use ` --dry-run ` :
18+ Then accept the planned changes interactively :
2419
25- --8<-- "docs/source/_ static/md/lock-accept-dry-run .md"
20+ --8<-- "docs/source/_ static/md/lock-accept-interactive .md"
2621
27- To apply all planned changes without prompting, use ` --yes ` :
22+ Add ` --yes ` to apply all planned changes without prompting:
2823
2924``` console
3025$ pytask lock accept -k train --yes
3126```
3227
33- ## Accept the current state
34-
35- Use [ ` pytask lock accept ` ] ( ../reference_guides/commands.md#pytask-lock-accept ) when the
36- current dependencies, products, and task definition are already correct and should
37- become the new recorded state.
38-
39- --8<-- "docs/source/_ static/md/lock-accept-interactive.md"
40-
4128If no selectors are provided, ` pytask lock accept ` applies to all collected tasks in the
4229provided paths.
4330
@@ -60,58 +47,73 @@ $ pytask lock accept -k "train or evaluate"
6047If a selected task is missing a required dependency or product, the command fails
6148instead of accepting incomplete state.
6249
63- ## Reset recorded state
50+ Run a build afterwards to check that unchanged tasks are skipped according to the
51+ updated lockfile.
52+
53+ ``` console
54+ $ pytask build
55+ ```
56+
57+ ## Reset state for selected tasks
6458
6559Use [ ` pytask lock reset ` ] ( ../reference_guides/commands.md#pytask-lock-reset ) to remove
66- recorded state for selected tasks. The following command removes the recorded state for
67- all tasks.
60+ recorded state for selected tasks when state was accepted too broadly or when specific
61+ tasks should be reconsidered from scratch .
6862
6963``` console
70- $ pytask lock reset
64+ $ pytask lock reset -k train
7165```
7266
7367Unlike ` accept ` , ` reset ` with a selector works on the exact selected tasks. It does not
7468automatically include ancestors.
7569
70+ Preview the reset with ` --dry-run ` if you want to check the affected tasks first:
71+
7672``` console
77- $ pytask lock reset -k train
73+ $ pytask lock reset -k train --dry-run
74+ ```
75+
76+ Add ` --yes ` to remove all planned entries without prompting:
77+
78+ ``` console
79+ $ pytask lock reset -k train --yes
7880```
7981
80- On the next build, ` pytask ` determines again whether these tasks require execution. This
81- is useful when state was accepted too broadly or when you want a specific task to be
82- reconsidered from scratch.
82+ If no selectors are provided, ` pytask lock reset ` removes the recorded state for all
83+ collected tasks in the provided paths.
84+
85+ Run a build afterwards so ` pytask ` determines again whether the selected tasks require
86+ execution.
87+
88+ ``` console
89+ $ pytask build
90+ ```
8391
84- ## Remove stale lockfile entries
92+ ## Remove stale entries for deleted or moved tasks
8593
8694Use [ ` pytask lock clean ` ] ( ../reference_guides/commands.md#pytask-lock-clean ) to remove
8795entries from the lockfile which no longer correspond to collected tasks in the current
88- project.
96+ project. This is useful after deleting, renaming, or moving tasks when old entries
97+ should no longer remain in the lockfile.
8998
90- --8<-- "docs/source/ _ static/md/lock-clean.md"
99+ Preview stale entries without writing them with ` --dry-run ` :
91100
92- This is useful after deleting, renaming, or moving tasks when old entries should no
93- longer remain in the lockfile.
101+ ``` console
102+ $ pytask lock clean --dry-run
103+ ```
94104
95- ## Example workflow
105+ Then remove stale entries interactively:
96106
97- One common workflow looks like this:
107+ --8<-- "docs/source/ _ static/md/lock-clean.md"
98108
99- 1 . Run a normal build once.
100- 1 . Change a task file in a way that should not force a rerun.
101- 1 . Accept the current state.
102- 1 . Verify that a later build skips the task.
103- 1 . Reset the task if you want ` pytask ` to reconsider it again.
109+ Add ` --yes ` to remove all stale entries without prompting:
104110
105111``` console
106- $ pytask build
107- $ pytask lock accept -k train --yes
108- $ pytask build
109- $ pytask lock reset -k train --yes
110- $ pytask build
112+ $ pytask lock clean --yes
111113```
112114
113- After ` accept ` , the next build skips unchanged tasks according to the updated lockfile.
114- After ` reset ` , the selected tasks are reconsidered on the next build .
115+ ` clean ` only removes entries for tasks which are no longer collected. It does not accept
116+ or update the current state of collected tasks .
115117
116118## Related
117119
0 commit comments