Skip to content

Commit 6d68206

Browse files
committed
docs: rewrite article about moving projects
1 parent d644e5e commit 6d68206

4 files changed

Lines changed: 79 additions & 97 deletions

File tree

docs/source/how_to_guides/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ specific tasks with pytask.
99

1010
- [Migrating From Scripts To Pytask](migrating_from_scripts_to_pytask.md)
1111
- [Interfaces For Dependencies Products](interfaces_for_dependencies_products.md)
12-
- [Portability](portability.md)
12+
- [Move a Project to Another Machine](move_project_to_another_machine.md)
1313
- [Remote Files](remote_files.md)
1414
- [Functional Interface](functional_interface.md)
1515
- [Capture Warnings](capture_warnings.md)
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
# Move a Project to Another Machine
2+
3+
This guide teaches you how to move a pytask project to another machine or environment
4+
and reuse existing outputs where possible.
5+
6+
## Update the lockfile on the source machine
7+
8+
Run a normal build with [`pytask build`](../reference_guides/commands.md#pytask-build)
9+
before moving the project with its `pytask.lock` and files and outputs are up-to-date:
10+
11+
```console
12+
$ pytask build
13+
```
14+
15+
## Move the project files and reusable outputs
16+
17+
If you have not done it yet, commit `pytask.lock` to your repository and move it with
18+
the project. In practice, move:
19+
20+
- the project files tracked in version control, including source files, configuration,
21+
data inputs, and `pytask.lock`
22+
- the build artifacts you want to reuse, often in `bld/` if you follow the tutorial
23+
layout
24+
- the `.pytask` folder if you use the data catalog and it manages some of your files
25+
26+
## Keep external files in the same relative layout
27+
28+
If tasks use files outside the project root, keep the same relative layout on the target
29+
machine. The project root is the folder with the `pyproject.toml` file.
30+
31+
For example, if a task reads `../shared/input.csv` from the source machine, the moved
32+
project also needs a readable `../shared/input.csv` next to the project root on the
33+
target machine.
34+
35+
## Run pytask on the target machine
36+
37+
After you moved the project to the target machine, run pytask to build the project:
38+
39+
```console
40+
$ pytask build
41+
```
42+
43+
Assuming that the project was fully built before the move, pytask will not rebuild the
44+
project and skip all tasks.
45+
46+
## Clean stale lockfile entries
47+
48+
If you removed, renamed, or moved tasks before transferring the project, clean up stale
49+
lockfile entries on the source machine before you move the project:
50+
51+
```console
52+
$ pytask build --clean-lockfile
53+
```
54+
55+
This rewrites the lockfile after a successful build with only the currently collected
56+
tasks and their current state values.
57+
58+
## If your project uses custom nodes
59+
60+
Make sure custom node IDs and state values stay stable across machines:
61+
62+
- Use project-relative IDs instead of absolute paths.
63+
- Prefer file content hashes over timestamps.
64+
- Avoid machine-specific paths or timestamps in custom
65+
[`state()`](../api/nodes_and_tasks.md#pytask.PNode.state) implementations.
66+
- Provide a custom hash function for
67+
[`PythonNode`](../api/nodes_and_tasks.md#pytask.PythonNode) values that are not
68+
natively stable.
69+
70+
Most projects that only use built-in nodes do not need extra work here.
71+
72+
!!! seealso
73+
74+
The lockfile format and behavior are documented in the
75+
[reference guide](../reference_guides/lockfile.md). For custom nodes, see
76+
[Writing custom nodes](writing_custom_nodes.md). For hashing guidance, see
77+
[Hashing inputs of tasks](hashing_inputs_of_tasks.md).

docs/source/how_to_guides/portability.md

Lines changed: 0 additions & 95 deletions
This file was deleted.

mkdocs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ nav:
3737
- Overview: how_to_guides/index.md
3838
- Migrating From Scripts To pytask: how_to_guides/migrating_from_scripts_to_pytask.md
3939
- Interfaces For Dependencies And Products: how_to_guides/interfaces_for_dependencies_products.md
40-
- Portability: how_to_guides/portability.md
40+
- Move a Project to Another Machine: how_to_guides/move_project_to_another_machine.md
4141
- Remote Files: how_to_guides/remote_files.md
4242
- Functional Interface: how_to_guides/functional_interface.md
4343
- Capture Warnings: how_to_guides/capture_warnings.md

0 commit comments

Comments
 (0)