Anonymous access of GCP bucket fails with `ValueError: Anonymous credentials cannot be refreshed.`
See original GitHub issueAffects modelstore 0.0.74.
To reproduce:
# create a new environment (Python 3.8)
python -m venv env
source env/bin/activate
# install modelstore and GCP CLI
pip install modelstore google-cloud-storage
python
Python 3.8.8 (default, Apr 4 2021, 16:02:17)
[GCC 10.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from modelstore import ModelStore
>>> model_store = ModelStore.from_gcloud(bucket_name="xai-demo-models")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/kilian/Documents/Ulm/GitHub/modelstorereplica/env/lib/python3.8/site-packages/modelstore/model_store.py", line 90, in from_gcloud
return ModelStore(
File "<string>", line 4, in __init__
File "/home/kilian/Documents/Ulm/GitHub/modelstorereplica/env/lib/python3.8/site-packages/modelstore/model_store.py", line 105, in __post_init__
if not self.storage.validate():
File "/home/kilian/Documents/Ulm/GitHub/modelstorereplica/env/lib/python3.8/site-packages/modelstore/storage/gcloud.py", line 128, in validate
if not self.bucket.exists():
File "/home/kilian/Documents/Ulm/GitHub/modelstorereplica/env/lib/python3.8/site-packages/google/cloud/storage/bucket.py", line 843, in exists
client._get_resource(
File "/home/kilian/Documents/Ulm/GitHub/modelstorereplica/env/lib/python3.8/site-packages/google/cloud/storage/client.py", line 366, in _get_resource
return self._connection.api_request(
File "/home/kilian/Documents/Ulm/GitHub/modelstorereplica/env/lib/python3.8/site-packages/google/cloud/storage/_http.py", line 73, in api_request
return call()
File "/home/kilian/Documents/Ulm/GitHub/modelstorereplica/env/lib/python3.8/site-packages/google/api_core/retry.py", line 283, in retry_wrapped_func
return retry_target(
File "/home/kilian/Documents/Ulm/GitHub/modelstorereplica/env/lib/python3.8/site-packages/google/api_core/retry.py", line 190, in retry_target
return target()
File "/home/kilian/Documents/Ulm/GitHub/modelstorereplica/env/lib/python3.8/site-packages/google/cloud/_http/__init__.py", line 482, in api_request
response = self._make_request(
File "/home/kilian/Documents/Ulm/GitHub/modelstorereplica/env/lib/python3.8/site-packages/google/cloud/_http/__init__.py", line 341, in _make_request
return self._do_request(
File "/home/kilian/Documents/Ulm/GitHub/modelstorereplica/env/lib/python3.8/site-packages/google/cloud/_http/__init__.py", line 379, in _do_request
return self.http.request(
File "/home/kilian/Documents/Ulm/GitHub/modelstorereplica/env/lib/python3.8/site-packages/google/auth/transport/requests.py", line 526, in request
self.credentials.refresh(auth_request)
File "/home/kilian/Documents/Ulm/GitHub/modelstorereplica/env/lib/python3.8/site-packages/google/auth/credentials.py", line 173, in refresh
raise ValueError("Anonymous credentials cannot be refreshed.")
ValueError: Anonymous credentials cannot be refreshed.
I remember encountering and resolving this issue while working on #142. We should have a look at the changes introduced by #161.
Output of pip freeze
:
cachetools==5.0.0
certifi==2021.10.8
charset-normalizer==2.0.12
click==8.1.3
gitdb==4.0.9
GitPython==3.1.27
google-api-core==2.7.3
google-auth==2.6.6
google-cloud-core==2.3.0
google-cloud-storage==2.3.0
google-crc32c==1.3.0
google-resumable-media==2.3.2
googleapis-common-protos==1.56.0
idna==3.3
joblib==1.1.0
modelstore==0.0.74
numpy==1.22.3
protobuf==3.20.1
pyasn1==0.4.8
pyasn1-modules==0.2.8
requests==2.27.1
rsa==4.8
six==1.16.0
smmap==5.0.0
tqdm==4.64.0
urllib3==1.26.9
Issue Analytics
- State:
- Created a year ago
- Comments:11 (11 by maintainers)
Top Results From Across the Web
ValueError: Anonymous credentials cannot be refreshed #2925
I am using MLFLOW in colab notebook. I have set up tracking uri (google cloud bucket) . When I try to log params...
Read more >How to properly use create_anonymous_client() function in ...
Exception I am getting: ValueError: Anonymous credentials cannot be refreshed. Additional Query: Can I list and download contents of public ...
Read more >Troubleshooting | Cloud Storage
Issue : Requests to a public bucket directly, or via Cloud CDN, are failing with a HTTP 401: Unauthorized and an Authentication Required...
Read more >google.auth.credentials module
Raises ValueError` , anonymous credentials cannot be refreshed. Anonymous credentials do nothing to the request. The optional token argument is not supported. ......
Read more >google-auth Documentation - Read the Docs
an on-prem or non-Google Cloud platform including Amazon Web Services ... Raises ValueError`, anonymous credentials cannot be refreshed.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Just to confirm, this is how it looks for me now!
Okay, I think that this PR has the fix (based on the above):
Comments welcome & thanks for raising this again @ionicsolutions.
In short: I try
exists()
, if that fails with aValueError
, I try tolist_blobs()
; if that fails withNotFound
then the validation fails.