Chenhao
commited on
Commit
·
e6a7d9d
1
Parent(s):
8596f82
添加了自动化提交脚本
Browse files- scripts/01_git_helper.sh +6 -0
- scripts/02_update_keys.py +27 -0
- sync.py +2 -2
scripts/01_git_helper.sh
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
git config --global commit.gpgsign false
|
3 |
+
git config --local commit.gpgsign false
|
4 |
+
git config --unset user.signingkey
|
5 |
+
git config --global --unset user.signingkey
|
6 |
+
git config --local --unset user.signingkey
|
scripts/02_update_keys.py
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
# https://huggingface.co/docs/huggingface_hub/en/guides/manage-spaces
|
3 |
+
from pathlib import Path
|
4 |
+
from dotenv import dotenv_values
|
5 |
+
from huggingface_hub import HfApi
|
6 |
+
|
7 |
+
|
8 |
+
dotenv_path = Path(__file__).resolve().parent.parent / '.env'
|
9 |
+
print(dotenv_path)
|
10 |
+
|
11 |
+
|
12 |
+
env_vars = dotenv_values(dotenv_path)
|
13 |
+
|
14 |
+
|
15 |
+
SPACE_NAME: str = env_vars.pop('SPACE_NAME', '')
|
16 |
+
if SPACE_NAME:
|
17 |
+
api = HfApi()
|
18 |
+
for k,v in env_vars.items():
|
19 |
+
api.add_space_secret(
|
20 |
+
repo_id=SPACE_NAME,
|
21 |
+
key=k,
|
22 |
+
value=v,
|
23 |
+
)
|
24 |
+
else:
|
25 |
+
print('You should set "SPACE_NAME" in .env files')
|
26 |
+
|
27 |
+
print('Update Keys Successfully!')
|
sync.py
CHANGED
@@ -31,9 +31,9 @@ class Config:
|
|
31 |
@classmethod
|
32 |
def from_env(cls):
|
33 |
load_dotenv()
|
34 |
-
repo_id = os.getenv('
|
35 |
if not repo_id:
|
36 |
-
raise ValueError("
|
37 |
|
38 |
return cls(
|
39 |
repo_id=repo_id,
|
|
|
31 |
@classmethod
|
32 |
def from_env(cls):
|
33 |
load_dotenv()
|
34 |
+
repo_id = os.getenv('HF_DATASET_REPO_ID')
|
35 |
if not repo_id:
|
36 |
+
raise ValueError("HF_DATASET_REPO_ID must be set")
|
37 |
|
38 |
return cls(
|
39 |
repo_id=repo_id,
|