feat: teapot stage added
This commit is contained in:
parent
1c48d9794b
commit
47c46755e6
|
@ -8,12 +8,13 @@ from joj3_config_generator.models import joj1, repo, result, task
|
||||||
from joj3_config_generator.processers.repo import (
|
from joj3_config_generator.processers.repo import (
|
||||||
get_healthcheck_config,
|
get_healthcheck_config,
|
||||||
get_teapot_config,
|
get_teapot_config,
|
||||||
|
get_teapotcheck_config,
|
||||||
)
|
)
|
||||||
from joj3_config_generator.processers.task import (
|
from joj3_config_generator.processers.task import (
|
||||||
fix_diff,
|
fix_diff,
|
||||||
fix_dummy,
|
fix_dummy,
|
||||||
fix_keyword,
|
|
||||||
fix_file,
|
fix_file,
|
||||||
|
fix_keyword,
|
||||||
fix_result_detail,
|
fix_result_detail,
|
||||||
get_conf_stage,
|
get_conf_stage,
|
||||||
get_executorWithConfig,
|
get_executorWithConfig,
|
||||||
|
@ -39,6 +40,7 @@ def convert(repo_conf: repo.Config, task_conf: task.Config) -> result.Config:
|
||||||
|
|
||||||
# Construct healthcheck stage
|
# Construct healthcheck stage
|
||||||
healthcheck_stage = get_healthcheck_config(repo_conf)
|
healthcheck_stage = get_healthcheck_config(repo_conf)
|
||||||
|
teapotcheck_stage = get_teapotcheck_config(repo_conf, task_conf)
|
||||||
result_conf.stage.stages.append(healthcheck_stage)
|
result_conf.stage.stages.append(healthcheck_stage)
|
||||||
cached: List[str] = []
|
cached: List[str] = []
|
||||||
# Convert each stage in the task configuration
|
# Convert each stage in the task configuration
|
||||||
|
|
|
@ -10,7 +10,6 @@ import yaml
|
||||||
|
|
||||||
from joj3_config_generator.convert import convert as convert_conf
|
from joj3_config_generator.convert import convert as convert_conf
|
||||||
from joj3_config_generator.convert import convert_joj1 as convert_joj1_conf
|
from joj3_config_generator.convert import convert_joj1 as convert_joj1_conf
|
||||||
from joj3_config_generator.convert import distribute_json
|
|
||||||
from joj3_config_generator.models import joj1, repo, task
|
from joj3_config_generator.models import joj1, repo, task
|
||||||
from joj3_config_generator.utils.logger import logger
|
from joj3_config_generator.utils.logger import logger
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
from typing import List, Optional
|
from typing import List
|
||||||
|
|
||||||
from pydantic import BaseModel, Field
|
from pydantic import BaseModel, Field
|
||||||
|
|
||||||
|
@ -7,11 +7,13 @@ class Files(BaseModel):
|
||||||
required: List[str]
|
required: List[str]
|
||||||
immutable: List[str]
|
immutable: List[str]
|
||||||
|
|
||||||
|
|
||||||
class Group(BaseModel):
|
class Group(BaseModel):
|
||||||
name: List[str]
|
name: List[str]
|
||||||
max_count: List[int]
|
max_count: List[int]
|
||||||
time_period_hour: List[int]
|
time_period_hour: List[int]
|
||||||
|
|
||||||
|
|
||||||
class Config(BaseModel):
|
class Config(BaseModel):
|
||||||
teaching_team: List[str]
|
teaching_team: List[str]
|
||||||
max_size: float = Field(..., ge=0)
|
max_size: float = Field(..., ge=0)
|
||||||
|
@ -19,4 +21,4 @@ class Config(BaseModel):
|
||||||
files: Files
|
files: Files
|
||||||
sandbox_token: str
|
sandbox_token: str
|
||||||
max_total_score: int = Field(100)
|
max_total_score: int = Field(100)
|
||||||
groups : Group
|
groups: Group
|
||||||
|
|
|
@ -33,7 +33,7 @@ class Cmd(BaseModel):
|
||||||
copy_in: Dict[str, CmdFile] = Field({}, serialization_alias="copyIn")
|
copy_in: Dict[str, CmdFile] = Field({}, serialization_alias="copyIn")
|
||||||
copy_in_cached: Dict[str, str] = Field({}, serialization_alias="copyInCached")
|
copy_in_cached: Dict[str, str] = Field({}, serialization_alias="copyInCached")
|
||||||
copy_in_dir: str = Field(".", serialization_alias="copyInDir")
|
copy_in_dir: str = Field(".", serialization_alias="copyInDir")
|
||||||
copy_out: List[str] = Field([], serialization_alias="copyOut")
|
copy_out: List[str] = Field(["stdout", "stderr"], serialization_alias="copyOut")
|
||||||
copy_out_cached: List[str] = Field([], serialization_alias="copyOutCached")
|
copy_out_cached: List[str] = Field([], serialization_alias="copyOutCached")
|
||||||
copy_out_max: int = Field(0, serialization_alias="copyOutMax")
|
copy_out_max: int = Field(0, serialization_alias="copyOutMax")
|
||||||
copy_out_dir: str = Field("", serialization_alias="copyOutDir")
|
copy_out_dir: str = Field("", serialization_alias="copyOutDir")
|
||||||
|
@ -68,7 +68,9 @@ class OptionalCmd(BaseModel):
|
||||||
None, serialization_alias="copyInCached"
|
None, serialization_alias="copyInCached"
|
||||||
)
|
)
|
||||||
copy_in_dir: Optional[str] = Field(None, serialization_alias="copyInDir")
|
copy_in_dir: Optional[str] = Field(None, serialization_alias="copyInDir")
|
||||||
copy_out: Optional[List[str]] = Field(None, serialization_alias="copyOut")
|
copy_out: Optional[List[str]] = Field(
|
||||||
|
["stdout", "stderr"], serialization_alias="copyOut"
|
||||||
|
)
|
||||||
copy_out_cached: Optional[List[str]] = Field(
|
copy_out_cached: Optional[List[str]] = Field(
|
||||||
None, serialization_alias="copyOutCached"
|
None, serialization_alias="copyOutCached"
|
||||||
)
|
)
|
||||||
|
@ -139,7 +141,9 @@ class Teapot(BaseModel):
|
||||||
skip_scoreboard: bool = Field(False, serialization_alias="skipScoreboard")
|
skip_scoreboard: bool = Field(False, serialization_alias="skipScoreboard")
|
||||||
skip_failed_table: bool = Field(False, serialization_alias="skipFailedTable")
|
skip_failed_table: bool = Field(False, serialization_alias="skipFailedTable")
|
||||||
max_total_score: int = Field(100, serialization_alias="maxTotalScore")
|
max_total_score: int = Field(100, serialization_alias="maxTotalScore")
|
||||||
groups: List[Dict[str, Any]] = Field([{"name": "", "maxCount": 100, "timePeriodHour": 24}])
|
groups: List[Dict[str, Any]] = Field(
|
||||||
|
[{"name": "", "maxCount": 100, "timePeriodHour": 24}]
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class Config(BaseModel):
|
class Config(BaseModel):
|
||||||
|
|
|
@ -11,9 +11,11 @@ class ParserResultDetail(BaseModel):
|
||||||
stderr: Optional[bool] = False # Display stderr messages
|
stderr: Optional[bool] = False # Display stderr messages
|
||||||
exitstatus: Optional[bool] = False
|
exitstatus: Optional[bool] = False
|
||||||
|
|
||||||
|
|
||||||
class ParserFile(BaseModel):
|
class ParserFile(BaseModel):
|
||||||
name: str = None
|
name: str = None
|
||||||
|
|
||||||
|
|
||||||
class ParserDummy(BaseModel):
|
class ParserDummy(BaseModel):
|
||||||
comment: Optional[str] = ""
|
comment: Optional[str] = ""
|
||||||
score: Optional[int] = 0
|
score: Optional[int] = 0
|
||||||
|
|
|
@ -22,13 +22,13 @@ def get_teapot_config(repo_conf: repo.Config, task_conf: task.Config) -> result.
|
||||||
"timePeriodHour": 24,
|
"timePeriodHour": 24,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
for idx, max_count in enumerate(repo_conf.groups.max_count):
|
for idx, max_count in enumerate(repo_conf.groups.max_count):
|
||||||
groups_config[idx]["maxCount"] = max_count
|
groups_config[idx]["maxCount"] = max_count
|
||||||
|
|
||||||
for idx, time_period_hour in enumerate(repo_conf.groups.time_period_hour):
|
for idx, time_period_hour in enumerate(repo_conf.groups.time_period_hour):
|
||||||
groups_config[idx]["timePeriodHour"] = time_period_hour
|
groups_config[idx]["timePeriodHour"] = time_period_hour
|
||||||
|
|
||||||
teapot = result.Teapot(
|
teapot = result.Teapot(
|
||||||
# TODO: fix the log path
|
# TODO: fix the log path
|
||||||
log_path=f"/home/tt/.cache/joj3/{task_conf.task.type_}-joint-teapot-debug.log",
|
log_path=f"/home/tt/.cache/joj3/{task_conf.task.type_}-joint-teapot-debug.log",
|
||||||
|
@ -45,7 +45,7 @@ def get_teapot_config(repo_conf: repo.Config, task_conf: task.Config) -> result.
|
||||||
),
|
),
|
||||||
grading_repo_name=get_grading_repo_name(),
|
grading_repo_name=get_grading_repo_name(),
|
||||||
max_total_score=repo_conf.max_total_score,
|
max_total_score=repo_conf.max_total_score,
|
||||||
groups=groups_config
|
groups=groups_config,
|
||||||
)
|
)
|
||||||
return teapot
|
return teapot
|
||||||
|
|
||||||
|
@ -88,6 +88,16 @@ def get_healthcheck_cmd(repo_conf: repo.Config) -> result.Cmd:
|
||||||
return cmd
|
return cmd
|
||||||
|
|
||||||
|
|
||||||
|
def get_teapotcheck_cmd(repo_conf: repo.Config, task_conf: task.Config) -> result.Cmd:
|
||||||
|
return 0
|
||||||
|
|
||||||
|
|
||||||
|
def get_teapotcheck_config(
|
||||||
|
repo_conf: repo.Config, task_conf: task.Config
|
||||||
|
) -> result.StageDetail:
|
||||||
|
return 0
|
||||||
|
|
||||||
|
|
||||||
def get_healthcheck_config(repo_conf: repo.Config) -> result.StageDetail:
|
def get_healthcheck_config(repo_conf: repo.Config) -> result.StageDetail:
|
||||||
healthcheck_stage = result.StageDetail(
|
healthcheck_stage = result.StageDetail(
|
||||||
name="healthcheck",
|
name="healthcheck",
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
import shlex
|
import shlex
|
||||||
import re
|
|
||||||
from typing import List, Tuple
|
from typing import List, Tuple
|
||||||
|
|
||||||
from joj3_config_generator.models import result, task
|
from joj3_config_generator.models import result, task
|
||||||
|
@ -16,11 +15,7 @@ def get_conf_stage(
|
||||||
# if (task_stage.name is not None and re.search(r'\[([^\[\]]+)\]', task_stage.name))
|
# if (task_stage.name is not None and re.search(r'\[([^\[\]]+)\]', task_stage.name))
|
||||||
# else ""
|
# else ""
|
||||||
# ),
|
# ),
|
||||||
group=(
|
group=(task_stage.group if (task_stage.group is not None) else ""),
|
||||||
task_stage.group
|
|
||||||
if (task_stage.group is not None)
|
|
||||||
else ""
|
|
||||||
),
|
|
||||||
executor=result.Executor(
|
executor=result.Executor(
|
||||||
name="sandbox",
|
name="sandbox",
|
||||||
with_=executor_with_config,
|
with_=executor_with_config,
|
||||||
|
@ -149,7 +144,14 @@ def fix_keyword(
|
||||||
else:
|
else:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
keyword_parser_.with_.update({"matches": keyword_weight, "fullscore": 0, "minscore": -1000, "files": ["stdout", "stderr"]})
|
keyword_parser_.with_.update(
|
||||||
|
{
|
||||||
|
"matches": keyword_weight,
|
||||||
|
"fullscore": 0,
|
||||||
|
"minscore": -1000,
|
||||||
|
"files": ["stdout", "stderr"],
|
||||||
|
}
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
continue
|
continue
|
||||||
return conf_stage
|
return conf_stage
|
||||||
|
@ -213,22 +215,22 @@ def fix_dummy(
|
||||||
continue
|
continue
|
||||||
return conf_stage
|
return conf_stage
|
||||||
|
|
||||||
def fix_file(task_stage: task.Stage, conf_stage: result.StageDetail) -> result.StageDetail:
|
|
||||||
|
def fix_file(
|
||||||
|
task_stage: task.Stage, conf_stage: result.StageDetail
|
||||||
|
) -> result.StageDetail:
|
||||||
file_parser = ["file"]
|
file_parser = ["file"]
|
||||||
if task_stage.parsers is not None:
|
if task_stage.parsers is not None:
|
||||||
for parser in task_stage.parsers:
|
for parser in task_stage.parsers:
|
||||||
if parser in file_parser:
|
if parser in file_parser:
|
||||||
file_parser_ = next(p for p in conf_stage.parsers if p.name == parser)
|
file_parser_ = next(p for p in conf_stage.parsers if p.name == parser)
|
||||||
if task_stage.file is not None:
|
if task_stage.file is not None:
|
||||||
file_parser_.with_.update(
|
file_parser_.with_.update({"name": task_stage.file.name})
|
||||||
{
|
|
||||||
"name": task_stage.file.name
|
|
||||||
}
|
|
||||||
)
|
|
||||||
else:
|
else:
|
||||||
continue
|
continue
|
||||||
return conf_stage
|
return conf_stage
|
||||||
|
|
||||||
|
|
||||||
def fix_diff(
|
def fix_diff(
|
||||||
task_stage: task.Stage, conf_stage: result.StageDetail, task_conf: task.Config
|
task_stage: task.Stage, conf_stage: result.StageDetail, task_conf: task.Config
|
||||||
) -> result.StageDetail:
|
) -> result.StageDetail:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user