Skip to content

Commit 4f6032f

Browse files
[CI] Support using blob prefix for downloading
So that uploading and downloading use the same file paths. Also refactor everything so that _get_blob_prefix is the common implementation.
1 parent ddf8cd3 commit 4f6032f

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

.ci/cache_lit_timing_files.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,13 @@
2222
GCS_PARALLELISM = 100
2323

2424

25+
def _get_blob_prefix():
26+
return f"lit_timing_{platform.system().lower()}"
27+
28+
2529
def _maybe_upload_timing_file(bucket, timing_file_path):
26-
blob_prefix = f"lit_timing_{platform.system().lower()}/"
2730
if os.path.exists(timing_file_path):
28-
timing_file_blob = bucket.blob(blob_prefix + timing_file_path)
31+
timing_file_blob = bucket.blob(_get_blob_prefix() + "/" + timing_file_path)
2932
timing_file_blob.upload_from_filename(timing_file_path)
3033

3134

@@ -45,14 +48,14 @@ def upload_timing_files(storage_client, bucket_name: str):
4548

4649

4750
def _maybe_download_timing_file(blob):
48-
file_name = blob.name.removeprefix("lit_timing/")
51+
file_name = blob.name.removeprefix(_get_blob_prefix() + "/")
4952
pathlib.Path(os.path.dirname(file_name)).mkdir(parents=True, exist_ok=True)
5053
blob.download_to_filename(file_name)
5154

5255

5356
def download_timing_files(storage_client, bucket_name: str):
5457
bucket = storage_client.bucket(bucket_name)
55-
blobs = bucket.list_blobs(prefix="lit_timing")
58+
blobs = bucket.list_blobs(prefix=_get_blob_prefix())
5659
with multiprocessing.pool.ThreadPool(GCS_PARALLELISM) as thread_pool:
5760
futures = []
5861
for timing_file_blob in blobs:

0 commit comments

Comments
 (0)