import gradio as gr
def model_hyperlink(link, model_name):
return f'{model_name}'
def make_clickable_model(model_name, result_file=""):
link = f"https://huggingface.co/{model_name}"
return model_hyperlink(link, model_name)
def styled_error(error: str) -> str:
"""Return a styled error card (HTML)."""
return (
f"
"
f"
"
f"\u274c"
f"{error}"
f"
"
f"
"
)
def styled_warning(warn: str) -> str:
"""Return a styled warning card (HTML)."""
return (
f""
f"
"
f"\u26a0\ufe0f"
f"{warn}"
f"
"
f"
"
)
def styled_message(message):
gr.Info(message)
return ""
def styled_success(title: str, eta: str, subtitle: str = "") -> str:
"""Return a styled success card with ETA (rendered in the output Markdown area)."""
sub_html = (
f"{subtitle}
"
if subtitle else ""
)
return (
f""
# Title row
f"
"
f"✅"
f"{title}"
f"
"
# ETA badge
f"
"
f"⏱"
f""
f"Estimated completion time: {eta}"
f"
"
f"{sub_html}"
f"
"
)
def styled_progress(step: int, total: int, message: str) -> str:
"""Return a styled progress indicator (HTML)."""
pct = min(int(step / total * 100) if total > 0 else 0, 99)
# Dots indicator: filled for completed steps, hollow for remaining
dots = "".join(
""
for i in range(total)
)
return (
f""
# Step label
f"
"
f"⚙ {message}"
f"{step}/{total}"
f"
"
# Progress bar
f"
"
# Dots + percentage
f"
"
f"
"
)
def has_no_nan_values(df, columns):
return df[columns].notna().all(axis=1)
def has_nan_values(df, columns):
return df[columns].isna().any(axis=1)