V6.5-7ds cleanup: remove legacy scripts/upload_v6_5_resilient.py
Browse files123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129"""upload_v6_5_resilient.py — V6.5 upload to HuggingFace (single commit)."""from __future__ import annotationsimport json, os, sys, time, refrom pathlib import Path
PROJECT_ROOT = Path("/home/z/my-project")BIGRU_ROOT = PROJECT_ROOT / "BiGRU_T_version"
CRITICAL_FILES_V65 = [ "src/bigru_t/model/kohonen_learning_system.py", "src/bigru_t/model/__init__.py", "src/bigru_t/__init__.py", "src/bigru_t/model/hyp_t.py", "src/bigru_t/training/mtp.py", "src/bigru_t/training/ewc.py", "src/bigru_t/quantization/smoothquant_compressor.py", "src/bigru_t/model/vqvae2_hierarchical.py", "src/bigru_t/model/vqvae2_hierarchical_flexnet.py", "src/bigru_t/model/token_compress.py", "src/bigru_t/reasoning/thinking.py", "src/bigru_t/reasoning/reasoning_engine.py", "src/bigru_t/reasoning/circular_orchestration.py", "src/bigru_t/reasoning/tool_agent.py", "src/bigru_t/reasoning/distributed_reasoning_system.py", "src/bigru_t/reasoning/cyclic_reasoning.py", "src/bigru_t/reasoning/consensus_sampling.py", "v6_5_report.json", "v6_5_training_metrics.json", "v6_5_module_analysis.json", "v6_5_script_activity.json", "v6_5_ewc_w8a8_benchmark.json", "v6_5_reasoning_eval.json", "scripts/train_v6_5.py", "scripts/upload_v6_5_resilient.py", "src/bigru_t/utils/xeon_runtime.py", "src/bigru_t/data/streaming_datasets.py",]
def main() -> int: print("=" * 72) print("V6.5 — UPLOAD TO HUGGINGFACE") print("=" * 72) hf_token = os.environ.get("HF_TOKEN") if not hf_token: print("ERROR: HF_TOKEN not set in env") return 1 print(f" HF_TOKEN loaded from env (length={len(hf_token)})")
# Pre-upload safety: regex scrub any HF token format token_pattern = re.compile(r'hf_[A-Za-z0-9]{32,}') print("\n Pre-upload safety: scrubbing token from scripts...") for script_path in BIGRU_ROOT.glob("scripts/*.py"): try: content = script_path.read_text() if token_pattern.search(content): scrubbed = token_pattern.sub("hf_<REDACTED_TOKEN>", content) script_path.write_text(scrubbed) print(f" SCRUBBED: {script_path.name}") except Exception as e: print(f" SKIP {script_path.name}: {e}")
try: from huggingface_hub import HfApi, upload_folder except ImportError: print("ERROR: huggingface_hub not installed") return 1
api = HfApi(token=hf_token) repo_id = "PowerMachine/BiGRU_T_version" try: info = api.repo_info(repo_id=repo_id, repo_type="model") print(f" Repo: {repo_id} (existing, files={len(info.siblings)})") except Exception as e: print(f" ERROR: cannot access repo: {e}") return 1
print(f"\n Uploading {BIGRU_ROOT} as single commit...") t0 = time.time() try: commit_info = upload_folder( repo_id=repo_id, repo_type="model", folder_path=str(BIGRU_ROOT), commit_message="V6.5-final: removed pre-V6.4 modules/scripts, moved kohonen_learning_system up, activated VQ-VAE-2 in pipeline, integrated reasoning_engine, benchmarked EWC+W8A8 dequant, exhausted 6 datasets", token=hf_token, ) t1 = time.time() print(f" Upload completed in {t1 - t0:.2f}s") print(f" Commit: {commit_info.oid}") print(f" URL: https://huggingface.co/PowerMachine/BiGRU_T_version/commit/{commit_info.oid}") except Exception as e: print(f" ERROR: upload failed: {e}") return 1
print("\n Verifying critical files in repo...") try: files_in_repo = api.list_repo_files(repo_id, repo_type="model") all_present = True for cf in CRITICAL_FILES_V65: present = cf in files_in_repo mark = "OK" if present else "MISS" print(f" [{mark}] {cf}") if not present: all_present = False print(f"\n Files in repo: {len(files_in_repo)}") if not all_present: print(" WARNING: some critical files missing!") except Exception as e: print(f" WARNING: cannot verify files: {e}")
report = { "version": "V6.5", "upload_timestamp": time.strftime("%Y-%m-%dT%H:%M:%S"), "repo_id": repo_id, "commit_oid": commit_info.oid, "commit_url": f"https://huggingface.co/PowerMachine/BiGRU_T_version/commit/{commit_info.oid}", "duration_s": float(t1 - t0), "critical_files": CRITICAL_FILES_V65, "n_files_in_repo": len(files_in_repo) if "files_in_repo" in dir() else 0, } report_path = BIGRU_ROOT / "v6_5_upload_report.json" report_path.write_text(json.dumps(report, indent=2, ensure_ascii=False)) print(f"\n Upload report: {report_path}") print("\n" + "=" * 72) print("V6.5 — UPLOAD COMPLETED") print("=" * 72) return 0
if __name__ == "__main__": sys.exit(main())scripts/upload_v6_5_resilient.pyDeleted-129