Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions changelog_entry.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
- bump: patch
changes:
fixed:
- revert cached downloads from google storage
38 changes: 15 additions & 23 deletions policyengine/utils/google_cloud_bucket.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,3 @@
from .data.caching_google_storage_client import CachingGoogleStorageClient
import asyncio
from pathlib import Path

_caching_client: CachingGoogleStorageClient | None = None


def _clear_client():
global _caching_client
_caching_client = None


def _get_client():
global _caching_client
if _caching_client is not None:
return _caching_client
_caching_client = CachingGoogleStorageClient()
return _caching_client


def download_file_from_gcs(
bucket_name: str, file_name: str, destination_path: str
) -> None:
Expand All @@ -32,6 +12,18 @@ def download_file_from_gcs(
Returns:
None
"""
asyncio.run(
_get_client().download(bucket_name, file_name, Path(destination_path))
)
from google.cloud import storage

# Initialize a client
client = storage.Client()

# Get the bucket
bucket = client.bucket(bucket_name)

# Create a blob object from the file name
blob = bucket.blob(file_name)

# Download the file to a local path
blob.download_to_filename(destination_path)

return destination_path
39 changes: 0 additions & 39 deletions tests/utils/data/test_google_cloud_bucket.py

This file was deleted.

Loading