Skip to content
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

Provide key/object_name/blob attribute in CloudPath #300

Open
Dev-iL opened this issue Oct 21, 2024 · 3 comments
Open

Provide key/object_name/blob attribute in CloudPath #300

Dev-iL opened this issue Oct 21, 2024 · 3 comments
Labels
enhancement 🚀 New feature or request

Comments

@Dev-iL
Copy link

Dev-iL commented Oct 21, 2024

Suppose I have a remote path as follows:

gcs_path = GCSPath("gs://bucket-name/A/B/C/filename.tar.gz")

I'd like a way to get a UPath object that represents the location in the bucket, e.g.

UPath("A/B/C/filename.tar.gz")

I'd like to avoid my present workaround of "/".join(gcs_path.parts[1:]) since it's not immediately clear what this code is doing.

Possibly related to #170

@ap--
Copy link
Collaborator

ap-- commented Oct 21, 2024

Can you provide more context?

The following style for creating paths is implemented for s3, gcs and az object storage:

>>> import upath
>>> upath.UPath("A/B/C/filename.tar.gz", protocol="gs", bucket="bucket-name")
GCSPath('gs://bucket-name/A/B/C/filename.tar.gz')

@ap-- ap-- changed the title [Feature request] Add way to access path-in-bucket for a CloudPath Add way to access path-in-bucket for a CloudPath Oct 21, 2024
@Dev-iL
Copy link
Author

Dev-iL commented Oct 21, 2024

I need the other way around.... I have a GCSPath object, now I'd like to extract the path itself (i.e. without the protocol and bucket) by using some of the methods/fields of the object. Is there a way to do that?

@ap--
Copy link
Collaborator

ap-- commented Oct 22, 2024

So from my understanding, to stay in the google storage vocabulary, you'd want the OBJECT_NAME, whereas right now you can only retrieve the PATH_TO_RESOURCE = BUCKET_NAME/OBJECT_NAME.

This will become generally available once either relative_to behaviour is fixed (which requires some more thought before rolling out) or url chaining is implemented #28 (you can then use dirfs to remove the prefix from path.)

@ap-- ap-- changed the title Add way to access path-in-bucket for a CloudPath Provide key/object_name/blob attribute in CloudPath Oct 22, 2024
@ap-- ap-- added the enhancement 🚀 New feature or request label Oct 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement 🚀 New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants