---------------------------------------------------------------------------
TransportError Traceback (most recent call last)
/usr/local/lib/python3.10/dist-packages/google/auth/compute_engine/credentials.py in refresh(self, request)
127 try:
--> 128 self._retrieve_info(request)
129 self.token, self.expiry = _metadata.get_service_account_token(
/usr/local/lib/python3.10/dist-packages/google/auth/compute_engine/credentials.py in _retrieve_info(self, request)
100 """
--> 101 info = _metadata.get_service_account_info(
102 request, service_account=self._service_account_email
/usr/local/lib/python3.10/dist-packages/google/auth/compute_engine/_metadata.py in get_service_account_info(request, service_account)
322 # for more on the use of 'recursive'.
--> 323 return get(request, path, params={"recursive": "true"})
324
/usr/local/lib/python3.10/dist-packages/google/auth/compute_engine/_metadata.py in get(request, path, root, params, recursive, retry_count, headers, return_none_for_not_found_error)
247
--> 248 raise exceptions.TransportError(
249 "Failed to retrieve {} from the Google Compute Engine "
TransportError: ("Failed to retrieve http://metadata.google.internal/computeMetadata/v1/instance/service-accounts/default/?recursive=true from the Google Compute Engine metadata service. Status: 404 Response:\nb''", <google.auth.transport.requests._Response object at 0x7b0a4dd37e20>)
The above exception was the direct cause of the following exception:
RefreshError Traceback (most recent call last)
<ipython-input-5-7478255724ae> in <cell line: 1>()
----> 1 with gs_open_default(path) as f:
2 print(len(f.read()))
<ipython-input-3-0131ff1af10c> in gs_open_default(path)
7 def gs_open_default(path):
8 fs = gcsfs.GCSFileSystem()
----> 9 return fs.open(path, 'rb')
/usr/local/lib/python3.10/dist-packages/fsspec/spec.py in open(self, path, mode, block_size, cache_options, compression, **kwargs)
1291 else:
1292 ac = kwargs.pop("autocommit", not self._intrans)
-> 1293 f = self._open(
1294 path,
1295 mode=mode,
/usr/local/lib/python3.10/dist-packages/gcsfs/core.py in _open(self, path, mode, block_size, cache_options, acl, consistency, metadata, autocommit, fixed_key_metadata, generation, **kwargs)
1514 block_size = self.default_block_size
1515 const = consistency or self.consistency
-> 1516 return GCSFile(
1517 self,
1518 path,
/usr/local/lib/python3.10/dist-packages/gcsfs/core.py in __init__(self, gcsfs, path, mode, block_size, autocommit, cache_type, cache_options, acl, consistency, metadata, content_type, timeout, fixed_key_metadata, generation, **kwargs)
1673 raise OSError("Attempt to open a bucket")
1674 self.generation = _coalesce_generation(generation, path_generation)
-> 1675 super().__init__(
1676 gcsfs,
1677 path,
/usr/local/lib/python3.10/dist-packages/fsspec/spec.py in __init__(self, fs, path, mode, block_size, autocommit, cache_type, cache_options, size, **kwargs)
1649 self.size = size
1650 else:
-> 1651 self.size = self.details["size"]
1652 self.cache = caches[cache_type](
1653 self.blocksize, self._fetch_range, self.size, **cache_options
/usr/local/lib/python3.10/dist-packages/gcsfs/core.py in details(self)
1709 def details(self):
1710 if self._details is None:
-> 1711 self._details = self.fs.info(self.path, generation=self.generation)
1712 return self._details
1713
/usr/local/lib/python3.10/dist-packages/fsspec/asyn.py in wrapper(*args, **kwargs)
116 def wrapper(*args, **kwargs):
117 self = obj or args[0]
--> 118 return sync(self.loop, func, *args, **kwargs)
119
120 return wrapper
/usr/local/lib/python3.10/dist-packages/fsspec/asyn.py in sync(loop, func, timeout, *args, **kwargs)
101 raise FSTimeoutError from return_result
102 elif isinstance(return_result, BaseException):
--> 103 raise return_result
104 else:
105 return return_result
/usr/local/lib/python3.10/dist-packages/fsspec/asyn.py in _runner(event, coro, result, timeout)
54 coro = asyncio.wait_for(coro, timeout=timeout)
55 try:
---> 56 result[0] = await coro
57 except Exception as ex:
58 result[0] = ex
/usr/local/lib/python3.10/dist-packages/gcsfs/core.py in _info(self, path, generation, **kwargs)
957 # Check exact file path
958 try:
--> 959 exact = await self._get_object(path)
960 # this condition finds a "placeholder" - still need to check if it's a directory
961 if exact["size"] or not exact["name"].endswith("/"):
/usr/local/lib/python3.10/dist-packages/gcsfs/core.py in _get_object(self, path)
514 # fall back to a bucket list + filter to object name (storage.objects.list).
515 try:
--> 516 res = await self._call(
517 "GET", "b/{}/o/{}", bucket, key, json_out=True, generation=generation
518 )
/usr/local/lib/python3.10/dist-packages/gcsfs/core.py in _call(self, method, path, json_out, info_out, *args, **kwargs)
435 ):
436 logger.debug(f"{method.upper()}: {path}, {args}, {kwargs.get('headers')}")
--> 437 status, headers, info, contents = await self._request(
438 method, path, *args, **kwargs
439 )
<decorator-gen-119> in _request(self, method, path, headers, json, data, *args, **kwargs)
/usr/local/lib/python3.10/dist-packages/gcsfs/retry.py in retry_request(func, retries, *args, **kwargs)
151 if retry == retries - 1:
152 logger.exception(f"{func.__name__} out of retries on exception: {e}")
--> 153 raise e
154 if is_retriable(e):
155 logger.debug(f"{func.__name__} retrying after exception: {e}")
/usr/local/lib/python3.10/dist-packages/gcsfs/retry.py in retry_request(func, retries, *args, **kwargs)
121 if retry > 0:
122 await asyncio.sleep(min(random.random() + 2 ** (retry - 1), 32))
--> 123 return await func(*args, **kwargs)
124 except (
125 HttpError,
/usr/local/lib/python3.10/dist-packages/gcsfs/core.py in _request(self, method, path, headers, json, data, *args, **kwargs)
419 params=self._get_params(kwargs),
420 json=json,
--> 421 headers=self._get_headers(headers),
422 data=data,
423 timeout=self.requests_timeout,
/usr/local/lib/python3.10/dist-packages/gcsfs/core.py in _get_headers(self, headers)
398 if "User-Agent" not in out:
399 out["User-Agent"] = "python-gcsfs/" + version
--> 400 self.credentials.apply(out)
401 return out
402
/usr/local/lib/python3.10/dist-packages/gcsfs/credentials.py in apply(self, out)
185 def apply(self, out):
186 """Insert credential headers in-place to a dictionary"""
--> 187 self.maybe_refresh()
188 if self.credentials is not None:
189 self.credentials.apply(out)
/usr/local/lib/python3.10/dist-packages/gcsfs/credentials.py in maybe_refresh(self)
180 return # repeat to avoid race (but don't want lock in common case)
181 logger.debug("GCS refresh")
--> 182 self.credentials.refresh(req)
183 self.apply(self.heads)
184
/usr/local/lib/python3.10/dist-packages/google/auth/compute_engine/credentials.py in refresh(self, request)
132 except exceptions.TransportError as caught_exc:
133 new_exc = exceptions.RefreshError(caught_exc)
--> 134 raise new_exc from caught_exc
135
136 @property
RefreshError: ("Failed to retrieve http://metadata.google.internal/computeMetadata/v1/instance/service-accounts/default/?recursive=true from the Google Compute Engine metadata service. Status: 404 Response:\nb''", <google.auth.transport.requests._Response object at 0x7b0a4dd37e20>)