Skip to content

Commit d6d13b9

Browse files
committed
MaD generator: use decompress terminology instead of extract
1 parent e1eb1f6 commit d6d13b9

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

misc/scripts/models-as-data/bulk_generate_mad.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -360,8 +360,7 @@ def download_dca_databases(
360360

361361
artifact_map[pretty_name] = analyzed_database
362362

363-
def download_and_extract(item: tuple[str, dict]) -> str:
364-
pretty_name, analyzed_database = item
363+
def download_and_decompress(analyzed_database: dict) -> str:
365364
artifact_name = analyzed_database["artifact_name"]
366365
repository = analyzed_database["repository"]
367366
run_id = analyzed_database["run_id"]
@@ -378,7 +377,7 @@ def download_and_extract(item: tuple[str, dict]) -> str:
378377
artifact_zip_location = download_artifact(
379378
archive_download_url, artifact_name, pat
380379
)
381-
print(f"=== Extracting artifact: {artifact_name} ===")
380+
print(f"=== Decompressing artifact: {artifact_name} ===")
382381
# The database is in a zip file, which contains a tar.gz file with the DB
383382
# First we open the zip file
384383
with zipfile.ZipFile(artifact_zip_location, "r") as zip_ref:
@@ -396,21 +395,21 @@ def download_and_extract(item: tuple[str, dict]) -> str:
396395
# And we just untar it to the same directory as the zip file
397396
tar_ref.extractall(artifact_unzipped_location)
398397
ret = os.path.join(artifact_unzipped_location, language)
399-
print(f"Extraction complete: {ret}")
398+
print(f"Decompression complete: {ret}")
400399
return ret
401400

402401
results = run_in_parallel(
403-
download_and_extract,
404-
list(artifact_map.items()),
405-
on_error=lambda item, exc: print(
406-
f"ERROR: Failed to download database for {item[0]}: {exc}"
402+
download_and_decompress,
403+
list(artifact_map.values()),
404+
on_error=lambda db, exc: print(
405+
f"ERROR: Failed to download and decompress {db["artifact_name"]}: {exc}"
407406
),
408407
error_summary=lambda failures: print(
409408
f"ERROR: Failed to download {len(failures)} databases: {', '.join(item[0] for item in failures)}"
410409
),
411410
)
412411

413-
print(f"\n=== Extracted {len(results)} databases ===")
412+
print(f"\n=== Fetched {len(results)} databases ===")
414413

415414
return [(project_map[n], r) for n, r in zip(artifact_map, results)]
416415

0 commit comments

Comments
 (0)