feat(test_panel): integrate scraped data

This commit is contained in:
Barrett Ruth 2025-09-19 20:41:19 -04:00
parent fe25b00537
commit 793063a68e
11 changed files with 160 additions and 40 deletions

View file

@ -11,7 +11,7 @@ from bs4 import BeautifulSoup, Tag
from .models import MetadataResult, ProblemSummary, TestCase, TestsResult
def extract_problem_limits(soup: BeautifulSoup) -> tuple[int, int]:
def extract_problem_limits(soup: BeautifulSoup) -> tuple[int, float]:
timeout_ms = None
memory_mb = None
@ -26,7 +26,8 @@ def extract_problem_limits(soup: BeautifulSoup) -> tuple[int, int]:
memory_match = re.search(r"Memory Limit:\s*(\d+)\s*MiB", text)
if memory_match:
memory_mb = int(memory_match.group(1))
memory_mib = int(memory_match.group(1))
memory_mb = round(memory_mib * 1.048576, 2)
break
if timeout_ms is None:

View file

@ -140,7 +140,7 @@ def parse_problem_url(contest_id: str, problem_letter: str) -> str:
)
def extract_problem_limits(soup: BeautifulSoup) -> tuple[int, int]:
def extract_problem_limits(soup: BeautifulSoup) -> tuple[int, float]:
import re
timeout_ms = None
@ -162,7 +162,7 @@ def extract_problem_limits(soup: BeautifulSoup) -> tuple[int, int]:
text = memory_limit_div.get_text().strip()
match = re.search(r"(\d+) megabytes", text)
if match:
memory_mb = int(match.group(1))
memory_mb = float(match.group(1))
if memory_mb is None:
raise ValueError("Could not find valid memory limit in memory-limit section")

View file

@ -19,7 +19,7 @@ def parse_problem_url(problem_input: str) -> str | None:
return None
def extract_problem_limits(soup: BeautifulSoup) -> tuple[int, int]:
def extract_problem_limits(soup: BeautifulSoup) -> tuple[int, float]:
timeout_ms = None
memory_mb = None
@ -39,7 +39,7 @@ def extract_problem_limits(soup: BeautifulSoup) -> tuple[int, int]:
if "Memory limit:" in text:
match = re.search(r"Memory limit:\s*(\d+)\s*MB", text)
if match:
memory_mb = int(match.group(1))
memory_mb = float(match.group(1))
if timeout_ms is None:
raise ValueError("Could not find valid timeout in task-constraints section")

View file

@ -13,14 +13,6 @@ class ProblemSummary:
name: str
@dataclass
class Problem:
id: str
name: str
timeout_ms: int
memory_mb: int
@dataclass
class ScrapingResult:
success: bool
@ -40,4 +32,4 @@ class TestsResult(ScrapingResult):
url: str
tests: list[TestCase]
timeout_ms: int
memory_mb: int
memory_mb: float