Update app.py
Browse files
app.py
CHANGED
|
@@ -76,7 +76,7 @@ def repl(rs,rt,uu):
|
|
| 76 |
|
| 77 |
|
| 78 |
|
| 79 |
-
def build_space(token,
|
| 80 |
model_id=t_name
|
| 81 |
if token==None or token=="":
|
| 82 |
token = token_self
|
|
@@ -84,35 +84,27 @@ def build_space(token,t_name,s_type,m_type=None,r_type=None,d_app=None,d_css=Non
|
|
| 84 |
token = token
|
| 85 |
pass
|
| 86 |
api = HfApi(token=token)
|
| 87 |
-
repo_name
|
|
|
|
| 88 |
print (repo_name)
|
| 89 |
-
repo_name=repo_name.split("/",1)[1]
|
| 90 |
-
print(repo_name)
|
| 91 |
try:
|
| 92 |
-
api_url = f'https://huggingface.co/api/spaces/{model_id}'
|
| 93 |
-
if s_type == "A":
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
| 104 |
|
| 105 |
-
api.upload_file(
|
| 106 |
-
path_or_fileobj=f"{uid}at.py",
|
| 107 |
-
path_in_repo="app.py",
|
| 108 |
-
repo_id=repo_name,
|
| 109 |
-
token=token,
|
| 110 |
-
repo_type="space",
|
| 111 |
-
)
|
| 112 |
-
os.remove(f"{uid}at.py")
|
| 113 |
|
| 114 |
-
|
| 115 |
-
return gr.HTML.update(f'''<center>Link to space <a href="https://huggingface.co/spaces/{repo_name}" target="_blank">https://huggingface.co/spaces/{repo_name}</a><center><br>''')
|
| 116 |
except Exception as e:
|
| 117 |
return gr.HTML.update(f"""{str(e)}""")
|
| 118 |
|
|
@@ -167,5 +159,5 @@ with gr.Blocks() as build:
|
|
| 167 |
r_btn.click(repl,[r_s,r_w,uu], [m_t,files])
|
| 168 |
|
| 169 |
pass_btn.click(checkp,pass_box,[no,yes])
|
| 170 |
-
|
| 171 |
build.queue(concurrency_count=10).launch()
|
|
|
|
| 76 |
|
| 77 |
|
| 78 |
|
| 79 |
+
def build_space(token,r_name,s_name,d_app,uu):
|
| 80 |
model_id=t_name
|
| 81 |
if token==None or token=="":
|
| 82 |
token = token_self
|
|
|
|
| 84 |
token = token
|
| 85 |
pass
|
| 86 |
api = HfApi(token=token)
|
| 87 |
+
repo_name=f'{r_name}/{s_name}'
|
| 88 |
+
#repo_name = get_full_repo_name(model_id=model_id, token=token)
|
| 89 |
print (repo_name)
|
| 90 |
+
#repo_name=repo_name.split("/",1)[1]
|
| 91 |
+
#print(repo_name)
|
| 92 |
try:
|
| 93 |
+
#api_url = f'https://huggingface.co/api/spaces/{model_id}'
|
| 94 |
+
#if s_type == "A":
|
| 95 |
+
|
| 96 |
+
|
| 97 |
+
api.upload_file(
|
| 98 |
+
path_or_fileobj=f"{uu}",
|
| 99 |
+
path_in_repo=f"{d_app}",
|
| 100 |
+
repo_id=repo_name,
|
| 101 |
+
token=token,
|
| 102 |
+
repo_type="space",
|
| 103 |
+
)
|
| 104 |
+
#os.remove(f"{uid}at.py")
|
| 105 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 106 |
|
| 107 |
+
return gr.HTML.update(f'''<center>Link to space <a href="https://huggingface.co/spaces/{repo_name}" target="_blank">https://huggingface.co/spaces/{repo_name}</a><center><br>''')
|
|
|
|
| 108 |
except Exception as e:
|
| 109 |
return gr.HTML.update(f"""{str(e)}""")
|
| 110 |
|
|
|
|
| 159 |
r_btn.click(repl,[r_s,r_w,uu], [m_t,files])
|
| 160 |
|
| 161 |
pass_btn.click(checkp,pass_box,[no,yes])
|
| 162 |
+
inbut.click(build_space,[token,r_name,s_name,d_app,uu],output_html)
|
| 163 |
build.queue(concurrency_count=10).launch()
|