in text-semantic-search/semantic_search/utils/search.py [0:0]
def _download_from_gcs(gcs_services, bucket_name, gcs_location, local_file_name):
print('Downloading file {} to {}...'.format(
'gs://{}/{}'.format(bucket_name, gcs_location), local_file_name))
with open(local_file_name, 'wb') as file_writer:
request = gcs_services.objects().get_media(
bucket=bucket_name, object=gcs_location)
media = googleapiclient.http.MediaIoBaseDownload(
file_writer, request, chunksize=CHUNKSIZE)
download_complete = False
while not download_complete:
progress, download_complete = media.next_chunk()
print('File {} downloaded to {}.'.format(
'gs://{}/{}'.format(bucket_name, gcs_location), local_file_name))
print('File size: {} GB'.format(
round(os.path.getsize(local_file_name) / float(1024 ** 3), 2)))