SushantGautam commited on
Commit
f6d47e5
·
1 Parent(s): 6815557

Update JSON file retrieval in refresh_submissions to support nested directories

Browse files
Files changed (1) hide show
  1. gradio_interface.py +4 -2
gradio_interface.py CHANGED
@@ -1,9 +1,10 @@
1
  import gradio as gr
2
  import json
3
- from datetime import datetime, timezone, timedelta
4
  from huggingface_hub import upload_file, snapshot_download
5
  import shutil
6
  import os
 
7
  from pathlib import Path
8
  from huggingface_hub import whoami
9
  print("Account token used to connect to HuggingFace: ", whoami()['name'])
@@ -26,7 +27,8 @@ def refresh_submissions():
26
  if not os.path.exists(hub_path):
27
  os.makedirs(hub_path) # empty repo case
28
  print("os.listdir(hub_path):", os.listdir(hub_path))
29
- json_files = [f for f in os.listdir(hub_path) if f.endswith('.json')]
 
30
  print("Downloaded submissions: ", json_files)
31
  submissions = []
32
  for file in json_files:
 
1
  import gradio as gr
2
  import json
3
+ from datetime import datetime, timezone
4
  from huggingface_hub import upload_file, snapshot_download
5
  import shutil
6
  import os
7
+ import glob
8
  from pathlib import Path
9
  from huggingface_hub import whoami
10
  print("Account token used to connect to HuggingFace: ", whoami()['name'])
 
27
  if not os.path.exists(hub_path):
28
  os.makedirs(hub_path) # empty repo case
29
  print("os.listdir(hub_path):", os.listdir(hub_path))
30
+ json_files = [f for f in glob.glob(os.path.join(
31
+ hub_path, "**/*.json"), recursive=True) if f.endswith('.json')]
32
  print("Downloaded submissions: ", json_files)
33
  submissions = []
34
  for file in json_files: