feat: set log path based on suffix

This commit is contained in:
张泊明518370910136 2025-06-25 22:05:59 -04:00
parent c428d51706
commit 10a5efb293
GPG Key ID: D47306D7062CDA9D
12 changed files with 26 additions and 14 deletions
joj3_config_generator
tests/convert
basic
clang-tidy
cppcheck
cpplint
diff
elf
keyword
result-detail
unnecessary

View File

@ -2,7 +2,11 @@ import os
from typing import Dict
from joj3_config_generator.models import answer, joj1, repo, result, task
from joj3_config_generator.models.const import ACTOR_CSV_PATH, JOJ3_LOG_PATH
from joj3_config_generator.models.const import (
ACTOR_CSV_PATH,
JOJ3_LOG_BASE_PATH,
JOJ3_LOG_FILENAME,
)
from joj3_config_generator.transformers.answer import get_task_conf_from_answers
from joj3_config_generator.transformers.joj1 import get_task_conf_from_joj1
from joj3_config_generator.transformers.repo import (
@ -25,7 +29,7 @@ def convert_joj3_conf(repo_conf: repo.Config, task_conf: task.Config) -> result.
result_conf = result.Config(
name=task_conf.task.name,
# exact folder difference specified by type
log_path=str(JOJ3_LOG_PATH),
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
expire_unix_timestamp=int(task_conf.release.end_time.timestamp()),
effective_unix_timestamp=int(task_conf.release.begin_time.timestamp()),

View File

@ -13,6 +13,7 @@ DEFAULT_PATH_ENV = "PATH=/usr/bin:/bin:/usr/local/bin"
JOJ3_CONFIG_ROOT = PurePosixPath("/home/tt/.config/joj")
TEAPOT_CONFIG_ROOT = PurePosixPath("/home/tt/.config/teapot")
CACHE_ROOT = PurePosixPath("/home/tt/.cache")
JOJ3_LOG_PATH = CACHE_ROOT / "joj3" / "joj3.log"
JOJ3_LOG_BASE_PATH = CACHE_ROOT / "joj3"
JOJ3_LOG_FILENAME = "joj3.log"
TEAPOT_LOG_PATH = CACHE_ROOT / "joint-teapot-debug.log"
ACTOR_CSV_PATH = JOJ3_CONFIG_ROOT / "students.csv"

View File

@ -270,9 +270,16 @@ class Config(BaseModel):
)
scoreboard: str = "scoreboard.csv"
suffix: str = Field("", exclude=True)
@model_validator(mode="after")
def set_suffix(self) -> "Config":
if not self.suffix:
self.suffix = re.split(r"[-_/\s]+", self.task.name)[0]
return self
@model_validator(mode="after")
def set_scoreboard(self) -> "Config":
if self.scoreboard == "auto":
suffix = re.split(r"[-_/\s]+", self.task.name)[0]
self.scoreboard = f"scoreboard-{suffix}.csv"
self.scoreboard = f"scoreboard-{self.suffix}.csv"
return self

View File

@ -1,6 +1,6 @@
{
"name": "hw7 ex2",
"logPath": "/home/tt/.cache/joj3/joj3.log",
"logPath": "/home/tt/.cache/joj3/hw7/joj3.log",
"expireUnixTimestamp": 0,
"effectiveUnixTimestamp": 0,
"actorCsvPath": "/home/tt/.config/joj/students.csv",

View File

@ -1,6 +1,6 @@
{
"name": "hw7 ex2",
"logPath": "/home/tt/.cache/joj3/joj3.log",
"logPath": "/home/tt/.cache/joj3/hw7/joj3.log",
"expireUnixTimestamp": 0,
"effectiveUnixTimestamp": 0,
"actorCsvPath": "/home/tt/.config/joj/students.csv",

View File

@ -1,6 +1,6 @@
{
"name": "hw7 ex2",
"logPath": "/home/tt/.cache/joj3/joj3.log",
"logPath": "/home/tt/.cache/joj3/hw7/joj3.log",
"expireUnixTimestamp": 0,
"effectiveUnixTimestamp": 0,
"actorCsvPath": "/home/tt/.config/joj/students.csv",

View File

@ -1,6 +1,6 @@
{
"name": "hw7 ex2",
"logPath": "/home/tt/.cache/joj3/joj3.log",
"logPath": "/home/tt/.cache/joj3/hw7/joj3.log",
"expireUnixTimestamp": 0,
"effectiveUnixTimestamp": 0,
"actorCsvPath": "/home/tt/.config/joj/students.csv",

View File

@ -1,6 +1,6 @@
{
"name": "hw7 ex2",
"logPath": "/home/tt/.cache/joj3/joj3.log",
"logPath": "/home/tt/.cache/joj3/hw7/joj3.log",
"expireUnixTimestamp": 0,
"effectiveUnixTimestamp": 0,
"actorCsvPath": "/home/tt/.config/joj/students.csv",

View File

@ -1,6 +1,6 @@
{
"name": "hw7 ex2",
"logPath": "/home/tt/.cache/joj3/joj3.log",
"logPath": "/home/tt/.cache/joj3/hw7/joj3.log",
"expireUnixTimestamp": 0,
"effectiveUnixTimestamp": 0,
"actorCsvPath": "/home/tt/.config/joj/students.csv",

View File

@ -1,6 +1,6 @@
{
"name": "hw7 ex2",
"logPath": "/home/tt/.cache/joj3/joj3.log",
"logPath": "/home/tt/.cache/joj3/hw7/joj3.log",
"expireUnixTimestamp": 0,
"effectiveUnixTimestamp": 0,
"actorCsvPath": "/home/tt/.config/joj/students.csv",

View File

@ -1,6 +1,6 @@
{
"name": "hw7 ex2",
"logPath": "/home/tt/.cache/joj3/joj3.log",
"logPath": "/home/tt/.cache/joj3/hw7/joj3.log",
"expireUnixTimestamp": 0,
"effectiveUnixTimestamp": 0,
"actorCsvPath": "/home/tt/.config/joj/students.csv",

View File

@ -1,6 +1,6 @@
{
"name": "hw7 ex2",
"logPath": "/home/tt/.cache/joj3/joj3.log",
"logPath": "/home/tt/.cache/joj3/hw7/joj3.log",
"expireUnixTimestamp": 0,
"effectiveUnixTimestamp": 0,
"actorCsvPath": "/home/tt/.config/joj/students.csv",