Skip to content

Commit d3f7a40

Browse files
authored
Merge pull request #142 from PolicyEngine/350_revert
Revert "Merge pull request #133 from PolicyEngine/350_use_caching_goo…
2 parents 70df911 + 043a210 commit d3f7a40

File tree

3 files changed

+19
-62
lines changed

3 files changed

+19
-62
lines changed

changelog_entry.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
- bump: patch
2+
changes:
3+
fixed:
4+
- revert cached downloads from google storage
Lines changed: 15 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,3 @@
1-
from .data.caching_google_storage_client import CachingGoogleStorageClient
2-
import asyncio
3-
from pathlib import Path
4-
5-
_caching_client: CachingGoogleStorageClient | None = None
6-
7-
8-
def _clear_client():
9-
global _caching_client
10-
_caching_client = None
11-
12-
13-
def _get_client():
14-
global _caching_client
15-
if _caching_client is not None:
16-
return _caching_client
17-
_caching_client = CachingGoogleStorageClient()
18-
return _caching_client
19-
20-
211
def download_file_from_gcs(
222
bucket_name: str, file_name: str, destination_path: str
233
) -> None:
@@ -32,6 +12,18 @@ def download_file_from_gcs(
3212
Returns:
3313
None
3414
"""
35-
asyncio.run(
36-
_get_client().download(bucket_name, file_name, Path(destination_path))
37-
)
15+
from google.cloud import storage
16+
17+
# Initialize a client
18+
client = storage.Client()
19+
20+
# Get the bucket
21+
bucket = client.bucket(bucket_name)
22+
23+
# Create a blob object from the file name
24+
blob = bucket.blob(file_name)
25+
26+
# Download the file to a local path
27+
blob.download_to_filename(destination_path)
28+
29+
return destination_path

tests/utils/data/test_google_cloud_bucket.py

Lines changed: 0 additions & 39 deletions
This file was deleted.

0 commit comments

Comments
 (0)