eduagarcia's picture
Permit different revision
a3b0a0f
raw
history blame
2.29 kB
import os
from datetime import datetime, timezone
from huggingface_hub import HfApi
from huggingface_hub.hf_api import ModelInfo
from src.envs import RESULTS_REPO, QUEUE_REPO, RAW_RESULTS_REPO
API = HfApi()
def model_hyperlink(link, model_name):
return f'<a target="_blank" href="{link}" style="color: var(--link-text-color); text-decoration: underline;text-decoration-style: dotted;">{model_name}</a>'
def make_requests_clickable_model(model_name, json_path=None):
link = f"https://huggingface.co/{model_name}"
#details_model_name = model_name.replace("/", "__")
details_link = f"https://huggingface.co/datasets/{QUEUE_REPO}/tree/main"
if '/' in model_name:
details_link += f"/{model_name.split('/')[0]}"
if json_path is not None:
details_link = f"https://huggingface.co/datasets/{QUEUE_REPO}/blob/main/{json_path}"
return model_hyperlink(link, model_name) + " " + model_hyperlink(details_link, "πŸ“‘")
def make_clickable_model(model_name, json_path=None, revision=None):
link = f"https://huggingface.co/{model_name}"
#details_model_name = model_name.replace("/", "__")
if RAW_RESULTS_REPO is not None:
details_link = f"https://huggingface.co/datasets/{RAW_RESULTS_REPO}/tree/main/{model_name}"
else:
details_link = f"https://huggingface.co/datasets/{RESULTS_REPO}/tree/main/{model_name}"
if json_path is not None:
details_link = f"https://huggingface.co/datasets/{RESULTS_REPO}/blob/main/{model_name}/{json_path}"
if revision is not None and revision != "main":
if len(revision) > 12:
revision = revision[:7]
model_name += f" (rev: {revision})"
return model_hyperlink(link, model_name) + " " + model_hyperlink(details_link, "πŸ“‘")
def styled_error(error):
return f"<p style='color: red; font-size: 20px; text-align: center;'>{error}</p>"
def styled_warning(warn):
return f"<p style='color: orange; font-size: 20px; text-align: center;'>{warn}</p>"
def styled_message(message):
return f"<p style='color: green; font-size: 20px; text-align: center;'>{message}</p>"
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)