PowerMachine commited on
Commit
d093cf2
·
verified ·
1 Parent(s): 5b9aab4

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

Browse files
Files changed (1) hide show
  1. scripts/upload_to_hf.py +0 -111
scripts/upload_to_hf.py DELETED
@@ -1,111 +0,0 @@
1
- #!/usr/bin/env python3
2
- """upload_to_hf.py — Upload do BiGRU_T_version para HuggingFace Hub.
3
-
4
- Faz upload de:
5
- - model_final/pytorch_model.bin
6
- - model_final/config.json
7
- - model_final/tokenizer/tokenizer.json
8
- - training_report.json
9
- - README.md
10
- - src/ (código fonte)
11
- - scripts/ (scripts de treino/smoke test)
12
- - docs/ (análise matemática)
13
-
14
- Repositório destino: PowerMachine/BiGRU_T_version (public)
15
-
16
- Uso:
17
- export HF_TOKEN="hf_xxx"
18
- python scripts/upload_to_hf.py
19
- """
20
- from __future__ import annotations
21
-
22
- import os
23
- import sys
24
- from pathlib import Path
25
-
26
- from huggingface_hub import HfApi, create_repo
27
-
28
-
29
- def main():
30
- token = os.environ.get("HF_TOKEN")
31
- if not token:
32
- print("ERROR: HF_TOKEN not set")
33
- sys.exit(1)
34
-
35
- repo_id = "PowerMachine/BiGRU_T_version"
36
- project_dir = Path("/home/z/my-project/BiGRU_T_version")
37
-
38
- print(f"Uploading to {repo_id} (public)...")
39
-
40
- api = HfApi(token=token)
41
-
42
- # Cria repo (idempotente)
43
- try:
44
- create_repo(repo_id, repo_type="model", token=token, private=False, exist_ok=True)
45
- print(f" Repo created/exists: {repo_id}")
46
- except Exception as e:
47
- print(f" Warning creating repo: {e}")
48
-
49
- # Upload de arquivos individuais
50
- files_to_upload = [
51
- ("README.md", "README.md"),
52
- ("requirements.txt", "requirements.txt"),
53
- ("training_report.json", "training_report.json"),
54
- ("model_final/config.json", "config.json"),
55
- ("model_final/pytorch_model.bin", "pytorch_model.bin"),
56
- ("model_final/tokenizer/tokenizer.json", "tokenizer/tokenizer.json"),
57
- ("docs/analysis.md", "docs/analysis.md"),
58
- ]
59
-
60
- for src, dst in files_to_upload:
61
- src_path = project_dir / src
62
- if not src_path.exists():
63
- print(f" SKIP (not found): {src}")
64
- continue
65
- print(f" Uploading {src} → {dst}...")
66
- try:
67
- api.upload_file(
68
- path_or_fileobj=str(src_path),
69
- path_in_repo=dst,
70
- repo_id=repo_id,
71
- repo_type="model",
72
- token=token,
73
- )
74
- print(f" OK")
75
- except Exception as e:
76
- print(f" FAIL: {e}")
77
-
78
- # Upload de diretórios como pastas
79
- dirs_to_upload = [
80
- ("src", "src"),
81
- ("scripts", "scripts"),
82
- ]
83
-
84
- for src_dir, dst_dir in dirs_to_upload:
85
- src_path = project_dir / src_dir
86
- if not src_path.exists():
87
- print(f" SKIP (not found): {src_dir}/")
88
- continue
89
- print(f" Uploading {src_dir}/ → {dst_dir}/ ...")
90
- try:
91
- api.upload_folder(
92
- folder_path=str(src_path),
93
- path_in_repo=dst_dir,
94
- repo_id=repo_id,
95
- repo_type="model",
96
- token=token,
97
- ignore_patterns=["__pycache__", "*.pyc", ".pytest_cache", "_temp_checkpoints"],
98
- )
99
- print(f" OK")
100
- except Exception as e:
101
- print(f" FAIL: {e}")
102
-
103
- print(f"\nUpload complete: https://huggingface.co/{repo_id}")
104
-
105
- # Apaga token do ambiente (especificação do usuário)
106
- del os.environ["HF_TOKEN"]
107
- print("HF_TOKEN apagado do ambiente")
108
-
109
-
110
- if __name__ == "__main__":
111
- main()