BioHCL-SSSM-Complete-Workspace / upload_complete_workspace.py
unknownBrain's picture
Complete medical imaging workspace dump (weights, deliverables, papers, notebooks, code, figures)
eded815 verified
Raw History Blame Contribute Delete
2.04 kB
import os
import sys
import time
from huggingface_hub import HfApi, upload_folder
# Force UTF-8 stdout
if sys.stdout.encoding != 'utf-8':
try:
sys.stdout.reconfigure(encoding='utf-8')
except Exception:
pass
api = HfApi()
repo_id = "unknownBrain/BioHCL-SSSM-Complete-Workspace"
workspace_dir = r"C:\Users\Acer\Documents\myproject\medical imaging"
print(f"Ensuring public repository '{repo_id}' on Hugging Face exists...")
api.create_repo(repo_id=repo_id, repo_type="model", exist_ok=True, private=False)
print("Repository confirmed public.")
max_retries = 10
for attempt in range(1, max_retries + 1):
try:
print(f"\n=======================================================")
print(f"--- Upload Attempt {attempt}/{max_retries} ---")
print(f"=======================================================")
upload_folder(
folder_path=workspace_dir,
repo_id=repo_id,
repo_type="model",
ignore_patterns=[
"__pycache__/*",
"*.pyc",
".git/*",
"wandb/*",
"**/__pycache__/*",
"**/*.pyc",
"**/wandb/*",
"hf_repo_staging/*",
"hf_repo_staging"
],
commit_message="Complete medical imaging workspace dump (weights, deliverables, papers, notebooks, code, figures)"
)
print("\n" + "="*70)
print(f"SUCCESS on attempt {attempt}: Complete workspace uploaded to Hugging Face!")
print(f"Repository URL: https://huggingface.co/{repo_id}")
print("="*70)
break
except Exception as e:
print(f"\n[Warning] Attempt {attempt} failed with error: {e}")
if attempt < max_retries:
wait_sec = 5
print(f"Retrying in {wait_sec} seconds (cached LFS files will be skipped automatically)...")
time.sleep(wait_sec)
else:
print("\n[Error] All retries exhausted.")
sys.exit(1)