feat: task.name -> name in task.toml
This commit is contained in:
parent
6a7c5eb5f8
commit
7c764ab2cb
|
@ -27,7 +27,7 @@ def convert_joj1_conf(joj1_conf: joj1.Config) -> task.Config:
|
||||||
def convert_joj3_conf(repo_conf: repo.Config, task_conf: task.Config) -> result.Config:
|
def convert_joj3_conf(repo_conf: repo.Config, task_conf: task.Config) -> result.Config:
|
||||||
# Create the base ResultConf object
|
# Create the base ResultConf object
|
||||||
result_conf = result.Config(
|
result_conf = result.Config(
|
||||||
name=task_conf.task.name,
|
name=task_conf.name,
|
||||||
# exact folder difference specified by type
|
# exact folder difference specified by type
|
||||||
log_path=str(JOJ3_LOG_BASE_PATH / task_conf.suffix / JOJ3_LOG_FILENAME),
|
log_path=str(JOJ3_LOG_BASE_PATH / task_conf.suffix / JOJ3_LOG_FILENAME),
|
||||||
# TODO: remove these 2 fields, will be handled in the health check stage
|
# TODO: remove these 2 fields, will be handled in the health check stage
|
||||||
|
|
|
@ -266,7 +266,8 @@ class Config(BaseModel):
|
||||||
path: Path = Field(Path("task.toml"), exclude=True)
|
path: Path = Field(Path("task.toml"), exclude=True)
|
||||||
suffix: str = Field("", exclude=True)
|
suffix: str = Field("", exclude=True)
|
||||||
|
|
||||||
task: Task = Task() # Task name (e.g., hw3 ex5)
|
task: Task = Task() # TODO: remove it in the future
|
||||||
|
name: str = "unknown" # Task name (e.g., hw3 ex5)
|
||||||
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")
|
||||||
)
|
)
|
||||||
|
@ -277,10 +278,17 @@ class Config(BaseModel):
|
||||||
penalties: Penalties = Penalties()
|
penalties: Penalties = Penalties()
|
||||||
stages: List[Stage] = [] # list of stage configurations
|
stages: List[Stage] = [] # list of stage configurations
|
||||||
|
|
||||||
|
# TODO: remove this validator in the future
|
||||||
|
@model_validator(mode="after")
|
||||||
|
def set_name(self) -> "Config":
|
||||||
|
if "task" in self.model_fields_set and "name" in self.task.model_fields_set:
|
||||||
|
self.name = self.task.name
|
||||||
|
return self
|
||||||
|
|
||||||
@model_validator(mode="after")
|
@model_validator(mode="after")
|
||||||
def set_suffix(self) -> "Config":
|
def set_suffix(self) -> "Config":
|
||||||
if not self.suffix:
|
if not self.suffix:
|
||||||
self.suffix = re.split(r"[-_/\s]+", self.task.name)[0]
|
self.suffix = re.split(r"[-_/\s]+", self.name)[0]
|
||||||
return self
|
return self
|
||||||
|
|
||||||
@model_validator(mode="after")
|
@model_validator(mode="after")
|
||||||
|
|
|
@ -9,16 +9,16 @@ def get_task_conf_from_answers(answers: answer.Answers) -> task.Config:
|
||||||
if answers.template_file_content:
|
if answers.template_file_content:
|
||||||
toml_dict = tomli.loads(answers.template_file_content)
|
toml_dict = tomli.loads(answers.template_file_content)
|
||||||
return task.Config(
|
return task.Config(
|
||||||
task=task.Task(name=answers.name),
|
name=answers.name,
|
||||||
stages=toml_dict["stages"],
|
stages=toml_dict["stages"],
|
||||||
)
|
)
|
||||||
language = answers.language
|
language = answers.language
|
||||||
transformer_dict = get_transformer_dict()
|
transformer_dict = get_transformer_dict()
|
||||||
if language not in transformer_dict:
|
if language not in transformer_dict:
|
||||||
return task.Config(task=task.Task(name=answers.name), stages=[])
|
return task.Config(name=answers.name, stages=[])
|
||||||
transformer = transformer_dict[language]
|
transformer = transformer_dict[language]
|
||||||
stages = transformer(language)
|
stages = transformer(language)
|
||||||
return task.Config(task=task.Task(name=answers.name), stages=stages)
|
return task.Config(name=answers.name, stages=stages)
|
||||||
|
|
||||||
|
|
||||||
def get_transformer_dict() -> Dict[
|
def get_transformer_dict() -> Dict[
|
||||||
|
|
Loading…
Reference in New Issue
Block a user