| import random |
| import pandas as pd |
| import streamlit as st |
| from datasets import load_dataset |
|
|
| st.title("Code Arena") |
|
|
| with st.spinner("Loading data...", show_time=True): |
| problem_dict = dict() |
| ds = load_dataset("Elfsong/leetcode_data", split='train') |
| for problem in ds: |
| problem_id = problem["problem_id"] |
| problem_dict[problem_id] = problem |
|
|
|
|
| if "problem" in st.query_params: |
| problem_id = int(st.query_params["problem"]) |
| st.write(f"Problem Description - [{problem_id}]") |
| st.write(problem_dict[problem_id]) |
| |
| else: |
| with st.spinner("Loading Framework...", show_time=True): |
| df = pd.DataFrame( |
| { |
| "problem_id": [problem['problem_id'] for problem in ds], |
| "problem_link": ["https://huggingface.co/spaces/Elfsong/CodeArena/?problem=" + str(problem['problem_id']) for problem in ds], |
| "dynamic_point": [[random.randint(0, 5000) for _ in range(30)] for problem in ds], |
| } |
| ) |
| |
| tab_problem, tab_submission, tab_model = st.tabs(["Problems", "Submissions", "Models"]) |
| with tab_problem: |
| |
| st.dataframe( |
| df, |
| column_config={ |
| "problem_id": st.column_config.TextColumn("Problem ID"), |
| "dynamic_point": st.column_config.LineChartColumn("Dynamic Point", y_min=0, y_max=5000), |
| "problem_link": st.column_config.LinkColumn("Link", display_text="Open"), |
| }, |
| hide_index=True, |
| ) |
|
|
| with tab_submission: |
| st.header("Submissions") |
|
|
| with tab_model: |
| st.header("Models") |
|
|