Spaces:
Runtime error
Runtime error
Upload app.py
Browse files
app.py
CHANGED
@@ -6,6 +6,8 @@ import logging
|
|
6 |
|
7 |
HF_TOKEN = os.environ["HF_TOKEN"] if "HF_TOKEN" in os.environ else ""
|
8 |
WiseModel_TOKEN = os.environ["WM_TOKEN"] if "WM_TOKEN" in os.environ else ""
|
|
|
|
|
9 |
|
10 |
|
11 |
def get_cache_dir():
|
@@ -21,6 +23,15 @@ def check_disk():
|
|
21 |
return os.system("df -h /")
|
22 |
|
23 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
24 |
def pull_from_wisemodel(
|
25 |
token: str, url: str, repo_name: str, cache_dir, branch: Optional[str] = None
|
26 |
):
|
@@ -147,6 +158,7 @@ def handle(wisemodel_link, hf_repo_id):
|
|
147 |
# (check_disk, (), {}),
|
148 |
# (push_to_hf, (cache_dir, wisemodel_repo_name, hf_repo_id), {}),
|
149 |
# (check_disk, (), {}),
|
|
|
150 |
(pull_from_hf, (cache_dir, hf_repo_id), {}),
|
151 |
(remove_file, (hf_repo_id, cache_dir), {}),
|
152 |
(check_disk, (), {}),
|
@@ -198,8 +210,8 @@ with gr.Blocks() as demo:
|
|
198 |
# 如何使用这个空间?
|
199 |
# How to use this Space?
|
200 |
|
201 |
-
- 点击右上角settings后面的“…”按钮,选择“Duplicate this Space”创建一个私有的space,同时输入wisemodel的token(必填),以及Huggingface的token(必填),确保有相应repo
|
202 |
-
- Duplicate this Space and providing WiseModel token (mandatory) and your read/write HF token (mandatory).
|
203 |
|
204 |
- 在wiseModel上创建一个空的repo,这一步需要手动完成,Space不会为您创建一个空的repo。
|
205 |
- Create your target model repo on WiseModel. This step is not automated.
|
|
|
6 |
|
7 |
HF_TOKEN = os.environ["HF_TOKEN"] if "HF_TOKEN" in os.environ else ""
|
8 |
WiseModel_TOKEN = os.environ["WM_TOKEN"] if "WM_TOKEN" in os.environ else ""
|
9 |
+
GIT_USER = os.environ["GIT_USE"] if "GIT_USER" in os.environ else ""
|
10 |
+
GIT_EMAIL = os.environ["GIT_EMAIL"] if "GIT_EMAIL" in os.environ else ""
|
11 |
|
12 |
|
13 |
def get_cache_dir():
|
|
|
23 |
return os.system("df -h /")
|
24 |
|
25 |
|
26 |
+
def init_git_user(username: str, email: str):
|
27 |
+
|
28 |
+
if not username or not email:
|
29 |
+
raise gr.Error("Please config your git username and email in the environment variables.")
|
30 |
+
|
31 |
+
os.system(f"git config --global user.email {email}")
|
32 |
+
os.system(f"git config --global user.name {username}")
|
33 |
+
|
34 |
+
|
35 |
def pull_from_wisemodel(
|
36 |
token: str, url: str, repo_name: str, cache_dir, branch: Optional[str] = None
|
37 |
):
|
|
|
158 |
# (check_disk, (), {}),
|
159 |
# (push_to_hf, (cache_dir, wisemodel_repo_name, hf_repo_id), {}),
|
160 |
# (check_disk, (), {}),
|
161 |
+
(init_git_user, (GIT_USER, GIT_EMAIL), {}),
|
162 |
(pull_from_hf, (cache_dir, hf_repo_id), {}),
|
163 |
(remove_file, (hf_repo_id, cache_dir), {}),
|
164 |
(check_disk, (), {}),
|
|
|
210 |
# 如何使用这个空间?
|
211 |
# How to use this Space?
|
212 |
|
213 |
+
- 点击右上角settings后面的“…”按钮,选择“Duplicate this Space”创建一个私有的space,同时输入wisemodel的token(必填),以及Huggingface的token(必填),确保有相应repo写入的权限。你还需要输入你的git用户名和邮箱。
|
214 |
+
- Duplicate this Space and providing WiseModel token (mandatory) and your read/write HF token (mandatory).you also need to provide your git username and email to push the model to WiseModel.
|
215 |
|
216 |
- 在wiseModel上创建一个空的repo,这一步需要手动完成,Space不会为您创建一个空的repo。
|
217 |
- Create your target model repo on WiseModel. This step is not automated.
|