-
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
Default client on gce instances #191
Comments
Thanks @amardeep! Do you know the reliable way to test creating the client? Will the following raise an exception if there are no creds, or do we need to actually try to do something with the client?
If that raises, then we can add a try except in the else block here and have anonymous be the final fallback: https://github.com/drivendataorg/cloudpathlib/blob/master/cloudpathlib/gs/gsclient.py#L70-L77 |
Trying following code on non-gce and gce instances: from google.cloud import storage
storage_client = storage.Client() It succeeds on gce instances or non-gce instances with gcloud auth login done. On non-gce instances with no gcloud auth login or google credentials in environment, it fails with following trace:
|
@amardeep Thanks! We have a potential fix. Would you mind testing it on your GCE env and non-GCE env? You can install the branch with the fix by doing:
|
Thanks. Change looks fine. I tested it and it works with one issue which is probably an issue with storage client library. On non-gce machine with no credentials - it works fine with public buckets. For eg: from cloudpathlib import CloudPath
p = CloudPath("gs://tfds-data/datasets")
p1 = p / "mnist"
print(list(p1.glob("*")))
p2 = CloudPath("gs://<some privtate bucket>/")
print(list(p2.glob("*"))) First works and second fails as expected. On gce machine, both work as expected. On non-gce machine, with GOOGLE_APPLICATION_CREDENTIALS set, both work. On non-gce machine without GOOGLE_APPLICATION_CREDENTIALS but with gcloud auth login, it fails with following error, but i think it is an issue with storage client library, so the current change should be good.
|
Thanks for testing @amardeep. We'll see if we get any reported issues on that last scenario—maybe there's another branch to the logic here, but it seems like this fix should make more scenarios work smoothly for folks. |
Thanks a lot for the quick response :) |
With GOOGLE_APPLICATION_CREDENTIALS not set on gce instances, cloudpathlib operations such as
is_dir
fail:fails with:
On gce instances, storage client doesn't need any further auth setup. For eg., without GOOGLE_APPLICATION_CREDENTIALS set, this works:
and this also works:
It would be nice if this extra setup is not needed.
Maybe while constructing it can try creating non-anonymous storage client and if it fails create anonymous one.
The text was updated successfully, but these errors were encountered: