Relocate
relocate
Move a dataset left by the previous layout into the place it belongs now.
A tree fetched before the current layout existed holds directories such as
stellar_evolution_tracks/Baraffe. Unmigrated code still reads them, so
they are left alone and age out as their consumers migrate. That is the right
default and the wrong one for anybody who wants the tree tidy today, which is
what this does: it finds the datasets an installed manifest declares, works
out where each one used to live, and moves the files across.
Nothing is moved on trust. Every present file is hashed against the registry the manifest ships before anything is touched, and only a file that matches moves; a present file whose contents do not match blocks the whole dataset, so an absent file can never mask a corrupt one. A file already at the new location is not replaced: an intact one is skipped and a differing one blocks the dataset. A legacy tree holding none of its registry's files is reported and left exactly where it is. The alternative, moving first and discovering afterwards, turns a stale copy into a stale copy in the place the fetcher will now believe.
Nothing is downloaded either. A dataset moved with some registry files still absent stays that way at its new location; the fetcher is what fills it in, once the move has happened.
A dataset packaged as an archive is reported rather than moved. Its registry pins the packed archive, and a legacy tree holds the extracted members, so there is nothing to hash the tree against.
A run assumes that no other process renames or replaces directories under the data root while it moves files. Unlike a deletion, a move does not check the fetch lock, so a fetch running at the same time is not detected at all; do not relocate while a fetch could be running.
Relocation(key, state, legacy_dir=None, target_dir=None, files=(), detail='', legacy_present=False)
dataclass
One dataset's legacy tree, and what can be done with it.
faulty
property
True when a legacy tree is present but was not usable.
summary()
One line a person reads, naming the dataset and its outcome.
Source code in src/fwl_io/relocate.py
98 99 100 101 102 103 104 105 | |
RelocationReport(entries=(), manifest_errors=dict(), layout_error=None)
dataclass
Every dataset considered, whether or not anything happened to it.
manifest_errors is carried beside them because a manifest that failed
to load, or was dropped for a conflict, declares datasets nobody here got to
look at. Without it a report
covering nothing would read exactly like a tree with nothing left to move.
Each is a ProviderError, whose kind tells a conflict from a load
failure, so the summary can tell a caller which repair applies.
faults
property
Legacy trees that are present and could not be moved.
moved
property
Datasets whose files were moved into the current layout.
ok
property
True when every legacy tree found was dealt with and none was skipped.
ready
property
Datasets whose legacy tree checks out and is waiting to be moved.
redundant
property
Datasets whose old copy is still on disk beside the current one.
Nothing here removes it, so it is worth counting: this is the disk the user can reclaim by hand, and it is the whole reason to run the command against a tree where every dataset has already been refetched.
summary()
A short report, one line per dataset plus a closing count.
Source code in src/fwl_io/relocate.py
157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 | |
plan_relocations(data_root=None)
Report what a relocation would do, touching nothing.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data_root
|
str | Path | None
|
Override for the data root; defaults to the resolved FWL_DATA tree. |
None
|
Returns:
| Type | Description |
|---|---|
RelocationReport
|
One entry per dataset that declares a legacy location, whether or not that location exists on this machine. |
Source code in src/fwl_io/relocate.py
548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 | |
relocate_all(data_root=None, dry_run=False)
Move every legacy tree that checks out into the current layout.
Every present file in the legacy location that matches its recorded digest moves; an absent file is reported for the fetcher to fill in at the new location. A present file that does not match its digest, or a legacy tree holding none of its registry's files, is reported and left untouched, as is a dataset already at its current location, which is the ordinary state once a fetch has happened there.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data_root
|
str | Path | None
|
Override for the data root; defaults to the resolved FWL_DATA tree. |
None
|
dry_run
|
bool
|
Report what would move without moving it. |
False
|
Returns:
| Type | Description |
|---|---|
RelocationReport
|
The plan, with each moved dataset's entry rewritten to say so. |
Source code in src/fwl_io/relocate.py
773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 | |