-
Notifications
You must be signed in to change notification settings - Fork 44
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
rename (move) file over different file system #234
Comments
Self comments from yesterday tests:
|
Hi @petrus-v Thank you for opening the issue. This is very much in scope for universal_pathlib. There is an open PR #225 that I still need to verify and merge, which provides better errors for the currently unsupported rename across filesystems. Please also see #227 for future additions once we rely on Python3.14+ upstream implementations in pathlib. That being said, cross-filesystem functionality could be added to # example how the feature could look like
>>> src = UPath("/tmp/somefile")
>>> src.write_text('hello world')
>>> dst = UPath("s3://mybucket/path/somefile")
>>> src.rename(dst)
Traceback (most recent call last):
...
ValueError("cross-filesystem rename is not permitted by default. Use `allow_protocols=['s3']`")
>>> src.rename(dst, allow_protocols=['s3'])
>>> dst.read_text()
'hello world' argument names are of course up for debate.
These might go away in the future once there is a reasonably well working implementation for relative UPaths. |
Hi ! Thanks taking time to reply, very appreciated.
That's nice upstream improvements 😍
I'm fine to implement the opt-in and will probably allow to set it globally from environment variables if you agree, something like this: def rename(dst, allow_protocols=None):
if allow_protocols is None:
allow_protocols = os.environ.get("UPATH_RENAME_ALLOW_PROTOCOLS", "").split(",")
... I like the idea that source code know about where are store data and separate configuration and usages.
sounds great 👍 |
I would like to be able to be able to rename/move a file over different file system.
Does it make sense, in this library to support such feature ?
This would let developers write something like this:
which would:
/tmp/local_file
to the s3 bucket:s3://my-bucket/destination
The text was updated successfully, but these errors were encountered: