fix: alias
This commit is contained in:
		
							parent
							
								
									3bb7cc195c
								
							
						
					
					
						commit
						70440382d2
					
				|  | @ -2,7 +2,7 @@ import socket | ||||||
| from pathlib import Path | from pathlib import Path | ||||||
| from typing import List | from typing import List | ||||||
| 
 | 
 | ||||||
| from pydantic import BaseModel, Field | from pydantic import AliasChoices, BaseModel, Field | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| class Files(BaseModel): | class Files(BaseModel): | ||||||
|  | @ -12,24 +12,50 @@ class Files(BaseModel): | ||||||
| 
 | 
 | ||||||
| class Groups(BaseModel): | class Groups(BaseModel): | ||||||
|     name: List[str] = [] |     name: List[str] = [] | ||||||
|     max_count: List[int] = Field([], alias="max-count") |     max_count: List[int] = Field( | ||||||
|     time_period_hour: List[int] = Field([], alias="time-period-hour") |         [], validation_alias=AliasChoices("max-count", "max_count") | ||||||
|  |     ) | ||||||
|  |     time_period_hour: List[int] = Field( | ||||||
|  |         [], validation_alias=AliasChoices("time-period-hour", "time_period_hour") | ||||||
|  |     ) | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| class Config(BaseModel): | class Config(BaseModel): | ||||||
|     max_size: float = Field(10, ge=0, alias="max-size") |     max_size: float = Field( | ||||||
|     files: Files = Files() |         10, ge=0, validation_alias=AliasChoices("max-size", "max_size") | ||||||
|     sandbox_token: str = Field("", alias="sandbox-token") |     ) | ||||||
|     max_total_score: int = Field(100, alias="max-total-score") |     files: Files = Files() | ||||||
|     force_skip_health_check_on_test: bool = Field( |     sandbox_token: str = Field( | ||||||
|         False, alias="force-skip-health-check-on-test" |         "", validation_alias=AliasChoices("sandbox-token", "sandbox_token") | ||||||
|  |     ) | ||||||
|  |     max_total_score: int = Field( | ||||||
|  |         100, validation_alias=AliasChoices("max-total-score", "max_total_score") | ||||||
|  |     ) | ||||||
|  |     force_skip_health_check_on_test: bool = Field( | ||||||
|  |         False, | ||||||
|  |         validation_alias=AliasChoices( | ||||||
|  |             "force-skip-health-check-on-test", "force_skip_health_check_on_test" | ||||||
|  |         ), | ||||||
|  |     ) | ||||||
|  |     force_skip_teapot_on_test: bool = Field( | ||||||
|  |         False, | ||||||
|  |         validation_alias=AliasChoices( | ||||||
|  |             "force-skip-teapot-on-test", "force_skip_teapot_on_test" | ||||||
|  |         ), | ||||||
|     ) |     ) | ||||||
|     force_skip_teapot_on_test: bool = Field(False, alias="force-skip-teapot-on-test") |  | ||||||
|     groups: Groups = Groups() |     groups: Groups = Groups() | ||||||
|     root: Path = Path(".") |     root: Path = Path(".") | ||||||
|     path: Path = Path("repo.toml") |     path: Path = Path("repo.toml") | ||||||
|     grading_repo_name: str = Field( |     grading_repo_name: str = Field( | ||||||
|         f"{socket.gethostname().split('-')[0]}-joj", alias="grading-repo-name" |         f"{socket.gethostname().split('-')[0]}-joj", | ||||||
|  |         validation_alias=AliasChoices("grading-repo-name", "grading_repo_name"), | ||||||
|  |     ) | ||||||
|  |     health_check_score: int = Field( | ||||||
|  |         0, validation_alias=AliasChoices("health-check-score", "health_check_score") | ||||||
|  |     ) | ||||||
|  |     submitter_in_issue_title: bool = Field( | ||||||
|  |         True, | ||||||
|  |         validation_alias=AliasChoices( | ||||||
|  |             "submitter-in-issue-title", "submitter_in_issue_title" | ||||||
|  |         ), | ||||||
|     ) |     ) | ||||||
|     health_check_score: int = Field(0, alias="health-check-score") |  | ||||||
|     submitter_in_issue_title: bool = Field(True, alias="submitter-in-issue-title") |  | ||||||
|  |  | ||||||
|  | @ -21,7 +21,7 @@ class MemoryFile(BaseModel): | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| class PreparedFile(BaseModel): | class PreparedFile(BaseModel): | ||||||
|     file_id: str = Field(..., alias="fileId") |     file_id: str = Field(..., serialization_alias="fileId") | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| class Collector(BaseModel): | class Collector(BaseModel): | ||||||
|  | @ -35,11 +35,11 @@ class Symlink(BaseModel): | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| class StreamIn(BaseModel): | class StreamIn(BaseModel): | ||||||
|     stream_in: bool = Field(..., alias="streamIn") |     stream_in: bool = Field(..., serialization_alias="streamIn") | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| class StreamOut(BaseModel): | class StreamOut(BaseModel): | ||||||
|     stream_out: bool = Field(..., alias="streamOut") |     stream_out: bool = Field(..., serialization_alias="streamOut") | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| InputFile = Union[LocalFile, MemoryFile, PreparedFile, Symlink] | InputFile = Union[LocalFile, MemoryFile, PreparedFile, Symlink] | ||||||
|  |  | ||||||
|  | @ -3,7 +3,14 @@ from enum import Enum | ||||||
| from pathlib import Path | from pathlib import Path | ||||||
| from typing import Any, Dict, List, Type | from typing import Any, Dict, List, Type | ||||||
| 
 | 
 | ||||||
