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
feat(dataset): use posix mv semantics when adding with destination #2612
Conversation
7102147
to
eb004b3
Compare
fdbbb13
to
961bd2f
Compare
961bd2f
to
22f2ea6
Compare
"""Add a file or directory from a local filesystem.""" | ||
src = Path(os.path.abspath(path)) | ||
action = "symlink" if external else "copy" |
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.
Not something you need to change here, but action
seems to be a good candidate for using an Enum
renku/core/management/datasets.py
Outdated
if multiple_sources and destination_exists and not destination_is_dir: | ||
raise errors.ParameterError(f"Destination is not a directory: '{destination}'") | ||
|
||
name = path.name if has_multiple_paths or (destination_exists and destination_is_dir) else "" |
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.
Also with the empty string path join
renku/core/utils/os.py
Outdated
@@ -59,22 +68,23 @@ def get_relative_paths(base: Union[Path, str], paths: List[Union[Path, str]]) -> | |||
return relative_paths | |||
|
|||
|
|||
def get_files_recursively(path: Path) -> Generator[Path, None, None]: |
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.
Not sure this is an issue, but the method is called get_files_recursively
but then the body is not actually recursive. Should this be
if not subpath.is_dir():
yield subpath
else:
yield from get_files_recursively(subpath)
?
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 renamed it to get_files
Description
Adding data to a dataset with passing a destination using
--destination
flag, acts similar to posixcp
andmv
commands: Added file is renamed it destination doesn't exists or it's a file and it's copied to the destination otherwise.Fixes #1765
Examples: