Create Copy/Temporary context managers #118
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In an effort to nicely handle potential use of SLURM
$MEMDIR
and$LOCALDIR
type local storage mechanisms I have attempted to spec out a couple context managers to help out.The idea being that on entry to the context the necessarily files are copied over to the compute node local storage space while creating folders along the way, work is performed (e.g. wsclean on the local copy), and output files are copied back.
There are two managers:
temporarily_move_into
: a subject directory or file is temporarily copied over to a temporary folder, work is performed, and it is copied back. The subject is the only item intended to be moved back, other files created along the way may not be.hold_then_move_into
: a folder if created where anything inside of it at the end of the context manager is copied over to the final directory.Very much a toy at this point, but tests in
tests/test_utils.py
seem to mock up the expected behaviour with the use cases I have in mind. Likely can be evolved, e.g. add some extra files to place intohold_then_move_into
on that folders creation.