SushantGautam commited on
Commit
235a7c1
·
1 Parent(s): b445d32

Fix timestamp handling in refresh_submissions to correctly process submitted time values

Browse files
Files changed (1) hide show
  1. gradio_interface.py +2 -3
gradio_interface.py CHANGED
@@ -28,7 +28,6 @@ def refresh_submissions():
28
  os.makedirs(hub_path) # empty repo case
29
  print("os.listdir(hub_path):", os.listdir(hub_path))
30
  all_jsons = glob.glob(hub_path + "/**/*.json", recursive=True)
31
- print("Downloaded submissions: ", all_jsons)
32
  json_files = [f.split("/")[-1] for f in all_jsons]
33
  submissions = []
34
  for file in json_files:
@@ -48,7 +47,7 @@ hub_dir = hub_path.split("snapshot")[0] + "snapshot"
48
 
49
  def time_ago(submitted_time):
50
  delta = datetime.now(timezone.utc) - datetime.fromtimestamp(
51
- int(submitted_time) / 1000, tz=timezone.utc)
52
  if delta.days > 0:
53
  return f"{delta.days} days ago"
54
  elif delta.seconds // 3600 > 0:
@@ -85,7 +84,7 @@ def add_submission(file):
85
  username, sub_timestamp, task = file.replace(
86
  ".json", "").split("-_-_-")
87
  submission_time = datetime.fromtimestamp(
88
- int(sub_timestamp) / 1000, tz=timezone.utc)
89
  assert task in ["task1", "task2"], "Invalid task type"
90
  assert len(username) > 0, "Invalid username"
91
  assert submission_time < datetime.now(
 
28
  os.makedirs(hub_path) # empty repo case
29
  print("os.listdir(hub_path):", os.listdir(hub_path))
30
  all_jsons = glob.glob(hub_path + "/**/*.json", recursive=True)
 
31
  json_files = [f.split("/")[-1] for f in all_jsons]
32
  submissions = []
33
  for file in json_files:
 
47
 
48
  def time_ago(submitted_time):
49
  delta = datetime.now(timezone.utc) - datetime.fromtimestamp(
50
+ int(submitted_time), tz=timezone.utc)
51
  if delta.days > 0:
52
  return f"{delta.days} days ago"
53
  elif delta.seconds // 3600 > 0:
 
84
  username, sub_timestamp, task = file.replace(
85
  ".json", "").split("-_-_-")
86
  submission_time = datetime.fromtimestamp(
87
+ int(sub_timestamp), tz=timezone.utc)
88
  assert task in ["task1", "task2"], "Invalid task type"
89
  assert len(username) > 0, "Invalid username"
90
  assert submission_time < datetime.now(