Spaces:
Sleeping
Sleeping
File size: 1,878 Bytes
d6979e5 48e891a e68c056 48e891a b70cfbb d6979e5 48e891a d6979e5 47a0d88 b70cfbb 48e891a b70cfbb e68c056 f36d14b e68c056 48e891a d6979e5 48e891a 47a0d88 aac23b7 d6979e5 48e891a 40aae8d 48e891a 40aae8d 48e891a 40aae8d d6979e5 40aae8d d6979e5 b70cfbb d6979e5 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
import os
import json
import logging
import pandas as pd
import gradio as gr
import multiprocessing
from src.backend import pull_search_results
from src.envs import (
API, REPO_ID, START_COMMIT_ID,
HF_CACHE_DIR, SUBMIT_INFOS_SAVE_PATH,
HF_SEARCH_RESULTS_REPO_DIR, HF_EVAL_RESULTS_REPO_DIR,
UNZIP_TARGET_DIR,
TIME_DURATION,
EVAL_K_VALUES,
SUBMIT_INFOS_TABLE_COLS
)
from src.css_html_js import custom_css
logger = logging.getLogger(__name__)
logging.basicConfig(
level=logging.WARNING,
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s'
)
# def restart_space():
# API.restart_space(repo_id=REPO_ID)
def load_submit_infos_df():
if os.path.exists(SUBMIT_INFOS_SAVE_PATH):
with open(SUBMIT_INFOS_SAVE_PATH, 'r', encoding='utf-8') as f:
submit_infos = json.load(f)
else:
submit_infos = []
if submit_infos:
submit_infos_df = pd.DataFrame(submit_infos)[SUBMIT_INFOS_TABLE_COLS]
else:
submit_infos_df = pd.DataFrame(columns=SUBMIT_INFOS_TABLE_COLS)
return submit_infos_df
with gr.Blocks(css=custom_css) as demo:
gr.Markdown("## Submission Infos Table")
table = gr.components.Dataframe(
value=load_submit_infos_df(),
elem_id="submission-infos-table",
interactive=False,
)
refresh_button = gr.Button("Refresh Submission Infos")
refresh_button.click(
fn=load_submit_infos_df,
outputs=table,
)
if __name__ == "__main__":
process = multiprocessing.Process(
target=pull_search_results,
args=(
HF_SEARCH_RESULTS_REPO_DIR,
HF_EVAL_RESULTS_REPO_DIR,
UNZIP_TARGET_DIR,
EVAL_K_VALUES,
HF_CACHE_DIR,
TIME_DURATION,
START_COMMIT_ID,
),
)
process.start()
demo.launch()
|