File size: 2,044 Bytes
eded815
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
51
52
53
54
55
56
57
58
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)