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

Return url for file in GCP public bucket instead of error #748

Merged
merged 2 commits into from
Dec 26, 2024

Conversation

dreadatour
Copy link
Contributor

@dreadatour dreadatour commented Dec 25, 2024

When retrieving URL for file in GCP bucket if this bucket is public and we have no GCP credentials set, error will be raised.

In this PR we are returning public download URL in this case instead of exception.

Note: I think we need to do the same for other types of storages.

@dreadatour dreadatour requested a review from a team December 25, 2024 17:54
@dreadatour dreadatour self-assigned this Dec 25, 2024
Copy link

cloudflare-workers-and-pages bot commented Dec 26, 2024

Deploying datachain-documentation with  Cloudflare Pages  Cloudflare Pages

Latest commit: d2e2e06
Status: ✅  Deploy successful!
Preview URL: https://e72679fe.datachain-documentation.pages.dev
Branch Preview URL: https://gcp-get-public-bucket-file-u.datachain-documentation.pages.dev

View logs

Copy link

codecov bot commented Dec 26, 2024

Codecov Report

Attention: Patch coverage is 75.00000% with 2 lines in your changes missing coverage. Please review.

Project coverage is 87.46%. Comparing base (60256d6) to head (d2e2e06).
Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
src/datachain/client/gcs.py 75.00% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #748      +/-   ##
==========================================
- Coverage   87.47%   87.46%   -0.01%     
==========================================
  Files         114      114              
  Lines       10941    10949       +8     
  Branches     1504     1505       +1     
==========================================
+ Hits         9571     9577       +6     
- Misses        992      993       +1     
- Partials      378      379       +1     
Flag Coverage Δ
datachain 87.40% <75.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@dreadatour dreadatour merged commit 46aa4ad into main Dec 26, 2024
33 of 34 checks passed
@dreadatour dreadatour deleted the gcp-get-public-bucket-file-url branch December 26, 2024 15:36
return self.fs.sign(self.get_full_path(path), expiration=expires, **kwargs)
except AttributeError as exc:
is_anon = self.fs.storage_options.get("token") == "anon"
if is_anon and "you need a private key to sign credentials" in str(exc):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a few questions come to my mind: :)

can we return a public link right away if anon is set to True?

is there any guarantee that HTTP link this always work for public buckets?

do we do anything like this for S3? if not, why?

when does this error happen?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a few questions come to my mind: :)

These are good questions! 👍

can we return a public link right away if anon is set to True?

Yes, we can. I doubted about chosen option here and still not sure, but on the other side I just wanted to be sure I will not break any existing use case.

is there any guarantee that HTTP link this always work for public buckets?

Yes: https://cloud.google.com/storage/docs/access-public-data#api-link

do we do anything like this for S3? if not, why?

We definitely should do the same for other types of storages. I am not doing it here for some reasons:

  • I wanted to check first if this will solve all the issues in SaaS
  • it will requires more work and proper tests, I am not sure we have capacity now for this (fix for GCP was quick and simple)

when does this error happen?

Original issue is here: https://github.com/iterative/studio/issues/11118

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Original issue is here: https://github.com/iterative/studio/issues/11118

yep, I understand. I guess my question is why it is happening. If anon it passed AFAIU it should not be even trying to use credentials (I assume it is failing on a cluster because some default Google cred are present, right?)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep, I understand. I guess my question is why it is happening. If anon it passed AFAIU it should not be even trying to use credentials (I assume it is failing on a cluster because some default Google cred are present, right?)

Ah, got it. It is failing not in a workers cluster, but on the backend (API request). It is interesting, I can not find any default Google credentials on backend 🤔

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants