znation HF staff commited on
Commit
079300d
·
1 Parent(s): b9e402d

only refresh repos, clean up UI

Browse files
Files changed (2) hide show
  1. app.py +4 -6
  2. list_files.py +2 -0
app.py CHANGED
@@ -10,20 +10,18 @@ import gradio as gr
10
  import list_repos
11
  import refresh_lists
12
 
13
- def greet(name):
14
  try:
15
  refresh_repos()
16
- refresh_files()
17
- return "Hello " + name + "!!"
18
  except:
19
  raise gr.Error(str(sys.exc_info()))
20
 
21
- def refresh_repos(progress=gr.Progress(track_tqdm=True)):
22
  list_repos.write_repos_to_db()
23
 
24
- def refresh_files(progress=gr.Progress(track_tqdm=True)):
25
  while True:
26
  refresh_lists.refresh_oldest_repo()
27
 
28
- demo = gr.Interface(fn=greet, inputs="text", outputs="text")
29
  demo.launch()
 
10
  import list_repos
11
  import refresh_lists
12
 
13
+ def refresh_on_submit(progress=gr.Progress(track_tqdm=True)):
14
  try:
15
  refresh_repos()
 
 
16
  except:
17
  raise gr.Error(str(sys.exc_info()))
18
 
19
+ def refresh_repos():
20
  list_repos.write_repos_to_db()
21
 
22
+ def refresh_files():
23
  while True:
24
  refresh_lists.refresh_oldest_repo()
25
 
26
+ demo = gr.Interface(fn=refresh_on_submit, inputs=None, outputs="text")
27
  demo.launch()
list_files.py CHANGED
@@ -61,6 +61,8 @@ def write_files_to_db(repo):
61
  print("Inserting new rows from HFFileSystem query for repo {}".format(repo), file=sys.stderr)
62
  for file in tqdm(list_files_from_hub(repo)):
63
  is_lfs = file["lfs"] is not None
 
 
64
  query = "INSERT INTO files VALUES ('{}', {}, '{}', {}, '{}', '{}', {}, {}, '{}', {}, '{}', '{}', '{}')".format(
65
  file["name"],
66
  int(time.time()),
 
61
  print("Inserting new rows from HFFileSystem query for repo {}".format(repo), file=sys.stderr)
62
  for file in tqdm(list_files_from_hub(repo)):
63
  is_lfs = file["lfs"] is not None
64
+ # Something is wrong below -- occasionally see an error like
65
+ # sqlite3.OperationalError: near "t": syntax error
66
  query = "INSERT INTO files VALUES ('{}', {}, '{}', {}, '{}', '{}', {}, {}, '{}', {}, '{}', '{}', '{}')".format(
67
  file["name"],
68
  int(time.time()),