def download_gcs_file(path, out_fname=None, prefix_filter=None):
  """Download a file from GCS, optionally to a file."""
  url = posixpath.join(GCS_BUCKET, path)
  if prefix_filter:
    url += "?prefix=%s" % prefix_filter
  stream = bool(out_fname)
  resp = requests.get(url, stream=stream)
  if not resp.ok:
    raise ValueError("GCS bucket inaccessible")
  if out_fname:
    with tf.io.gfile.GFile(out_fname, "wb") as f:
      for chunk in resp.iter_content(1024):
        f.write(chunk)
  else:
    return resp.content
def download_gcs_file ( path , out_fname = None , prefix_filter = None ) : url = posixpath . join ( GCS_BUCKET , path ) if prefix_filter : url += "?prefix=%s" % prefix_filter stream = bool ( out_fname ) resp = requests . get ( url , stream = stream ) if not resp . ok : raise ValueError ( "GCS bucket inaccessible" ) if out_fname : with tf . io . gfile . GFile ( out_fname , "wb" ) as f : for chunk in resp . iter_content ( 1024 ) : f . write ( chunk ) else : return resp . content
Download a file from GCS, optionally to a file.