Commit
·
de9585b
1
Parent(s):
58db0a0
Hacky but refreshing works. Now to simplify
Browse files
app.py
CHANGED
|
@@ -15,12 +15,7 @@ from constants import (
|
|
| 15 |
from about import ABOUT_TEXT, FAQS
|
| 16 |
from submit import make_submission
|
| 17 |
|
| 18 |
-
|
| 19 |
def format_leaderboard_table(df_results: pd.DataFrame, assay: str | None = None):
|
| 20 |
-
# Previous things that were nice in the constellaration leaderboard:
|
| 21 |
-
# Having a submission time column, and a user column where the username is clickable (this is a pro for usability but con for anonymity)
|
| 22 |
-
# full_df.rename(columns={'submission_time': 'submission time', 'problem_type': 'problem type'}, inplace=True)
|
| 23 |
-
# to_show['user'] = to_show['user'].apply(lambda x: make_user_clickable(x)).astype(str)
|
| 24 |
df = df_results.query("assay.isin(@ASSAY_RENAME.keys())").copy()
|
| 25 |
if assay is not None:
|
| 26 |
df = df[df["assay"] == assay]
|
|
@@ -34,19 +29,34 @@ def get_leaderboard_object(assay: str | None = None):
|
|
| 34 |
filter_columns.append("property")
|
| 35 |
# TODO how to sort filter columns alphabetically?
|
| 36 |
# Bug: Can't leave search_columns empty because then it says "Column None not found in headers"
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
|
|
|
| 40 |
datatype=["str", "str", "str", "number"],
|
| 41 |
select_columns=["model", "property", "spearman", "dataset"],
|
| 42 |
-
search_columns=["model"],
|
| 43 |
filter_columns=filter_columns,
|
| 44 |
-
every=
|
| 45 |
render=True,
|
| 46 |
)
|
|
|
|
|
|
|
| 47 |
|
|
|
|
|
|
|
| 48 |
|
| 49 |
with gr.Blocks() as demo:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 50 |
# TODO: Add Ginkgo logo here on the top right
|
| 51 |
gr.Markdown("""
|
| 52 |
## Welcome to the Ginkgo Antibody Developability Benchmark!
|
|
@@ -73,19 +83,25 @@ with gr.Blocks() as demo:
|
|
| 73 |
gr.Markdown(f"*{answer}*") # Italics for answers
|
| 74 |
|
| 75 |
# Procedurally make these 5 tabs
|
| 76 |
-
|
|
|
|
| 77 |
with gr.TabItem(
|
| 78 |
f"{ASSAY_EMOJIS[assay]} {ASSAY_RENAME[assay]}",
|
| 79 |
elem_id="abdev-benchmark-tab-table",
|
| 80 |
):
|
| 81 |
gr.Markdown(f"# {ASSAY_DESCRIPTION[assay]}")
|
| 82 |
-
get_leaderboard_object(assay=assay)
|
|
|
|
|
|
|
| 83 |
|
| 84 |
with gr.TabItem("🚀 Overall", elem_id="abdev-benchmark-tab-table"):
|
| 85 |
gr.Markdown(
|
| 86 |
"# Antibody Developability Benchmark Leaderboard over all properties"
|
| 87 |
)
|
| 88 |
-
get_leaderboard_object()
|
|
|
|
|
|
|
|
|
|
| 89 |
|
| 90 |
with gr.TabItem("✉️ Submit", elem_id="boundary-benchmark-tab-table"):
|
| 91 |
gr.Markdown(
|
|
|
|
| 15 |
from about import ABOUT_TEXT, FAQS
|
| 16 |
from submit import make_submission
|
| 17 |
|
|
|
|
| 18 |
def format_leaderboard_table(df_results: pd.DataFrame, assay: str | None = None):
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
df = df_results.query("assay.isin(@ASSAY_RENAME.keys())").copy()
|
| 20 |
if assay is not None:
|
| 21 |
df = df[df["assay"] == assay]
|
|
|
|
| 29 |
filter_columns.append("property")
|
| 30 |
# TODO how to sort filter columns alphabetically?
|
| 31 |
# Bug: Can't leave search_columns empty because then it says "Column None not found in headers"
|
| 32 |
+
# Note(Lood): Would be nice to make it clear that the Search Column is searching on model name
|
| 33 |
+
# TODO(Lood) check that this actually refreshes using the function
|
| 34 |
+
lb = Leaderboard(
|
| 35 |
+
value=format_leaderboard_table(df_results=current_dataframe, assay=assay),
|
| 36 |
datatype=["str", "str", "str", "number"],
|
| 37 |
select_columns=["model", "property", "spearman", "dataset"],
|
| 38 |
+
search_columns=["model"],
|
| 39 |
filter_columns=filter_columns,
|
| 40 |
+
every=15,
|
| 41 |
render=True,
|
| 42 |
)
|
| 43 |
+
return lb
|
| 44 |
+
|
| 45 |
|
| 46 |
+
# Initialize global dataframe
|
| 47 |
+
current_dataframe = fetch_hf_results()
|
| 48 |
|
| 49 |
with gr.Blocks() as demo:
|
| 50 |
+
timer = gr.Timer(10)
|
| 51 |
+
|
| 52 |
+
def update_current_dataframe():
|
| 53 |
+
global current_dataframe
|
| 54 |
+
current_dataframe = fetch_hf_results()
|
| 55 |
+
# Don't return anything, just update the global dataframe
|
| 56 |
+
|
| 57 |
+
timer.tick(fn=update_current_dataframe) # Keep this up to date, all leaderboard objects will use this
|
| 58 |
+
timers = [gr.Timer(10) for _ in range(6)] # One timer for each tab
|
| 59 |
+
|
| 60 |
# TODO: Add Ginkgo logo here on the top right
|
| 61 |
gr.Markdown("""
|
| 62 |
## Welcome to the Ginkgo Antibody Developability Benchmark!
|
|
|
|
| 83 |
gr.Markdown(f"*{answer}*") # Italics for answers
|
| 84 |
|
| 85 |
# Procedurally make these 5 tabs
|
| 86 |
+
leaderboards = []
|
| 87 |
+
for i, assay in enumerate(ASSAY_LIST):
|
| 88 |
with gr.TabItem(
|
| 89 |
f"{ASSAY_EMOJIS[assay]} {ASSAY_RENAME[assay]}",
|
| 90 |
elem_id="abdev-benchmark-tab-table",
|
| 91 |
):
|
| 92 |
gr.Markdown(f"# {ASSAY_DESCRIPTION[assay]}")
|
| 93 |
+
lb = get_leaderboard_object(assay=assay)
|
| 94 |
+
leaderboards.append(lb)
|
| 95 |
+
timers[i].tick(fn=lambda _, assay=assay: format_leaderboard_table(df_results=current_dataframe, assay=assay), inputs=leaderboards[i], outputs=leaderboards[i])
|
| 96 |
|
| 97 |
with gr.TabItem("🚀 Overall", elem_id="abdev-benchmark-tab-table"):
|
| 98 |
gr.Markdown(
|
| 99 |
"# Antibody Developability Benchmark Leaderboard over all properties"
|
| 100 |
)
|
| 101 |
+
lb = get_leaderboard_object()
|
| 102 |
+
leaderboards.append(lb)
|
| 103 |
+
# Replace the value every 10 seconds
|
| 104 |
+
timers[5].tick(fn=lambda _: format_leaderboard_table(df_results=current_dataframe), inputs=leaderboards[5], outputs=leaderboards[5])
|
| 105 |
|
| 106 |
with gr.TabItem("✉️ Submit", elem_id="boundary-benchmark-tab-table"):
|
| 107 |
gr.Markdown(
|
utils.py
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
|
|
| 1 |
import pandas as pd
|
| 2 |
from datasets import load_dataset
|
| 3 |
import gradio as gr
|
|
@@ -12,6 +13,9 @@ def show_output_box(message):
|
|
| 12 |
|
| 13 |
|
| 14 |
def fetch_hf_results():
|
|
|
|
|
|
|
|
|
|
| 15 |
# Should cache by default if not using force_redownload
|
| 16 |
df = load_dataset(
|
| 17 |
RESULTS_REPO, data_files="auto_submissions/metrics_all.csv",
|
|
|
|
| 1 |
+
from datetime import datetime, timezone, timedelta
|
| 2 |
import pandas as pd
|
| 3 |
from datasets import load_dataset
|
| 4 |
import gradio as gr
|
|
|
|
| 13 |
|
| 14 |
|
| 15 |
def fetch_hf_results():
|
| 16 |
+
# Print current time in EST
|
| 17 |
+
EST = timezone(timedelta(hours=-4))
|
| 18 |
+
print(f"tmp: Fetching results from HF at {datetime.now(EST)}")
|
| 19 |
# Should cache by default if not using force_redownload
|
| 20 |
df = load_dataset(
|
| 21 |
RESULTS_REPO, data_files="auto_submissions/metrics_all.csv",
|