lysandre HF staff commited on
Commit
7174749
·
1 Parent(s): 94dbcbd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -43
app.py CHANGED
@@ -11,47 +11,6 @@ HF_TOKEN = os.environ.get("HF_TOKEN")
11
 
12
  repo: Optional[Repository] = None
13
 
14
- def run(model_id: str, is_private: bool, token: Optional[str] = None) -> str:
15
- if model_id == "":
16
- return """
17
- ### Invalid input 🐞
18
-
19
- Please fill a token and model_id.
20
- """
21
- try:
22
- if is_private:
23
- api = HfApi(token=token)
24
- else:
25
- api = HfApi(token=HF_TOKEN)
26
- hf_is_private = api.model_info(repo_id=model_id).private
27
- if is_private and not hf_is_private:
28
- # This model is NOT private
29
- # Change the token so we make the PR on behalf of the bot.
30
- api = HfApi(token=HF_TOKEN)
31
-
32
- print("is_private", is_private)
33
-
34
- commit_info, errors = convert(api=api, model_id=model_id)
35
- print("[commit_info]", commit_info)
36
-
37
-
38
- string = f"""
39
- ### Success 🔥
40
-
41
- Yay! This model was successfully converted and a PR was open using your token, here:
42
-
43
- [{commit_info.pr_url}]({commit_info.pr_url})
44
- """
45
- if errors:
46
- string += "\nErrors during conversion:\n"
47
- string += "\n".join(f"Error while converting {filename}: {e}, skipped conversion" for filename, e in errors)
48
- return string
49
- except Exception as e:
50
- return f"""
51
- ### Error 😢😢😢
52
-
53
- {e}
54
- """
55
 
56
 
57
  DESCRIPTION = """
@@ -88,6 +47,6 @@ with gr.Blocks(title=title) as demo:
88
  output = gr.Markdown()
89
 
90
  is_private.change(lambda s: token_text(s), inputs=is_private, outputs=token)
91
- submit.click(run, inputs=[model_id, is_private, token], outputs=output, concurrency_limit=1)
92
 
93
- demo.queue(max_size=10).launch(show_api=True)
 
11
 
12
  repo: Optional[Repository] = None
13
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
14
 
15
 
16
  DESCRIPTION = """
 
47
  output = gr.Markdown()
48
 
49
  is_private.change(lambda s: token_text(s), inputs=is_private, outputs=token)
50
+ submit.click(lambda e: e, inputs=[model_id, is_private, token], outputs=output, concurrency_limit=1)
51
 
52
+ demo.queue(max_size=10, api_open=True).launch(show_api=True)