chore: move path to const
All checks were successful
build / build (pull_request) Successful in 2m35s
build / build (push) Successful in 2m38s

This commit is contained in:
张泊明518370910136 2025-03-02 15:01:31 -05:00
parent 4b3668d772
commit 6b5d941eb1
GPG Key ID: D47306D7062CDA9D
5 changed files with 24 additions and 26 deletions

View File

@ -2,6 +2,7 @@ import os
from typing import List
from joj3_config_generator.models import joj1, repo, result, task
from joj3_config_generator.models.const import CACHE_ROOT, JOJ3_CONFIG_ROOT
from joj3_config_generator.processers.repo import (
get_healthcheck_config,
get_teapot_stage,
@ -22,10 +23,10 @@ def convert(repo_conf: repo.Config, task_conf: task.Config) -> result.Config:
result_conf = result.Config(
name=task_conf.task.name,
# exact folder difference specified by type
log_path=f"/home/tt/.cache/joj3/{task_conf.task.type_}.log",
log_path=str(CACHE_ROOT / "joj3" / f"{task_conf.task.type_}.log"),
expire_unix_timestamp=int(task_conf.release.end_time.timestamp()),
effective_unix_timestamp=int(task_conf.release.begin_time.timestamp()),
actor_csv_path="/home/tt/.config/joj/students.csv", # students.csv position
actor_csv_path=str(JOJ3_CONFIG_ROOT / "students.csv"), # students.csv position
max_total_score=repo_conf.max_total_score,
stage=result.Stage(sandbox_token=repo_conf.sandbox_token),
)

View File

@ -10,6 +10,7 @@ from typing_extensions import Annotated
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.models import joj1, repo, task
from joj3_config_generator.models.const import JOJ3_CONFIG_ROOT
from joj3_config_generator.utils.logger import logger
app = typer.Typer(add_completion=False)
@ -50,8 +51,7 @@ def convert(
root: Annotated[
Path,
typer.Argument(
help="root directory of config files, "
"located at /home/tt/.config/joj in JTC"
help=f"root directory of config files, located at {JOJ3_CONFIG_ROOT} in JTC"
),
] = Path(".")
) -> None:

View File

@ -1,5 +1,11 @@
from pathlib import Path
from joj3_config_generator.models.common import Memory, Time
DEFAULT_CPU_LIMIT = Time("1s")
DEFAULT_MEMORY_LIMIT = Memory("128m")
DEFAULT_FILE_LIMIT = Memory("32m")
JOJ3_CONFIG_ROOT = Path("/home/tt/.config/joj")
TEAPOT_CONFIG_ROOT = Path("/home/tt/.config/teapot")
CACHE_ROOT = Path("/home/tt/.cache")

View File

@ -3,13 +3,14 @@ from pathlib import Path
from typing import List
from joj3_config_generator.models import repo, result
from joj3_config_generator.models.const import CACHE_ROOT, TEAPOT_CONFIG_ROOT
def get_teapot_stage(repo_conf: repo.Config) -> result.StageDetail:
args = [
"/usr/local/bin/joint-teapot",
"joj3-all-env",
"/home/tt/.config/teapot/teapot.env",
str(TEAPOT_CONFIG_ROOT / "teapot.env"),
"--grading-repo-name",
repo_conf.grading_repo_name,
"--max-total-score",
@ -23,7 +24,7 @@ def get_teapot_stage(repo_conf: repo.Config) -> result.StageDetail:
with_=result.ExecutorWith(
default=result.Cmd(
args=args,
env=["LOG_FILE_PATH=/home/tt/.cache/joint-teapot-debug.log"],
env=[f"LOG_FILE_PATH={CACHE_ROOT}/joint-teapot-debug.log"],
),
cases=[],
),
@ -58,7 +59,7 @@ def get_debug_args(repo_conf: repo.Config) -> List[str]:
return [
"/usr/local/bin/joint-teapot",
"joj3-check-env",
"/home/tt/.config/teapot/teapot.env",
str(TEAPOT_CONFIG_ROOT / "teapot.env"),
"--grading-repo-name",
repo_conf.grading_repo_name,
"--group-config",
@ -80,7 +81,7 @@ def get_healthcheck_config(repo_conf: repo.Config) -> result.StageDetail:
),
result.OptionalCmd(
args=get_debug_args(repo_conf),
env=["LOG_FILE_PATH=/home/tt/.cache/joint-teapot-debug.log"],
env=[f"LOG_FILE_PATH={CACHE_ROOT}/joint-teapot-debug.log"],
),
],
),

View File

@ -3,6 +3,7 @@ import shlex
from typing import List, Tuple
from joj3_config_generator.models import result, task
from joj3_config_generator.models.const import JOJ3_CONFIG_ROOT
def get_conf_stage(
@ -36,22 +37,9 @@ def get_conf_stage(
def get_executor_with_config(
task_stage: task.Stage, cached: List[str]
) -> Tuple[result.ExecutorWith, List[str]]:
file_import = (
task_stage.files.import_
if hasattr(task_stage, "files")
and hasattr(task_stage.files, "import_")
and (task_stage.files is not None)
and (task_stage.files.import_ is not None)
else []
)
file_import = task_stage.files.import_
copy_in_files = [file for file in file_import if file not in cached]
file_export = (
task_stage.files.export
if hasattr(task_stage, "files")
and hasattr(task_stage.files, "export")
and (task_stage.files is not None)
else []
)
file_export = task_stage.files.export
copy_out_files = ["stdout", "stderr"]
executor_with_config = result.ExecutorWith(
default=result.Cmd(
@ -61,7 +49,7 @@ def get_executor_with_config(
else []
),
copy_in={
file: result.LocalFile(src=f"/home/tt/.config/joj/{file}")
file: result.LocalFile(src=str(JOJ3_CONFIG_ROOT / file))
# all copyin files store in this tools folder
# are there any corner cases
for file in copy_in_files
@ -213,7 +201,7 @@ def fix_diff(
stage_cases.append(
result.OptionalCmd(
stdin=result.LocalFile(
src=f"/home/tt/.config/joj/{task_conf.task.type_}/{stdin}",
src=str(JOJ3_CONFIG_ROOT / task_conf.task.type_ / stdin),
),
args=(shlex.split(command) if command is not None else None),
cpu_limit=cpu_limit,
@ -236,7 +224,9 @@ def fix_diff(
result.DiffOutputConfig(
score=diff_output.score,
file_name="stdout",
answer_path=f"/home/tt/.config/joj/{task_conf.task.type_}/{stdout}",
answer_path=str(
JOJ3_CONFIG_ROOT / task_conf.task.type_ / stdout
),
force_quit_on_diff=diff_output.forcequit,
always_hide=diff_output.hide,
compare_space=not diff_output.ignorespaces,