Spaces:
Sleeping
Sleeping
File size: 2,374 Bytes
d6979e5 48e891a e68c056 48e891a b70cfbb d6979e5 47a60e0 f58e22b d6979e5 47a0d88 b70cfbb 48e891a b70cfbb e68c056 f36d14b f58e22b f36d14b e68c056 47a60e0 d6979e5 48e891a f58e22b 48e891a 47a0d88 aac23b7 d6979e5 48e891a 40aae8d 48e891a 40aae8d 99f7c39 40aae8d 48e891a 40aae8d d6979e5 40aae8d d6979e5 b70cfbb d6979e5 f58e22b d6979e5 dff4bae 47a60e0 05d123a |
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 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
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, START_COMMIT_ID, REPO_ID,
HF_CACHE_DIR, SUBMIT_INFOS_DIR, SUBMIT_INFOS_FILE_NAME,
HF_SEARCH_RESULTS_REPO_DIR, HF_EVAL_RESULTS_REPO_DIR, SUBMIT_INFOS_REPO,
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,
datefmt='%Y-%m-%d %H:%M:%S',
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
force=True
)
def restart_space():
API.restart_space(repo_id=REPO_ID)
def load_submit_infos_df():
# Pull the submit infos
API.snapshot_download(
repo_id=SUBMIT_INFOS_REPO,
repo_type="dataset",
local_dir=SUBMIT_INFOS_DIR,
etag_timeout=30
)
submit_infos_save_path = os.path.join(SUBMIT_INFOS_DIR, SUBMIT_INFOS_FILE_NAME)
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,
datatype="markdown"
)
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,
SUBMIT_INFOS_DIR,
SUBMIT_INFOS_FILE_NAME,
EVAL_K_VALUES,
HF_CACHE_DIR,
TIME_DURATION,
START_COMMIT_ID,
),
)
process.start()
demo.queue(default_concurrency_limit=40)
demo.launch()
|