-
Notifications
You must be signed in to change notification settings - Fork 38
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
fix: expand ~ to user home dir #557
Open
jericht
wants to merge
1
commit into
aws-deadline:mainline
Choose a base branch
from
jericht:jericht/expanduser
base: mainline
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
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 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
This file contains 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
Oops, something went wrong.
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.
This place will call
expanduser()
on all calls toset_root_path
, but I doubt that's what we want to do. The original issue is about interactive user input, I think it's better to put this call immediately after that input is collected instead of inside this setter.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 we do want it in here since we make a call to
pathlib.Path.absolute()
which will prepend the current working directory to the path in cases where the path starts with~
, resulting in a root path like/home/jericht/~/tmp/123
, which is something we don't want in my opinion.We are applying
os.normpath
andpathlib.Path.absolute
to the path, so we're already not setting thenew_root
parameter as is to theself.outputs_by_root
dict. To me, this means the code is intended to "make sure the path is a valid root path". However, transforming a path like~/tmp/123
into something like/the/current/working/dir/~/tmp/123
, for example, seems like a bug. If the caller really wants to set a root path like/the/current/working/dir/~/tmp/123
by just passing in~/tmp/123
while the cwd is/the/current/working/dir/
, I think it's reasonable to have the caller pass in the absolute path in this case.I've updated the function docstring to make it clear that this happens along with the other transformations it applies to
new_root
.I tested this locally to make sure
expanduser
handles some edge cases I could think of correctly. If the path is already has the~
expanded, it won't attempt to expand it again creating an invalid path. Here are a few tests I ran locally.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.
side comment: Does this change also work for
deadline attachment download
?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 we do want this expansion to happen always in the setter, I think we should look more closely at where the value comes from currently, and where it could come from. Will this be surprising in any case?