-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclean_hf_space.py
More file actions
26 lines (23 loc) · 1.05 KB
/
Copy pathclean_hf_space.py
File metadata and controls
26 lines (23 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import os
from huggingface_hub import HfApi
def load_token():
if os.path.exists('.env'):
with open('.env', 'r') as f:
for line in f:
if line.startswith('HF_TOKEN='):
return line.strip().split('=', 1)[1].strip('\'"')
return os.environ.get('HF_TOKEN')
api = HfApi(token=load_token())
repo_id = 'adityavanjre/project-k'
print("Scanning Hugging Face Space for large files to delete...")
try:
files = api.list_repo_files(repo_id, repo_type='space')
large_files = [f for f in files if f.endswith('.gguf') or f.endswith('.bin') or f.endswith('.pt') or f.endswith('.safetensors')]
if large_files:
print(f"Found large files taking up space: {large_files}")
api.delete_files(large_files, repo_id=repo_id, repo_type='space', commit_message="Clear space for build")
print("Successfully deleted large files.")
else:
print("No .gguf or .bin files found. The repository git history might be taking up space.")
except Exception as e:
print(f"Error checking Space: {e}")