liormizr / s3path

s3path is a pathlib extension for AWS S3 Service
Apache License 2.0
206 stars 39 forks source link

missing a forward slash in S3Path object #146

Closed schultzm closed 7 months ago

schultzm commented 11 months ago

hi @liormizr ,

Perhaps this is intended behaviour, but this give me a problem:

from s3path import S3Path
fname = "s3://fastq-inbox/inbox/3_1.fastq.gz"
print(S3Path(fname))
print(fname)

I get:

s3:/fastq-inbox/inbox/3_1.fastq.gz
s3://fastq-inbox/inbox/3_1.fastq.gz

It shows that one forward slash disappears when I ask for an S3Path on an s3 URI.

But this works:

print(S3Path(fname.replace("s3:/", "")).as_uri())

to give:

s3://fastq-inbox/inbox/3_1.fastq.gz

I'm using v 0.5.0:

python3 -c 'import s3path; print(s3path.__version__)'
0.5.0
liormizr commented 11 months ago

Hi @schultzm This is wird I see this issue in old versions as well Did you upgraded the python version as well? I'm trying to understand when and from where this issue started

liormizr commented 11 months ago

AA OK @schultzm this is not a bug This is not how we use S3Path... :-) And this is not a new behaviour

You have few options how to write differently your code:

ether you give P3Path a path without the URI representation like this:

from s3path import S3Path
fname = "/fastq-inbox/inbox/3_1.fastq.gz"
print(S3Path(fname))
print(S3Path(fname).as_uri())

Or if you want to use URI you can do this:

from s3path import S3Path
fname = "s3://fastq-inbox/inbox/3_1.fastq.gz"
print(S3Path.from_uri(fname))
print(S3Path.from_uri(fname).as_uri())

You can see in the doc's that S3Path like the STD Path get path strings not uri's

liormizr commented 10 months ago

@schultzm can I close this issue or do you have some feedback?