Spaces:
Sleeping
Sleeping
Commit
•
5d67afc
1
Parent(s):
70050ea
Create demo with dataframe
Browse files
app.py
CHANGED
@@ -29,8 +29,25 @@ def greet(name):
|
|
29 |
return "Hello " + name + "!!"
|
30 |
|
31 |
|
32 |
-
|
33 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
|
35 |
|
36 |
def update_datasets():
|
@@ -50,5 +67,14 @@ scheduler.add_job(update_datasets, trigger="cron", hour=0, minute=1, timezone=da
|
|
50 |
scheduler.start()
|
51 |
|
52 |
|
53 |
-
demo = gr.Interface(fn=greet, inputs="text", outputs="text")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
54 |
demo.launch()
|
|
|
29 |
return "Hello " + name + "!!"
|
30 |
|
31 |
|
32 |
+
repo = pull_dataset_repo()
|
33 |
+
datasets = hfh.list_datasets()
|
34 |
+
|
35 |
+
|
36 |
+
def filter_datasets_by_date():
|
37 |
+
date_from = "2022-10-09"
|
38 |
+
date_to = "2022-10-10"
|
39 |
+
with open(f"{DATA_PATH}/{date_from}.json", "w") as f:
|
40 |
+
ids_from = json.load(f)
|
41 |
+
with open(f"{DATA_PATH}/{date_to}.json", "w") as f:
|
42 |
+
ids_to = json.load(f)
|
43 |
+
ids = set(ids_to) - set(ids_from)
|
44 |
+
dss = sorted([ds for ds in datasets if ds.id in ids], key=lambda item: item.downloads, reverse=True)
|
45 |
+
return dss
|
46 |
+
|
47 |
+
|
48 |
+
def filter_dataframe(name):
|
49 |
+
dss = filter_datasets_by_date()
|
50 |
+
return [[ds.id, ds.downloads] for ds in dss]
|
51 |
|
52 |
|
53 |
def update_datasets():
|
|
|
67 |
scheduler.start()
|
68 |
|
69 |
|
70 |
+
# demo = gr.Interface(fn=greet, inputs="text", outputs="text")
|
71 |
+
demo = gr.Interface(
|
72 |
+
fn=filter_dataframe,
|
73 |
+
inputs="text",
|
74 |
+
outputs=gr.Dataframe(
|
75 |
+
headers=["Dataset", "Downloads"],
|
76 |
+
datatype=["str", "number"],
|
77 |
+
label="Created datasets",
|
78 |
+
),
|
79 |
+
)
|
80 |
demo.launch()
|