-
Notifications
You must be signed in to change notification settings - Fork 94
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Move files from temporary directory changer #2022
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like the move doesn't work with windows/mac.
But I'd like to make a higher level comment. The secret overwriting of shutil.copy is something I want to remove from ARMI (i.e., I want to go change all the instances of shutil.copy
to explicitly use safeCopy
instead, then remove the overwrite. See #1690.
Maybe for this update it makes sense to keep the same scheme and we just tack this onto that tech debt payoff since it won't really be causing any extra work.
But I'd also be happy if the shutil.move
calls were just safeMove
instead. :-)
I didn't touch It's also weird that the existing unit test of Edit: It looks like the problem was the "windows-like" file path |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great!
I note we already have a ticket for this: #1690 But I think Michael's PR doesn't touch that, because he didn't alter |
Yep! the first iteration in this PR had a similar setup, (where shutil.move was overwritten with |
…pin-dep * origin/main: Moving from shutil.copy to safeCopy (#2024) Move files from temporary directory changer (#2022) Handling checking for OSs better (#2023) Expose some skip inspection options for `armi.init` and `db.loadOperator` (#2005) Adding setting to control MCNP / ENDF library (#1989) Improving logging on ISOTXS compare (#2013)
What is the change?
Use
shutil.move
/mv
instead ofshutil.copy
/cp
to move files from temporary directory back to the original working directory on__exit__
.Why is the change being made?
Copying files from one location to another keeps the original file intact, but the original files in a temporary directory do not need to be kept around after the
__exit__
from theTemporaryDirectoryChanger
. These files are immediately deleted after the copy operation is completed.Using
shutil.move()
is significantly faster thanshutil.copy()
when the source and destination locations are on the same drive, since the data doesn't have to physically be copied to a new place in memory.Checklist
doc
folder.pyproject.toml
.