fix(diff): bugs on diff stdin and numerics #16

Merged
张泊明518370910136 merged 22 commits from fix/diff into master 2025-05-24 02:45:39 +08:00
5 changed files with 20 additions and 8 deletions
Showing only changes of commit ca63a94238 - Show all commits

View File

@ -5,7 +5,6 @@ from joj3_config_generator.models.common import Memory, Time
DEFAULT_CPU_LIMIT = Time("1s")
DEFAULT_MEMORY_LIMIT = Memory("256m")
DEFAULT_FILE_LIMIT = Memory("32m")
DEFAULT_CASE_SCORE = 5
jon-lee marked this conversation as resolved Outdated

why is it removed?

why is it removed?

added a field in toml named diff.default_score and this 5 is now directly written numerically here:

class ParserDiff(BaseModel):
    output: Outputs = Outputs()
    default_score: int = 5

added back now.

added a field in toml named `diff.default_score` and this 5 is now directly written numerically here: ``` class ParserDiff(BaseModel): output: Outputs = Outputs() default_score: int = 5 ``` --- added back now.

why not

class ParserDiff(BaseModel):
    output: Outputs = Outputs()
    default_score: int = DEFAULT_CASE_SCORE
why not ``` class ParserDiff(BaseModel): output: Outputs = Outputs() default_score: int = DEFAULT_CASE_SCORE ```

yes, this is the case now, sorry :)

yes, this is the case now, sorry :)

do we need to also create a DEFAULT_PROC_LIMIT?

do we need to also create a `DEFAULT_PROC_LIMIT`?

good idea, maybe we can also have DEFAULT_CLOCK_LIMIT_MULTIPLIER

good idea, maybe we can also have `DEFAULT_CLOCK_LIMIT_MULTIPLIER`

both added now.

both added now.
JOJ3_CONFIG_ROOT = Path("/home/tt/.config/joj")
TEAPOT_CONFIG_ROOT = Path("/home/tt/.config/teapot")

View File

@ -51,6 +51,7 @@ class Outputs(BaseModel):
class ParserDiff(BaseModel):
output: Outputs = Outputs()
default_score: int = 5
class Files(BaseModel):

View File

@ -226,11 +226,21 @@ def fix_diff(
cmd = result.OptionalCmd(
stdin=result.LocalFile(src=str(base_dir / f"{case}.in"))
)
if cmd.args == executor.with_.default.args:
cmd.args = None
if cmd.cpu_limit == executor.with_.default.cpu_limit:
cmd.cpu_limit = None
if cmd.clock_limit == executor.with_.default.clock_limit:
cmd.clock_limit = None
if cmd.memory_limit == executor.with_.default.memory_limit:
cmd.memory_limit = None
if cmd.proc_limit == executor.with_.default.proc_limit:
cmd.proc_limit = None
stage_cases.append(cmd)
parser_case = result.DiffCasesConfig(
outputs=[
result.DiffOutputConfig(
score=const.DEFAULT_CASE_SCORE,
score=task_stage.diff.default_score,
file_name="stdout",
answer_path=str(base_dir / f"{case}.out"),
)

View File

@ -219,7 +219,7 @@
{
"outputs": [
{
"score": 5,
"score": 100,
"fileName": "stdout",
"answerPath": "/home/tt/.config/joj/diff/case2.out",
"forceQuitOnDiff": false,
@ -231,7 +231,7 @@
{
"outputs": [
{
"score": 5,
"score": 100,
"fileName": "stdout",
"answerPath": "/home/tt/.config/joj/diff/case3.out",
"forceQuitOnDiff": false,
@ -243,7 +243,7 @@
{
"outputs": [
{
"score": 5,
"score": 100,
"fileName": "stdout",
"answerPath": "/home/tt/.config/joj/diff/task1/case4.out",
"forceQuitOnDiff": false,
@ -255,7 +255,7 @@
{
"outputs": [
{
"score": 5,
"score": 100,
"fileName": "stdout",
"answerPath": "/home/tt/.config/joj/diff/task2/case6.out",
"forceQuitOnDiff": false,
@ -267,7 +267,7 @@
{
"outputs": [
{
"score": 5,
"score": 100,
"fileName": "stdout",
"answerPath": "/home/tt/.config/joj/diff/task2/case7.out",
"forceQuitOnDiff": false,
@ -279,7 +279,7 @@
{
"outputs": [
{
"score": 5,
"score": 100,
"fileName": "stdout",
"answerPath": "/home/tt/.config/joj/diff/task2/case8.out",
"forceQuitOnDiff": false,

View File

@ -14,6 +14,8 @@ parsers = [ "diff", "result-detail" ]
result-detail.exitstatus = true
result-detail.stderr = true
diff.default_score = 100
# will be removed as long as the name is fixed
case0.diff.output.score = 5
case0.limit.cpu = "1s"