Maharshi Gor
Squash merge dictify-states into main
9756440
raw
history blame
1.56 kB
from typing import Optional
import gradio as gr
from loguru import logger
from app_configs import UNSELECTED_PIPELINE_NAME
from components.structs import TossupWorkflow, Workflow
from display.formatting import styled_error
from submission import submit
def get_user_submission_names(profile: gr.OAuthProfile | None) -> list[str]:
if profile is None:
logger.error("Authentication required. Please log in to view your submissions.")
return []
return submit.get_user_submission_names("tossup", profile)
def get_pipeline_names(competition_type: str, profile: gr.OAuthProfile | None) -> list[str]:
demo_example_names = submit.get_demo_example_submissions(competition_type)
user_model_names = submit.get_user_submission_names(competition_type, profile)
all_names = demo_example_names + user_model_names
logger.info(f"Loaded model names: {all_names}")
return all_names
def load_workflow(
competition_type: str, model_name: str, profile: gr.OAuthProfile | None
) -> Workflow | TossupWorkflow | None:
if not model_name or model_name == UNSELECTED_PIPELINE_NAME:
return None
username, model_name = model_name.split("/")
if username == "umdclip":
workflow = submit.load_demo_example(model_name, competition_type)
elif profile is not None:
submission = submit.load_submission(model_name, competition_type, profile)
workflow = submission.workflow
else:
raise gr.Error("Authentication required. Please log in to view your submissions.")
return workflow