IlyasMoutawwakil HF staff commited on
Commit
111d85e
1 Parent(s): 634acb1
Files changed (1) hide show
  1. app.py +13 -10
app.py CHANGED
@@ -1,6 +1,8 @@
1
  import os
2
  import time
3
  import traceback
 
 
4
 
5
  from config_store import (
6
  get_process_config,
@@ -44,14 +46,16 @@ MODELS_TO_TASKS = {
44
  TASKS = set(TASKS_TO_OVMODEL.keys()) & set(TASKS_TO_MODEL_LOADERS.keys())
45
 
46
 
47
- def run_benchmark(kwargs, oauth_token: gr.OAuthToken):
48
- if oauth_token.token is None:
49
  gr.Error("Please login to be able to run the benchmark.")
50
  return tuple(None for _ in BACKENDS)
51
 
 
 
52
  timestamp = time.strftime("%Y-%m-%d-%H-%M-%S")
53
- username = whoami(oauth_token.token)["name"]
54
- repo_id = f"{username}/benchmarks"
55
  token = oauth_token.token
56
 
57
  create_repo(repo_id, token=token, repo_type="dataset", exist_ok=True)
@@ -124,7 +128,7 @@ def run_benchmark(kwargs, oauth_token: gr.OAuthToken):
124
  benchmark.push_to_hub(
125
  repo_id=repo_id, subfolder=benchmark_name, token=oauth_token.token
126
  )
127
- gr.Info(f"Pushed benchmark to {username}/benchmarks/{benchmark_name}")
128
 
129
  outputs[backend] = f"\n{benchmark_report.to_markdown_text()}"
130
 
@@ -137,11 +141,13 @@ def run_benchmark(kwargs, oauth_token: gr.OAuthToken):
137
 
138
  yield tuple(outputs[b] for b in BACKENDS)
139
 
 
 
140
 
141
  def build_demo():
142
  with gr.Blocks() as demo:
143
  # add login button
144
- gr.LoginButton(min_width=250)
145
 
146
  # add image
147
  gr.HTML(
@@ -237,11 +243,8 @@ def build_demo():
237
  return demo
238
 
239
 
240
- demo = build_demo()
241
-
242
  if __name__ == "__main__":
243
  os.environ["LOG_TO_FILE"] = "0"
244
  os.environ["LOG_LEVEL"] = "INFO"
245
- setup_logging(level="INFO", prefix="MAIN-PROCESS")
246
 
247
- demo.queue(max_size=10).launch()
 
1
  import os
2
  import time
3
  import traceback
4
+ import logging
5
+ from typing import Optional
6
 
7
  from config_store import (
8
  get_process_config,
 
46
  TASKS = set(TASKS_TO_OVMODEL.keys()) & set(TASKS_TO_MODEL_LOADERS.keys())
47
 
48
 
49
+ def run_benchmark(kwargs, oauth_token: Optional[gr.OAuthToken] = None):
50
+ if oauth_token.token is None or oauth_token.token == "":
51
  gr.Error("Please login to be able to run the benchmark.")
52
  return tuple(None for _ in BACKENDS)
53
 
54
+ setup_logging(level="INFO", prefix="MAIN-PROCESS")
55
+
56
  timestamp = time.strftime("%Y-%m-%d-%H-%M-%S")
57
+ name = whoami(oauth_token.token)["name"]
58
+ repo_id = f"{name}/benchmarks"
59
  token = oauth_token.token
60
 
61
  create_repo(repo_id, token=token, repo_type="dataset", exist_ok=True)
 
128
  benchmark.push_to_hub(
129
  repo_id=repo_id, subfolder=benchmark_name, token=oauth_token.token
130
  )
131
+ gr.Info(f"Pushed benchmark to {repo_id}/{benchmark_name}")
132
 
133
  outputs[backend] = f"\n{benchmark_report.to_markdown_text()}"
134
 
 
141
 
142
  yield tuple(outputs[b] for b in BACKENDS)
143
 
144
+ logging.getLogger().setLevel(logging.NOTSET)
145
+
146
 
147
  def build_demo():
148
  with gr.Blocks() as demo:
149
  # add login button
150
+ gr.LoginButton()
151
 
152
  # add image
153
  gr.HTML(
 
243
  return demo
244
 
245
 
 
 
246
  if __name__ == "__main__":
247
  os.environ["LOG_TO_FILE"] = "0"
248
  os.environ["LOG_LEVEL"] = "INFO"
 
249
 
250
+ build_demo().queue(max_size=10).launch()