feat: set log path based on suffix
This commit is contained in:
parent
c428d51706
commit
10a5efb293
|
@ -2,7 +2,11 @@ import os
|
||||||
from typing import Dict
|
from typing import Dict
|
||||||
|
|
||||||
from joj3_config_generator.models import answer, joj1, repo, result, task
|
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.answer import get_task_conf_from_answers
|
||||||
from joj3_config_generator.transformers.joj1 import get_task_conf_from_joj1
|
from joj3_config_generator.transformers.joj1 import get_task_conf_from_joj1
|
||||||
from joj3_config_generator.transformers.repo import (
|
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(
|
result_conf = result.Config(
|
||||||
name=task_conf.task.name,
|
name=task_conf.task.name,
|
||||||
# exact folder difference specified by type
|
# 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
|
# TODO: remove these 2 fields, will be handled in the health check stage
|
||||||
expire_unix_timestamp=int(task_conf.release.end_time.timestamp()),
|
expire_unix_timestamp=int(task_conf.release.end_time.timestamp()),
|
||||||
effective_unix_timestamp=int(task_conf.release.begin_time.timestamp()),
|
effective_unix_timestamp=int(task_conf.release.begin_time.timestamp()),
|
||||||
|
|
|
@ -13,6 +13,7 @@ DEFAULT_PATH_ENV = "PATH=/usr/bin:/bin:/usr/local/bin"
|
||||||
JOJ3_CONFIG_ROOT = PurePosixPath("/home/tt/.config/joj")
|
JOJ3_CONFIG_ROOT = PurePosixPath("/home/tt/.config/joj")
|
||||||
TEAPOT_CONFIG_ROOT = PurePosixPath("/home/tt/.config/teapot")
|
TEAPOT_CONFIG_ROOT = PurePosixPath("/home/tt/.config/teapot")
|
||||||
CACHE_ROOT = PurePosixPath("/home/tt/.cache")
|
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"
|
TEAPOT_LOG_PATH = CACHE_ROOT / "joint-teapot-debug.log"
|
||||||
ACTOR_CSV_PATH = JOJ3_CONFIG_ROOT / "students.csv"
|
ACTOR_CSV_PATH = JOJ3_CONFIG_ROOT / "students.csv"
|
||||||
|
|
|
@ -270,9 +270,16 @@ class Config(BaseModel):
|
||||||
)
|
)
|
||||||
scoreboard: str = "scoreboard.csv"
|
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")
|
@model_validator(mode="after")
|
||||||
def set_scoreboard(self) -> "Config":
|
def set_scoreboard(self) -> "Config":
|
||||||
if self.scoreboard == "auto":
|
if self.scoreboard == "auto":
|
||||||
suffix = re.split(r"[-_/\s]+", self.task.name)[0]
|
self.scoreboard = f"scoreboard-{self.suffix}.csv"
|
||||||
self.scoreboard = f"scoreboard-{suffix}.csv"
|
|
||||||
return self
|
return self
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "hw7 ex2",
|
"name": "hw7 ex2",
|
||||||
"logPath": "/home/tt/.cache/joj3/joj3.log",
|
"logPath": "/home/tt/.cache/joj3/hw7/joj3.log",
|
||||||
"expireUnixTimestamp": 0,
|
"expireUnixTimestamp": 0,
|
||||||
"effectiveUnixTimestamp": 0,
|
"effectiveUnixTimestamp": 0,
|
||||||
"actorCsvPath": "/home/tt/.config/joj/students.csv",
|
"actorCsvPath": "/home/tt/.config/joj/students.csv",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "hw7 ex2",
|
"name": "hw7 ex2",
|
||||||
"logPath": "/home/tt/.cache/joj3/joj3.log",
|
"logPath": "/home/tt/.cache/joj3/hw7/joj3.log",
|
||||||
"expireUnixTimestamp": 0,
|
"expireUnixTimestamp": 0,
|
||||||
"effectiveUnixTimestamp": 0,
|
"effectiveUnixTimestamp": 0,
|
||||||
"actorCsvPath": "/home/tt/.config/joj/students.csv",
|
"actorCsvPath": "/home/tt/.config/joj/students.csv",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "hw7 ex2",
|
"name": "hw7 ex2",
|
||||||
"logPath": "/home/tt/.cache/joj3/joj3.log",
|
"logPath": "/home/tt/.cache/joj3/hw7/joj3.log",
|
||||||
"expireUnixTimestamp": 0,
|
"expireUnixTimestamp": 0,
|
||||||
"effectiveUnixTimestamp": 0,
|
"effectiveUnixTimestamp": 0,
|
||||||
"actorCsvPath": "/home/tt/.config/joj/students.csv",
|
"actorCsvPath": "/home/tt/.config/joj/students.csv",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "hw7 ex2",
|
"name": "hw7 ex2",
|
||||||
"logPath": "/home/tt/.cache/joj3/joj3.log",
|
"logPath": "/home/tt/.cache/joj3/hw7/joj3.log",
|
||||||
"expireUnixTimestamp": 0,
|
"expireUnixTimestamp": 0,
|
||||||
"effectiveUnixTimestamp": 0,
|
"effectiveUnixTimestamp": 0,
|
||||||
"actorCsvPath": "/home/tt/.config/joj/students.csv",
|
"actorCsvPath": "/home/tt/.config/joj/students.csv",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "hw7 ex2",
|
"name": "hw7 ex2",
|
||||||
"logPath": "/home/tt/.cache/joj3/joj3.log",
|
"logPath": "/home/tt/.cache/joj3/hw7/joj3.log",
|
||||||
"expireUnixTimestamp": 0,
|
"expireUnixTimestamp": 0,
|
||||||
"effectiveUnixTimestamp": 0,
|
"effectiveUnixTimestamp": 0,
|
||||||
"actorCsvPath": "/home/tt/.config/joj/students.csv",
|
"actorCsvPath": "/home/tt/.config/joj/students.csv",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "hw7 ex2",
|
"name": "hw7 ex2",
|
||||||
"logPath": "/home/tt/.cache/joj3/joj3.log",
|
"logPath": "/home/tt/.cache/joj3/hw7/joj3.log",
|
||||||
"expireUnixTimestamp": 0,
|
"expireUnixTimestamp": 0,
|
||||||
"effectiveUnixTimestamp": 0,
|
"effectiveUnixTimestamp": 0,
|
||||||
"actorCsvPath": "/home/tt/.config/joj/students.csv",
|
"actorCsvPath": "/home/tt/.config/joj/students.csv",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "hw7 ex2",
|
"name": "hw7 ex2",
|
||||||
"logPath": "/home/tt/.cache/joj3/joj3.log",
|
"logPath": "/home/tt/.cache/joj3/hw7/joj3.log",
|
||||||
"expireUnixTimestamp": 0,
|
"expireUnixTimestamp": 0,
|
||||||
"effectiveUnixTimestamp": 0,
|
"effectiveUnixTimestamp": 0,
|
||||||
"actorCsvPath": "/home/tt/.config/joj/students.csv",
|
"actorCsvPath": "/home/tt/.config/joj/students.csv",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "hw7 ex2",
|
"name": "hw7 ex2",
|
||||||
"logPath": "/home/tt/.cache/joj3/joj3.log",
|
"logPath": "/home/tt/.cache/joj3/hw7/joj3.log",
|
||||||
"expireUnixTimestamp": 0,
|
"expireUnixTimestamp": 0,
|
||||||
"effectiveUnixTimestamp": 0,
|
"effectiveUnixTimestamp": 0,
|
||||||
"actorCsvPath": "/home/tt/.config/joj/students.csv",
|
"actorCsvPath": "/home/tt/.config/joj/students.csv",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "hw7 ex2",
|
"name": "hw7 ex2",
|
||||||
"logPath": "/home/tt/.cache/joj3/joj3.log",
|
"logPath": "/home/tt/.cache/joj3/hw7/joj3.log",
|
||||||
"expireUnixTimestamp": 0,
|
"expireUnixTimestamp": 0,
|
||||||
"effectiveUnixTimestamp": 0,
|
"effectiveUnixTimestamp": 0,
|
||||||
"actorCsvPath": "/home/tt/.config/joj/students.csv",
|
"actorCsvPath": "/home/tt/.config/joj/students.csv",
|
||||||
|
|
Loading…
Reference in New Issue
Block a user