Clémentine
commited on
Commit
·
9fec70b
1
Parent(s):
6e99f98
ux improvement: colors, logs
Browse files- app.py +3 -3
- utils/io.py +27 -5
app.py
CHANGED
|
@@ -43,10 +43,10 @@ def create_app() -> gr.Blocks:
|
|
| 43 |
with gr.Column():
|
| 44 |
gr.Markdown("## Job Results")
|
| 45 |
results_table = gr.Dataframe(
|
| 46 |
-
headers=["Model", "Provider", "Last Run", "Status", "Current Score", "Previous Score", "Latest Job Id"],
|
| 47 |
value=get_results_table(),
|
| 48 |
-
interactive=
|
| 49 |
-
wrap=True
|
|
|
|
| 50 |
)
|
| 51 |
refresh_btn = gr.Button("Refresh Results")
|
| 52 |
|
|
|
|
| 43 |
with gr.Column():
|
| 44 |
gr.Markdown("## Job Results")
|
| 45 |
results_table = gr.Dataframe(
|
|
|
|
| 46 |
value=get_results_table(),
|
| 47 |
+
interactive=False,
|
| 48 |
+
wrap=True,
|
| 49 |
+
datatype=["str", "str", "str", "str", "str", "str", "html"]
|
| 50 |
)
|
| 51 |
refresh_btn = gr.Button("Refresh Results")
|
| 52 |
|
utils/io.py
CHANGED
|
@@ -120,11 +120,21 @@ def load_results() -> None:
|
|
| 120 |
print(f"No existing dataset found or error loading: {e}")
|
| 121 |
print("Starting with empty results")
|
| 122 |
|
| 123 |
-
def
|
| 124 |
-
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 125 |
with globals.results_lock:
|
| 126 |
if not globals.job_results:
|
| 127 |
-
return []
|
| 128 |
|
| 129 |
table_data = []
|
| 130 |
for key, info in globals.job_results.items():
|
|
@@ -136,6 +146,14 @@ def get_results_table() -> List[List[str]]:
|
|
| 136 |
if previous_score is not None and isinstance(previous_score, (int, float)):
|
| 137 |
previous_score = f"{previous_score:.4f}"
|
| 138 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 139 |
table_data.append([
|
| 140 |
info["model"],
|
| 141 |
info["provider"],
|
|
@@ -143,8 +161,12 @@ def get_results_table() -> List[List[str]]:
|
|
| 143 |
info["status"],
|
| 144 |
current_score,
|
| 145 |
previous_score,
|
| 146 |
-
|
| 147 |
])
|
| 148 |
|
| 149 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 150 |
|
|
|
|
| 120 |
print(f"No existing dataset found or error loading: {e}")
|
| 121 |
print("Starting with empty results")
|
| 122 |
|
| 123 |
+
def style_status(val):
|
| 124 |
+
"""Style function for status column."""
|
| 125 |
+
if val == "COMPLETED":
|
| 126 |
+
return 'background-color: green'
|
| 127 |
+
elif val == "ERROR":
|
| 128 |
+
return 'background-color: red'
|
| 129 |
+
elif val == "RUNNING":
|
| 130 |
+
return 'background-color: blue'
|
| 131 |
+
return ''
|
| 132 |
+
|
| 133 |
+
def get_results_table():
|
| 134 |
+
"""Return job results as a styled pandas DataFrame for Gradio DataFrame."""
|
| 135 |
with globals.results_lock:
|
| 136 |
if not globals.job_results:
|
| 137 |
+
return pd.DataFrame(columns=["Model", "Provider", "Last Run", "Status", "Current Score", "Previous Score", "Latest Job Id"])
|
| 138 |
|
| 139 |
table_data = []
|
| 140 |
for key, info in globals.job_results.items():
|
|
|
|
| 146 |
if previous_score is not None and isinstance(previous_score, (int, float)):
|
| 147 |
previous_score = f"{previous_score:.4f}"
|
| 148 |
|
| 149 |
+
job_id = info.get("job_id", "N/A")
|
| 150 |
+
# Create a clickable link for the job ID
|
| 151 |
+
if job_id != "N/A":
|
| 152 |
+
job_url = f"https://hf.co/jobs/{globals.NAMESPACE}/{job_id}"
|
| 153 |
+
job_link = f'{job_id}: <a href="{job_url}" target="_blank">📄</a> '
|
| 154 |
+
else:
|
| 155 |
+
job_link = job_id
|
| 156 |
+
|
| 157 |
table_data.append([
|
| 158 |
info["model"],
|
| 159 |
info["provider"],
|
|
|
|
| 161 |
info["status"],
|
| 162 |
current_score,
|
| 163 |
previous_score,
|
| 164 |
+
job_link
|
| 165 |
])
|
| 166 |
|
| 167 |
+
df = pd.DataFrame(table_data, columns=["Model", "Provider", "Last Run", "Status", "Current Score", "Previous Score", "Job Id and Logs"])
|
| 168 |
+
|
| 169 |
+
# Apply styling to the Status column
|
| 170 |
+
styled_df = df.style.map(style_status, subset=['Status'])
|
| 171 |
+
return styled_df
|
| 172 |
|