-
Notifications
You must be signed in to change notification settings - Fork 64
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
ENH: enable relative_to() between to cloud files #149
Comments
@remi-braun Definitely not an unreasonable request. The reason that we don't currently have relative paths, just absolute paths. For example., We could implement That said, for the particular use case you lay out, In [1]: from cloudpathlib import CloudPath
In [2]: CloudPath("s3://my-bucket/END_TO_END_RESULTS/INDEX/result.tif").key
Out[2]: 'END_TO_END_RESULTS/INDEX/result.tif' |
Oh I understand, your point is, in my opinion, very relevant. My workaround is in my case (I need a str and it should be OK since there are no relative paths for CloudPath): if isinstance(file, CloudPath):
rel_path = str(file).replace(str(res_dir), "")
else:
rel_path = file.relative_to(res_dir) |
Both Obviously there are some cases where the resulting Path cannot be used to recreate the original path Support for relative is important when you are mapping files between two different file systems relative to |
Some notes from @Gilthans from #229:
|
Fixed with #232 |
Hello,
Is there any drowbacks to implement
relative_to
for Cloud paths ?For example my usecase is:
And I would like to retrieve the relative path between the 2, a.k.a :
"/END_TO_END_RESULTS/INDEX/result.tif"
.Does it make sense ? I am not very familiar with the cloud paths usages.
The text was updated successfully, but these errors were encountered: