-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathforce_push.py
More file actions
50 lines (44 loc) · 1.42 KB
/
Copy pathforce_push.py
File metadata and controls
50 lines (44 loc) · 1.42 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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
"""
Force upload specific files to HuggingFace Space repository regardless of change detection.
"""
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')
token = load_token()
if not token:
print("Error: HF_TOKEN not found")
exit(1)
api = HfApi(token=token)
repo_id = 'adityavanjre/project-k'
# Files that were actually changed and need pushing
files_to_upload = [
'src/core/processor.py',
'data/wealth_ledger.json',
'logs/sovereign_vault.json',
'logs/credential_vault.json',
'push_modified_files.py'
]
print(f"Force-uploading changed files to {repo_id}...")
for file in files_to_upload:
if os.path.exists(file):
try:
print(f"Uploading {file}...")
api.upload_file(
path_or_fileobj=file,
path_in_repo=file,
repo_id=repo_id,
repo_type='space',
commit_message=f"Fix: wealth display and capabilities fallback - {file}"
)
print(f" OK: {file}")
except Exception as e:
print(f" FAILED {file}: {e}")
else:
print(f" SKIP (not found): {file}")
print("\nDone! HF Space container will rebuild.")