Comments (4)
Hi @mberlinger3,
thank you for opening an issue! It seems as_uri
is broken in general for UPath.
An easy way would be to implement it as:
class UPath(...):
def as_uri(self):
return str(self)
would you be interested in adding tests and a patch in a PR?
Cheers,
Andreas 😃
from universal_pathlib.
Hi @mberlinger3,
thank you for opening an issue! It seems
as_uri
is broken in general for UPath. An easy way would be to implement it as:class UPath(...): def as_uri(self): return str(self)would you be interested in adding tests and a patch in a PR?
Cheers, Andreas smiley
I think this would make more sense on the non-local (cloud?) implementations because it looks like the as_uri() method is currently inherited from the standard pathlib implementation which is correct for local files. Perhaps a specific wrapper in the UPath class to explicitly call the pathlib implementation and separate methods for the differing schemes.
from universal_pathlib.
Local paths that aren't provided via a file uri are currently returned as their corresponding pathlib.PosixPath
and pathlib.WindowsPath
instances. (which is going to change in the near future, see: #90)
As it stands right now, as_uri
seems to be broken in general for all UPath
subclasses:
>>> import upath
>>> upath.UPath("file://a/b/c.dat").as_uri()
'file://file%3A//a/b/c.dat'
So a general fix in upath.UPath.as_uri
seems appropriate. If we add a test to upath/tests/cases.py
we can ensure that we do the right thing for the implemented subclasses and address potential issues there with custom implementations.
from universal_pathlib.
I see what is issue is here. If you instantiate UPath using a uri as above it breaks; however, if you use a file path then as_uri works as expected.
>>> from upath import UPath
>>> print( UPath("/a/b/c.dat").as_uri() )
file:///a/b/c.dat
This could likely be solved by a simple conditional to check if a scheme exists and pass it to pathlib if it doesn't. We could probably implement the scheme check as a simple property.
An alternative solution would be something like what s3path does. They have a method S3Path().from_uri(uri)
that takes in a uri while the base init assumes a path syntax.
from universal_pathlib.
Related Issues (20)
- is it possible to switch AWS_PROFILE/start a new Session completely for UPath pointing to S3? HOT 2
- AttributeError: _cparts HOT 1
- Moving files via `UPath.rename` to absolute path locations HOT 5
- Passing abfs as fs parameter to UPath fails. HOT 3
- SSH / SFTP Implementations HOT 4
- s3fs kwarg unexpected keyword argument in `AioSession` HOT 2
- Static analysis of types broken in `>=0.2.0` HOT 1
- Relative paths don't work when `_protocol_dispatch = False`. HOT 4
- Behaviour of joinpath when the second path has protocol HOT 6
- `relative_to` doesn't work for FilePath HOT 2
- `S3Path.touch` with `exist_ok=True` on existing file raises an error HOT 3
- v0.2.2 breaks SMBFilesystem HOT 4
- `pip install -e .` under Python 3.12.3, pip 24.0 fails because `description` is not dynamic HOT 8
- Support for huggingface filesystem `hf` protocol
- Test against 3.13
- Prepare for release v0.3.0
- `path.iterdir()` yields `path` itself as the first item (with S3) HOT 6
- Efficient copying via shutil HOT 4
- Investigate python3.12 http fs path parsing errors
- rename (move) file over different file system HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from universal_pathlib.