Skip to content

Commit 1fd66a2

Browse files
authored
Increase model size to 500MB for cache models (#1837)
* print csche size * update script * trigger ci * trigger tests * fix * trigger * fix * set 500mb limit * remove weekly schedule
1 parent ae64930 commit 1fd66a2

2 files changed

Lines changed: 23 additions & 6 deletions

File tree

‎.github/workflows/create_model_cache.yml‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
name: Create Model Cache
22

33
on:
4-
schedule:
5-
- cron: "0 0 * * 1" # every monday at midnight UTC
64
workflow_dispatch:
75
inputs:
86
force_update:
@@ -20,7 +18,7 @@ env:
2018

2119
jobs:
2220
create-cache:
23-
if: github.event_name == 'workflow_dispatch' || github.event_name == 'schedule'
21+
if: github.event_name == 'workflow_dispatch'
2422
runs-on: ubuntu-22.04
2523

2624
steps:
@@ -38,6 +36,7 @@ jobs:
3836
uv pip install .[tests]
3937
4038
- name: Restore existing cache
39+
if: ${{ !inputs.force_update }}
4140
uses: actions/cache/restore@v4
4241
with:
4342
path: ~/.cache/huggingface/hub

‎tests/scripts/download_cached_models.py‎

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525

2626
# github actions repo cache limit is 10 GB so using 9 GB
2727
CACHE_LIMIT = 9 * 10**9
28-
# exclude model larger than 200 MB
29-
MODEL_SIZE_THRESHOLD = 200 * 10**6
28+
# exclude model larger than 500 MB
29+
MODEL_SIZE_THRESHOLD = 500 * 10**6
3030

3131

3232
def hub_size(api: HfApi, repo_id: str) -> int:
@@ -41,7 +41,6 @@ def hub_size(api: HfApi, repo_id: str) -> int:
4141
def main() -> None:
4242
api = HfApi()
4343
candidates = {}
44-
4544
for name, repo_id in MODEL_NAMES.items():
4645
if not isinstance(repo_id, str) or not repo_id or repo_id.startswith("/"):
4746
continue
@@ -89,6 +88,25 @@ def main() -> None:
8988
print(f"Skipped (too large) : {len(skipped_too_large)} ({', '.join(skipped_too_large)})")
9089
print(f"Skipped (cache full): {len(skipped_cache_full)} ({', '.join(skipped_cache_full)})")
9190
print(f"Loading failed : {len(failed)} ({', '.join(failed)})")
91+
final_cache_info = scan_cache_dir()
92+
actual_size = final_cache_info.size_on_disk / 10**9
93+
print(f"Actual cache : {actual_size:.2f} GB, sum_repo_size {sum_repo_size / 10**9:.0f} GB")
94+
95+
final_cached_repos = {repo.repo_id for repo in final_cache_info.repos}
96+
name_of = {repo_id: name for name, repo_id in MODEL_NAMES.items()}
97+
downloaded_repo_ids = {repo_id for name, repo_id in MODEL_NAMES.items() if name in set(downloaded)}
98+
99+
in_cache_not_downloaded = final_cached_repos - downloaded_repo_ids
100+
in_downloaded_not_in_cache = downloaded_repo_ids - final_cached_repos
101+
102+
print(
103+
f"In cache but not in downloaded ({len(in_cache_not_downloaded)}): "
104+
f"{', '.join(name_of.get(r, r) for r in sorted(in_cache_not_downloaded))}"
105+
)
106+
print(
107+
f"In downloaded but not in cache ({len(in_downloaded_not_in_cache)}): "
108+
f"{', '.join(name_of.get(r, r) for r in sorted(in_downloaded_not_in_cache))}"
109+
)
92110

93111

94112
if __name__ == "__main__":

0 commit comments

Comments
 (0)