-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy_to_hf.py
More file actions
53 lines (44 loc) · 1.1 KB
/
deploy_to_hf.py
File metadata and controls
53 lines (44 loc) · 1.1 KB
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
"""Re-deploy all project files to HuggingFace Space."""
import os
import sys
# Force UTF-8
os.environ["PYTHONUTF8"] = "1"
from huggingface_hub import HfApi
REPO_ID = "keshav-005/cyber_range"
TOKEN = os.getenv("HF_TOKEN")
if not TOKEN:
print("Set HF_TOKEN environment variable first!")
sys.exit(1)
api = HfApi(token=TOKEN)
# Upload the entire project folder
api.upload_folder(
folder_path=".",
repo_id=REPO_ID,
repo_type="space",
ignore_patterns=[
".git/*",
".git/**",
"__pycache__/*",
"__pycache__/**",
"**/__pycache__/*",
"**/__pycache__/**",
"*.pyc",
".pytest_cache/*",
".pytest_cache/**",
"validation_source.txt",
"validation_results.log",
"deploy_to_hf.py",
".venv/*",
".venv/**",
"README.md",
],
)
# Upload the specific HuggingFace config as README.md
api.upload_file(
path_or_fileobj="HF_README.md",
path_in_repo="README.md",
repo_id=REPO_ID,
repo_type="space",
)
print("Upload complete!")
print(f"Space: https://huggingface.co/spaces/{REPO_ID}")