PowerMachine commited on
Commit
188d7d7
·
verified ·
1 Parent(s): 5aa1714

V6.5-7ds cleanup: remove legacy scripts/upload_v6_3_resilient.py

Browse files
Files changed (1) hide show
  1. scripts/upload_v6_3_resilient.py +0 -139
scripts/upload_v6_3_resilient.py DELETED
@@ -1,139 +0,0 @@
1
- """upload_v6_3_resilient.py — V6.3 single-commit upload to HuggingFace.
2
-
3
- User requirement:
4
- "HF_TOKEN=hf_<REDACTED_TOKEN> que deve ser apagada após uso"
5
-
6
- Upload V6.3 critical files in a single commit via upload_folder.
7
- Then unset HF_TOKEN from environment.
8
- """
9
- from __future__ import annotations
10
-
11
- import os
12
- import sys
13
- import time
14
- from pathlib import Path
15
-
16
- # ============================================================================
17
- # Configuração
18
- # ============================================================================
19
- REPO_ID = "PowerMachine/BiGRU_T_version"
20
- BIGRU_ROOT = Path("/home/z/my-project/BiGRU_T_version")
21
-
22
- CRITICAL_FILES_V63 = [
23
- # NOVO V6.3: módulo refatorado com código do usuário
24
- "src/bigru_t/model/kohonen_refactored/__init__.py",
25
- "src/bigru_t/model/kohonen_refactored/kohonen_learning_system.py",
26
- # Treino V6.3
27
- "scripts/train_v6_3.py",
28
- # Upload script V6.3
29
- "scripts/upload_v6_3_resilient.py",
30
- # Relatórios V6.3
31
- "v6_3_report.json",
32
- "v6_3_training_metrics.json",
33
- # Módulos preservados (xeon_runtime, streaming_datasets, hyp_t, ewc, orq_cell)
34
- "src/bigru_t/utils/xeon_runtime.py",
35
- "src/bigru_t/data/streaming_datasets.py",
36
- "src/bigru_t/model/hyp_t.py",
37
- "src/bigru_t/model/orq_cell.py",
38
- "src/bigru_t/training/ewc.py",
39
- ]
40
-
41
-
42
- def main() -> int:
43
- print("\n" + "=" * 72)
44
- print("V6.3 — UPLOAD TO HUGGINGFACE")
45
- print("=" * 72)
46
- print(f" Repo ID : {REPO_ID}")
47
- print(f" Critical files : {len(CRITICAL_FILES_V63)}")
48
- print("=" * 72 + "\n")
49
-
50
- # Verifica HF_TOKEN
51
- hf_token = os.environ.get("HF_TOKEN")
52
- if not hf_token:
53
- print("[ERROR] HF_TOKEN not set in environment.")
54
- return 1
55
-
56
- # Verifica arquivos existem
57
- missing = []
58
- for rel_path in CRITICAL_FILES_V63:
59
- full_path = BIGRU_ROOT / rel_path
60
- if not full_path.exists():
61
- missing.append(rel_path)
62
- if missing:
63
- print(f"[ERROR] Missing files ({len(missing)}):")
64
- for p in missing:
65
- print(f" - {p}")
66
- return 1
67
- print(f"[OK] All {len(CRITICAL_FILES_V63)} critical files exist.")
68
-
69
- try:
70
- from huggingface_hub import HfApi, whoami
71
- except ImportError:
72
- print("[ERROR] huggingface_hub not installed. Run: pip install huggingface_hub")
73
- return 1
74
-
75
- # Validate token
76
- try:
77
- user_info = whoami(token=hf_token)
78
- username = user_info.get("name", "unknown")
79
- print(f"[OK] HF token valid. User: {username}")
80
- except Exception as e:
81
- print(f"[ERROR] HF token invalid: {e}")
82
- return 1
83
-
84
- api = HfApi(token=hf_token)
85
-
86
- # Upload em single commit
87
- print("\n[INFO] Uploading files (single commit)...")
88
- t_start = time.time()
89
- try:
90
- # Cria commit via upload_folder com os arquivos críticos
91
- # Para preservar a estrutura, mapeamos cada arquivo para seu caminho no repo
92
- commit_info = api.upload_folder(
93
- repo_id=REPO_ID,
94
- folder_path=str(BIGRU_ROOT),
95
- path_in_repo="",
96
- allow_patterns=CRITICAL_FILES_V63,
97
- commit_message="V6.3: refactored Kohonen Learning System (user code) + xeon_runtime + streaming + bug fix find_bmu",
98
- token=hf_token,
99
- )
100
- t_elapsed = time.time() - t_start
101
- print(f"\n[OK] Upload concluído em {t_elapsed:.2f}s")
102
- print(f" Commit: {commit_info.commit_url}")
103
- print(f" OID : {commit_info.commit_id}")
104
-
105
- # Lista arquivos no repo para verificação
106
- try:
107
- files_in_repo = api.list_repo_files(repo_id=REPO_ID, token=hf_token)
108
- print(f"\n[INFO] Arquivos no repo: {len(files_in_repo)}")
109
- verified = 0
110
- missing_in_repo = []
111
- for crit in CRITICAL_FILES_V63:
112
- if crit in files_in_repo:
113
- verified += 1
114
- else:
115
- missing_in_repo.append(crit)
116
- print(f"[OK] {verified}/{len(CRITICAL_FILES_V63)} critical files verified in repo")
117
- if missing_in_repo:
118
- print(f"[WARN] Missing in repo: {missing_in_repo}")
119
- except Exception as e:
120
- print(f"[WARN] Could not list repo files: {e}")
121
-
122
- except Exception as e:
123
- print(f"[ERROR] Upload failed: {e}")
124
- import traceback
125
- traceback.print_exc()
126
- return 1
127
-
128
- print("\n" + "=" * 72)
129
- print("V6.3 — UPLOAD COMPLETO")
130
- print("=" * 72)
131
- print(f" Commit URL : {commit_info.commit_url}")
132
- print(f" Commit OID : {commit_info.commit_id}")
133
- print(f" Duration : {t_elapsed:.2f}s")
134
- print("=" * 72)
135
- return 0
136
-
137
-
138
- if __name__ == "__main__":
139
- sys.exit(main())