Weyaxi commited on
Commit
f232a9e
·
1 Parent(s): a5b7670

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -0
app.py CHANGED
@@ -10,6 +10,22 @@ import datetime
10
  api = HfApi()
11
 
12
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13
  def get_most(df_for_most_function):
14
  download_sorted_df = df_for_most_function.sort_values(by=['downloads'], ascending=False)
15
  most_downloaded = download_sorted_df.iloc[0]
@@ -518,6 +534,7 @@ with gr.Blocks() as demo:
518
  datatype=["str", "markdown", "str", "str", "str", "markdown", "str", "markdown", "str",
519
  "str"])
520
 
 
521
  with gr.TabItem("🔍 Search", id=4):
522
  with gr.Column(min_width=320):
523
  search_bar = gr.Textbox(
@@ -529,6 +546,9 @@ with gr.Blocks() as demo:
529
  search_bar.submit(fn=search_df, inputs=search_bar, outputs=yazi)
530
 
531
 
 
 
 
532
  orgs.change(fn=update_table, inputs=[orgs, users], outputs=gr_models)
533
 
534
  orgs.change(fn=update_table_datasets, inputs=[orgs, users], outputs=gr_datasets)
 
10
  api = HfApi()
11
 
12
 
13
+ HF_TOKEN = os.getenv('HF_TOKEN')
14
+
15
+ def get_time():
16
+ return datetime.datetime.now().strftime("%d-%m-%Y %H-%M-%S")
17
+
18
+
19
+ def upload_datasets(dfs):
20
+ time = get_time()
21
+
22
+ operations = [CommitOperationAdd(path_in_repo=f"{time}/models_df.csv", path_or_fileobj=(dfs[0].to_csv()).encode()),
23
+ CommitOperationAdd(path_in_repo=f"{time}/datasets_df.csv", path_or_fileobj=(dfs[1].to_csv()).encode()),
24
+ CommitOperationAdd(path_in_repo=f"{time}/spaces_df.csv", path_or_fileobj=(dfs[2].to_csv()).encode())]
25
+
26
+ return (create_commit(repo_id="PulsarAI/huggingface-leaderboard-history", operations=operations, commit_message=f"Uploading history of {time}", repo_type="dataset", token=HF_TOKEN))
27
+
28
+
29
  def get_most(df_for_most_function):
30
  download_sorted_df = df_for_most_function.sort_values(by=['downloads'], ascending=False)
31
  most_downloaded = download_sorted_df.iloc[0]
 
534
  datatype=["str", "markdown", "str", "str", "str", "markdown", "str", "markdown", "str",
535
  "str"])
536
 
537
+
538
  with gr.TabItem("🔍 Search", id=4):
539
  with gr.Column(min_width=320):
540
  search_bar = gr.Textbox(
 
546
  search_bar.submit(fn=search_df, inputs=search_bar, outputs=yazi)
547
 
548
 
549
+ commit = upload_datasets([models_df, dataset_df, spaces_df])
550
+ print(commit)
551
+
552
  orgs.change(fn=update_table, inputs=[orgs, users], outputs=gr_models)
553
 
554
  orgs.change(fn=update_table_datasets, inputs=[orgs, users], outputs=gr_datasets)