Skip to content

Commit e552fba

Browse files
committed
fix(toxgen): Preserve caches when running with --only or --skip
Unused cache entries were pruned at the end of every run. Integrations skipped via --only/--skip never access their cache entries, so a partial run wiped most of releases.jsonl and package_dependencies.jsonl. Only prune on full runs.
1 parent 843958d commit e552fba

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

‎scripts/populate_tox/populate_tox.py‎

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1330,6 +1330,11 @@ def main() -> dict[str, list]:
13301330

13311331
write_tox_file(packages)
13321332

1333+
# Unused cache entries are only pruned on full runs. With --only/--skip,
1334+
# skipped integrations don't touch (most of) their cache entries, so pruning
1335+
# would wipe them.
1336+
prune_cache = not (only_update or skip_update)
1337+
13331338
# Sort the release cache file
13341339
releases = []
13351340
with open(RELEASES_CACHE_FILE) as releases_cache:
@@ -1338,7 +1343,8 @@ def main() -> dict[str, list]:
13381343
with open(RELEASES_CACHE_FILE, "w") as releases_cache:
13391344
for release in releases:
13401345
if (
1341-
CACHE[_normalize_name(release["info"]["name"])][
1346+
not prune_cache
1347+
or CACHE[_normalize_name(release["info"]["name"])][
13421348
release["info"]["version"]
13431349
]["_accessed"]
13441350
is True
@@ -1353,7 +1359,8 @@ def main() -> dict[str, list]:
13531359
with open(DEPENDENCIES_CACHE_FILE, "w") as releases_cache:
13541360
for release in releases:
13551361
if (
1356-
DEPENDENCIES_CACHE[release["python_version"]][
1362+
not prune_cache
1363+
or DEPENDENCIES_CACHE[release["python_version"]][
13571364
release["install_targets_hash"]
13581365
]["_accessed"]
13591366
is True

0 commit comments

Comments
 (0)