| from pydantic import BaseModel, ConfigDict, Field, field_validator, model_validator | from pydantic import ( | ||||||
|  |     AliasChoices, | ||||||
|  |     BaseModel, | ||||||
|  |     ConfigDict, | ||||||
|  |     Field, | ||||||
|  |     field_validator, | ||||||
|  |     model_validator, | ||||||
|  | ) | ||||||
| 
 | 
 | ||||||
| from joj3_config_generator.models.common import Memory, Time | from joj3_config_generator.models.common import Memory, Time | ||||||
| from joj3_config_generator.models.const import ( | from joj3_config_generator.models.const import ( | ||||||
|  | @ -16,13 +23,19 @@ from joj3_config_generator.models.const import ( | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| class ParserResultDetail(BaseModel): | class ParserResultDetail(BaseModel): | ||||||
|     cpu_time: bool = Field(True, alias="cpu-time")  # Display CPU time |     cpu_time: bool = Field( | ||||||
|  |         True, validation_alias=AliasChoices("cpu-time", "cpu_time") | ||||||
|  |     )  # Display CPU time | ||||||
|     time: bool = True  # Display run time |     time: bool = True  # Display run time | ||||||
|     mem: bool = True  # Display memory usage |     mem: bool = True  # Display memory usage | ||||||
|     stdout: bool = False  # Display stdout messages |     stdout: bool = False  # Display stdout messages | ||||||
|     stderr: bool = False  # Display stderr messages |     stderr: bool = False  # Display stderr messages | ||||||
|     exit_status: bool = Field(True, alias="exit-status")  # Display exit status |     exit_status: bool = Field( | ||||||
|     proc_peak: bool = Field(False, alias="proc-peak")  # Display peak process count |         True, validation_alias=AliasChoices("exit-status", "exit_status") | ||||||
|  |     )  # Display exit status | ||||||
|  |     proc_peak: bool = Field( | ||||||
|  |         False, validation_alias=AliasChoices("proc-peak", "proc_peak") | ||||||
|  |     )  # Display peak process count | ||||||
|     error: bool = False  # Display error messages |     error: bool = False  # Display error messages | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  | @ -39,7 +52,9 @@ class ParserLog(BaseModel): | ||||||
| class ParserDummy(BaseModel): | class ParserDummy(BaseModel): | ||||||
|     comment: str = "" |     comment: str = "" | ||||||
|     score: int = 0 |     score: int = 0 | ||||||
|     force_quit: bool = Field(False, alias="force-quit") |     force_quit: bool = Field( | ||||||
|  |         False, validation_alias=AliasChoices("force-quit", "force_quit") | ||||||
|  |     ) | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| class ParserKeyword(BaseModel): | class ParserKeyword(BaseModel): | ||||||
|  | @ -49,21 +64,32 @@ class ParserKeyword(BaseModel): | ||||||
| 
 | 
 | ||||||
| class ParserDiffOutputs(BaseModel): | class ParserDiffOutputs(BaseModel): | ||||||
|     score: int = 0 |     score: int = 0 | ||||||
|     ignore_spaces: bool = Field(True, alias="ignore-spaces") |     ignore_spaces: bool = Field( | ||||||
|  |         True, validation_alias=AliasChoices("ignore-spaces", "ignore_spaces") | ||||||
|  |     ) | ||||||
|     hide: bool = False |     hide: bool = False | ||||||
|     force_quit: bool = Field(False, alias="force-quit") |     force_quit: bool = Field( | ||||||
|     max_length: int = Field(2048, alias="max-length") |         False, validation_alias=AliasChoices("force-quit", "force_quit") | ||||||
|     max_lines: int = Field(50, alias="max-lines") |     ) | ||||||
|     hide_common_prefix: bool = Field(False, alias="hide-common-prefix") |     max_length: int = Field( | ||||||
|  |         2048, validation_alias=AliasChoices("max-length", "max_length") | ||||||
|  |     ) | ||||||
|  |     max_lines: int = Field(50, validation_alias=AliasChoices("max-lines", "max_lines")) | ||||||
|  |     hide_common_prefix: bool = Field( | ||||||
|  |         False, validation_alias=AliasChoices("hide-common-prefix", "hide_common_prefix") | ||||||
|  |     ) | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| class ParserDiff(BaseModel): | class ParserDiff(BaseModel): | ||||||
|     output: ParserDiffOutputs = ParserDiffOutputs() |     output: ParserDiffOutputs = ParserDiffOutputs() | ||||||
|     default_score: int = Field(DEFAULT_CASE_SCORE, alias="default-score") |     default_score: int = Field( | ||||||
|  |         DEFAULT_CASE_SCORE, | ||||||
|  |         validation_alias=AliasChoices("default-score", "default_score"), | ||||||
|  |     ) | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| class StageFiles(BaseModel): | class StageFiles(BaseModel): | ||||||
|     import_: List[str] = Field([], alias="import") |     import_: List[str] = Field([], validation_alias="import") | ||||||
|     export: List[str] = [] |     export: List[str] = [] | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  | @ -109,21 +135,26 @@ class Stage(BaseModel): | ||||||
|     env: List[str] = [] |     env: List[str] = [] | ||||||
|     command: str = ""  # Command to run |     command: str = ""  # Command to run | ||||||
|     files: StageFiles = StageFiles() |     files: StageFiles = StageFiles() | ||||||
|     in_: str = Field("", alias="in") |     in_: str = Field("", validation_alias="in") | ||||||
|     out_: str = Field("", alias="out") |     out_: str = Field("", validation_alias="out") | ||||||
|     copy_in_cwd: bool = Field(True, alias="copy-in-cwd") |     copy_in_cwd: bool = Field( | ||||||
|  |         True, validation_alias=AliasChoices("copy-in-cwd", "copy_in_cwd") | ||||||
|  |     ) | ||||||
|     score: int = 0 |     score: int = 0 | ||||||
|     parsers: List[Parser] = []  # list of parsers |     parsers: List[Parser] = []  # list of parsers | ||||||
|     limit: Limit = Limit() |     limit: Limit = Limit() | ||||||
|     dummy: ParserDummy = ParserDummy() |     dummy: ParserDummy = ParserDummy() | ||||||
|     result_status: ParserDummy = Field(ParserDummy(), alias="result-status") |     result_status: ParserDummy = Field( | ||||||
|  |         ParserDummy(), validation_alias=AliasChoices("result-status", "result_status") | ||||||
|  |     ) | ||||||
|     keyword: ParserKeyword = ParserKeyword() |     keyword: ParserKeyword = ParserKeyword() | ||||||
|     clangtidy: ParserKeyword = ParserKeyword() |     clangtidy: ParserKeyword = ParserKeyword() | ||||||
|     cppcheck: ParserKeyword = ParserKeyword() |     cppcheck: ParserKeyword = ParserKeyword() | ||||||
|     cpplint: ParserKeyword = ParserKeyword() |     cpplint: ParserKeyword = ParserKeyword() | ||||||
|     elf: ParserKeyword = ParserKeyword() |     elf: ParserKeyword = ParserKeyword() | ||||||
|     result_detail: ParserResultDetail = Field( |     result_detail: ParserResultDetail = Field( | ||||||
|         ParserResultDetail(), alias="result-detail" |         ParserResultDetail(), | ||||||
|  |         validation_alias=AliasChoices("result-detail", "result_detail"), | ||||||
|     ) |     ) | ||||||
|     file: ParserFile = ParserFile() |     file: ParserFile = ParserFile() | ||||||
|     skip: List[str] = [] |     skip: List[str] = [] | ||||||
|  | @ -151,10 +182,12 @@ class Stage(BaseModel): | ||||||
| 
 | 
 | ||||||
| class Release(BaseModel): | class Release(BaseModel): | ||||||
|     end_time: datetime = Field( |     end_time: datetime = Field( | ||||||
|         datetime(1970, 1, 1, 0, 0, 0, tzinfo=timezone.utc), alias="end-time" |         datetime(1970, 1, 1, 0, 0, 0, tzinfo=timezone.utc), | ||||||
|  |         validation_alias=AliasChoices("end-time", "end_time"), | ||||||
|     )  # timestamp = 0, no end time |     )  # timestamp = 0, no end time | ||||||
|     begin_time: datetime = Field( |     begin_time: datetime = Field( | ||||||
|         datetime(1970, 1, 1, 0, 0, 0, tzinfo=timezone.utc), alias="begin-time" |         datetime(1970, 1, 1, 0, 0, 0, tzinfo=timezone.utc), | ||||||
|  |         validation_alias=AliasChoices("begin-time", "begin_time"), | ||||||
|     )  # timestamp = 0, no begin time |     )  # timestamp = 0, no begin time | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue
	
	Block a user