feat: support penalty config
All checks were successful
build / build (push) Successful in 2m2s
build / trigger-build-image (push) Successful in 8s

This commit is contained in:
张泊明518370910136 2025-06-19 06:43:29 -04:00
parent 42bbf3ce39
commit e2dc094263
GPG Key ID: D47306D7062CDA9D
4 changed files with 41 additions and 2 deletions

View File

@ -220,6 +220,11 @@ class Task(BaseModel):
name: str = "unknown" name: str = "unknown"
class Penalties(BaseModel):
hours: List[float] = []
factors: List[float] = []
class Config(BaseModel): class Config(BaseModel):
root: Path = Path(".") root: Path = Path(".")
path: Path = Path("task.toml") path: Path = Path("task.toml")
@ -228,6 +233,7 @@ class Config(BaseModel):
release: Release = Release() # Release configuration release: Release = Release() # Release configuration
stages: List[Stage] = [] # list of stage configurations stages: List[Stage] = [] # list of stage configurations
groups: Groups = Groups() groups: Groups = Groups()
penalties: Penalties = Penalties()
max_total_score: Optional[int] = Field( max_total_score: Optional[int] = Field(
None, validation_alias=AliasChoices("max-total-score", "max_total_score") None, validation_alias=AliasChoices("max-total-score", "max_total_score")
) )

View File

@ -41,6 +41,21 @@ def get_teapot_post_stage(
] ]
if not repo_conf.submitter_in_issue_title: if not repo_conf.submitter_in_issue_title:
args.append("--no-submitter-in-issue-title") args.append("--no-submitter-in-issue-title")
if task_conf.time.end:
args.extend(
[
"--end-time",
task_conf.time.end.strftime("%Y-%m-%dT%H:%M:%S"),
]
)
if task_conf.penalties.hours:
penalty_config = ",".join(
f"{hour}={factor}"
for hour, factor in zip(
task_conf.penalties.hours, task_conf.penalties.factors
)
)
args.extend(["--penalty-config", penalty_config])
stage_conf = result.StageDetail( stage_conf = result.StageDetail(
name="teapot", name="teapot",
@ -118,6 +133,14 @@ def get_teapot_check_args(repo_conf: repo.Config, task_conf: task.Config) -> Lis
res.extend(["--begin-time", task_conf.time.begin.strftime("%Y-%m-%dT%H:%M:%S")]) res.extend(["--begin-time", task_conf.time.begin.strftime("%Y-%m-%dT%H:%M:%S")])
if task_conf.time.end: if task_conf.time.end:
res.extend(["--end-time", task_conf.time.end.strftime("%Y-%m-%dT%H:%M:%S")]) res.extend(["--end-time", task_conf.time.end.strftime("%Y-%m-%dT%H:%M:%S")])
if task_conf.penalties.hours:
penalty_config = ",".join(
f"{hour}={factor}"
for hour, factor in zip(
task_conf.penalties.hours, task_conf.penalties.factors
)
)
res.extend(["--penalty-config", penalty_config])
return res return res

View File

@ -78,7 +78,9 @@
"--group-config", "--group-config",
"Manuel=500:24,Boming=501:48,Nuvole=502:72", "Manuel=500:24,Boming=501:48,Nuvole=502:72",
"--end-time", "--end-time",
"2024-12-30T23:59:59" "2024-12-30T23:59:59",
"--penalty-config",
"24.0=0.5,48.0=0.25,72.0=0.1"
], ],
"env": [ "env": [
"REPOS_DIR=/home/tt/.cache", "REPOS_DIR=/home/tt/.cache",
@ -808,7 +810,11 @@
"--grading-repo-name", "--grading-repo-name",
"ece280-joj", "ece280-joj",
"--max-total-score", "--max-total-score",
"10245871" "10245871",
"--end-time",
"2024-12-30T23:59:59",
"--penalty-config",
"24.0=0.5,48.0=0.25,72.0=0.1"
], ],
"env": [ "env": [
"REPOS_DIR=/home/tt/.cache", "REPOS_DIR=/home/tt/.cache",

View File

@ -5,6 +5,10 @@ max-total-score = 10245871
time.end = 2024-12-30 23:59:59+08:00 time.end = 2024-12-30 23:59:59+08:00
release.begin-time = 2024-12-29 23:59:59+08:00 release.begin-time = 2024-12-29 23:59:59+08:00
[penalties]
hours = [ 24, 48, 72 ]
factors = [ 0.5, 0.25, 0.1 ]
[groups] [groups]
name = ["Manuel", "Boming", "Nuvole"] name = ["Manuel", "Boming", "Nuvole"]
max-count = [500, 501, 502] max-count = [500, 501, 502]