albertvillanova HF staff commited on
Commit
2548bde
1 Parent(s): b2a0b3c

Remove background scheduler

Browse files
Files changed (1) hide show
  1. app.py +17 -17
app.py CHANGED
@@ -1,11 +1,11 @@
1
- import datetime
2
  import json
3
  import os
4
  from pathlib import Path
5
 
6
  import gradio as gr
7
  import huggingface_hub as hfh
8
- from apscheduler.schedulers.background import BackgroundScheduler
9
 
10
 
11
  DATASET_ID = "albertvillanova/datasets-report"
@@ -56,21 +56,21 @@ def filter_dataframe(date_from, date_to):
56
  return [[ds.id, ds.downloads] for ds in dss]
57
 
58
 
59
- def update_datasets():
60
- # Retrieve datasets
61
- datasets = hfh.list_datasets()
62
- # Save dataset IDs
63
- repo = pull_dataset_repo()
64
- os.makedirs(DATA_PATH, exist_ok=True)
65
- today = datetime.datetime.now(datetime.timezone.utc).date().isoformat()
66
- with repo.commit(f"Add {today} data file"):
67
- with open(f"data/{today}.json", "w") as f:
68
- json.dump([ds.id for ds in sorted(datasets, key=lambda item: item.id)], f)
69
-
70
-
71
- scheduler = BackgroundScheduler()
72
- scheduler.add_job(update_datasets, trigger="cron", hour=0, minute=1, timezone=datetime.timezone.utc)
73
- scheduler.start()
74
 
75
 
76
  with gr.Blocks() as demo:
 
1
+ # import datetime
2
  import json
3
  import os
4
  from pathlib import Path
5
 
6
  import gradio as gr
7
  import huggingface_hub as hfh
8
+ # from apscheduler.schedulers.background import BackgroundScheduler
9
 
10
 
11
  DATASET_ID = "albertvillanova/datasets-report"
 
56
  return [[ds.id, ds.downloads] for ds in dss]
57
 
58
 
59
+ # def update_datasets():
60
+ # # Retrieve datasets
61
+ # datasets = hfh.list_datasets()
62
+ # # Save dataset IDs
63
+ # repo = pull_dataset_repo()
64
+ # os.makedirs(DATA_PATH, exist_ok=True)
65
+ # today = datetime.datetime.now(datetime.timezone.utc).date().isoformat()
66
+ # with repo.commit(f"Add {today} data file"):
67
+ # with open(f"data/{today}.json", "w") as f:
68
+ # json.dump([ds.id for ds in sorted(datasets, key=lambda item: item.id)], f)
69
+ #
70
+ #
71
+ # scheduler = BackgroundScheduler()
72
+ # scheduler.add_job(update_datasets, trigger="cron", hour=0, minute=1, timezone=datetime.timezone.utc)
73
+ # scheduler.start()
74
 
75
 
76
  with gr.Blocks() as demo: