-
Notifications
You must be signed in to change notification settings - Fork 217
fixing bug that could cause to silently overwrite an existing easyconfig when using --try-* #2635
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
ac07b75
fixing bug that could cause to silently overwrite an existing easyconfig
mboisson 4a7b9d1
add support to write_file to prevent overwriting existing files unles…
boegel b299861
don't blindly overwrite existing easyconfig files with --try-*
boegel b69f2b0
Merge branch 'develop' into fix-bug-tweak
boegel 54e7c20
Merge pull request #8 from boegel/fix-bug-tweak
mboisson 1e8c2e0
fix tweak_one test + remove duplicate check for forced overwriting of…
boegel 05718cc
Merge pull request #9 from boegel/fix-bug-tweak
mboisson c90bee8
renamed overwrite to always_overwrite
mboisson 9fc02a2
fix write_file tests after 'overwrite' argument was renamed to 'alway…
boegel abb8aa8
fix typo (allways_overwrite -> always_overwrite)
boegel 0c3e576
Merge pull request #10 from boegel/fix-bug-tweak
mboisson c7b3020
fixed docstring
mboisson File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
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.
@mboisson Shouldn't we do this in
dumpitself instead? We may be usingdumpis other places in the future...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.
We could. I went to the simplest and least intrusive. Note that there are two different code-paths that can write files, in tweak.py. The first one uses
write_file, the other one usesdump. The test was already around thewrite_filecall, but not around thedumppart. I am happy with whatever fix you or @ocaisa think is best.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.
In this case I really think doing it in
dumpitself makes more sense...I'm not sure why there are two code paths where one uses
write_fileand another usesdump, maybe @ocaisa knows?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.
There are two paths because one uses regex substitution and the other modifies the EasyConfig object and dumps the modified object.
Ultimately the dump method does use
write_fileso perhaps the question is whether we want to pass down options, the choices currently are: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.
Perhaps doing a backup is sufficient? That way nothing ever gets removed and no need for the force option
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.
I think write_file should at the very least issue a warning if not fail if it is going to be over-writing an existing file.
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.
If a backup is created, it will print a warning message for that.
But I agree with @mboisson here, it shouldn't overwrite existing files without
--force(and it should still create a backup if--forceis used).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.
@mboisson W.r.t. making
write_filefail hard rather than overwriting an existing file: we can't do that without breaking backward compatibility, changing that would likely break a lot of easyblocks. Also, always having to use force to makewrite_fileactually overwrite existing file would be a bit much, that's not standard semantics in Linux either...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.
So, how do we proceed? Are you saying that the original check that @mboisson had is appropriate then and maybe couple that with adding the backup kw in the dump?
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.
I took a look at it, the best way is to enhance
write_filea bit to optionally not blindly overwrite existing files, and then usewrite_filecorrectly in both places.Done in ComputeCanada#8