From 94dc847a116d02a72f96038b561329cf6fe6d420 Mon Sep 17 00:00:00 2001 From: jon-lee Date: Sun, 2 Mar 2025 11:24:26 +0800 Subject: [PATCH] fix: remove optional for task.Limit --- joj3_config_generator/models/task.py | 10 +++--- tests/convert/basic/task.json | 52 ++++++++++++++-------------- tests/convert/clang-tidy/task.json | 8 ++--- tests/convert/cppcheck/task.json | 8 ++--- tests/convert/cpplint/task.json | 8 ++--- tests/convert/diff/task.json | 8 ++--- tests/convert/keyword/task.json | 10 +++--- 7 files changed, 53 insertions(+), 51 deletions(-) diff --git a/joj3_config_generator/models/task.py b/joj3_config_generator/models/task.py index aab3d48..38a4861 100644 --- a/joj3_config_generator/models/task.py +++ b/joj3_config_generator/models/task.py @@ -2,7 +2,9 @@ from datetime import datetime from pathlib import Path from typing import Any, Dict, List, Optional, Type +import humanfriendly from pydantic import BaseModel, Field, model_validator +from pytimeparse.timeparse import timeparse class ParserResultDetail(BaseModel): @@ -51,10 +53,10 @@ class Files(BaseModel): class Limit(BaseModel): - mem: Optional[int] = 800 - cpu: Optional[int] = 1000 - stderr: Optional[int] = 800 - stdout: Optional[int] = 800 + mem: int = humanfriendly.parse_size("128M") + cpu: int = timeparse("1s") + stderr: int = humanfriendly.parse_size("128M") + stdout: int = humanfriendly.parse_size("128M") class Stage(BaseModel): diff --git a/tests/convert/basic/task.json b/tests/convert/basic/task.json index 1adfdeb..9384d49 100644 --- a/tests/convert/basic/task.json +++ b/tests/convert/basic/task.json @@ -115,18 +115,18 @@ }, "stdout": { "name": "stdout", - "max": 800000000000000, + "max": 128000000000000000000, "pipe": true }, "stderr": { "name": "stderr", - "max": 800000000000000, + "max": 128000000000000000000, "pipe": true }, - "cpuLimit": 1000000000000000, + "cpuLimit": 1000000000000, "realCpuLimit": 0, - "clockLimit": 2000000000000000, - "memoryLimit": 838860800, + "clockLimit": 2000000000000, + "memoryLimit": 134217728000000, "stackLimit": 0, "procLimit": 50, "cpuRateLimit": 0, @@ -203,18 +203,18 @@ }, "stdout": { "name": "stdout", - "max": 800000000000000, + "max": 128000000000000000000, "pipe": true }, "stderr": { "name": "stderr", - "max": 800000000000000, + "max": 128000000000000000000, "pipe": true }, - "cpuLimit": 1000000000000000, + "cpuLimit": 1000000000000, "realCpuLimit": 0, - "clockLimit": 2000000000000000, - "memoryLimit": 838860800, + "clockLimit": 2000000000000, + "memoryLimit": 134217728000000, "stackLimit": 0, "procLimit": 50, "cpuRateLimit": 0, @@ -309,13 +309,13 @@ }, "stderr": { "name": "stderr", - "max": 800000000000000, + "max": 128000000000000000000, "pipe": true }, - "cpuLimit": 1000000000000000, + "cpuLimit": 1000000000000, "realCpuLimit": 0, - "clockLimit": 2000000000000000, - "memoryLimit": 838860800, + "clockLimit": 2000000000000, + "memoryLimit": 134217728000000, "stackLimit": 0, "procLimit": 50, "cpuRateLimit": 0, @@ -431,7 +431,7 @@ }, "stdout": { "name": "stdout", - "max": 800000000000000, + "max": 128000000000000000000, "pipe": true }, "stderr": { @@ -439,10 +439,10 @@ "max": 65000000000000, "pipe": true }, - "cpuLimit": 1000000000000000, + "cpuLimit": 1000000000000, "realCpuLimit": 0, - "clockLimit": 2000000000000000, - "memoryLimit": 838860800, + "clockLimit": 2000000000000, + "memoryLimit": 134217728000000, "stackLimit": 0, "procLimit": 50, "cpuRateLimit": 0, @@ -535,13 +535,13 @@ }, "stderr": { "name": "stderr", - "max": 800000000000000, + "max": 128000000000000000000, "pipe": true }, - "cpuLimit": 1000000000000000, + "cpuLimit": 1000000000000, "realCpuLimit": 0, - "clockLimit": 2000000000000000, - "memoryLimit": 838860800, + "clockLimit": 2000000000000, + "memoryLimit": 134217728000000, "stackLimit": 0, "procLimit": 50, "cpuRateLimit": 0, @@ -625,17 +625,17 @@ "env": [], "stdout": { "name": "stdout", - "max": 800000000000000, + "max": 128000000000000000000, "pipe": true }, "stderr": { "name": "stderr", - "max": 800000000000000, + "max": 128000000000000000000, "pipe": true }, - "cpuLimit": 1000000000000000, + "cpuLimit": 1000000000000, "realCpuLimit": 0, - "clockLimit": 2000000000000000, + "clockLimit": 2000000000000, "memoryLimit": 95656304705536, "stackLimit": 0, "procLimit": 50, diff --git a/tests/convert/clang-tidy/task.json b/tests/convert/clang-tidy/task.json index 3604b27..b686a5e 100644 --- a/tests/convert/clang-tidy/task.json +++ b/tests/convert/clang-tidy/task.json @@ -37,13 +37,13 @@ }, "stderr": { "name": "stderr", - "max": 800000000000000, + "max": 128000000000000000000, "pipe": true }, - "cpuLimit": 1000000000000000, + "cpuLimit": 1000000000000, "realCpuLimit": 0, - "clockLimit": 2000000000000000, - "memoryLimit": 838860800, + "clockLimit": 2000000000000, + "memoryLimit": 134217728000000, "stackLimit": 0, "procLimit": 50, "cpuRateLimit": 0, diff --git a/tests/convert/cppcheck/task.json b/tests/convert/cppcheck/task.json index ad85b8d..6e78a28 100644 --- a/tests/convert/cppcheck/task.json +++ b/tests/convert/cppcheck/task.json @@ -32,7 +32,7 @@ }, "stdout": { "name": "stdout", - "max": 800000000000000, + "max": 128000000000000000000, "pipe": true }, "stderr": { @@ -40,10 +40,10 @@ "max": 65000000000000, "pipe": true }, - "cpuLimit": 1000000000000000, + "cpuLimit": 1000000000000, "realCpuLimit": 0, - "clockLimit": 2000000000000000, - "memoryLimit": 838860800, + "clockLimit": 2000000000000, + "memoryLimit": 134217728000000, "stackLimit": 0, "procLimit": 50, "cpuRateLimit": 0, diff --git a/tests/convert/cpplint/task.json b/tests/convert/cpplint/task.json index d1ac92c..9b78a1e 100644 --- a/tests/convert/cpplint/task.json +++ b/tests/convert/cpplint/task.json @@ -36,13 +36,13 @@ }, "stderr": { "name": "stderr", - "max": 800000000000000, + "max": 128000000000000000000, "pipe": true }, - "cpuLimit": 1000000000000000, + "cpuLimit": 1000000000000, "realCpuLimit": 0, - "clockLimit": 2000000000000000, - "memoryLimit": 838860800, + "clockLimit": 2000000000000, + "memoryLimit": 134217728000000, "stackLimit": 0, "procLimit": 50, "cpuRateLimit": 0, diff --git a/tests/convert/diff/task.json b/tests/convert/diff/task.json index 85169ec..1056a33 100644 --- a/tests/convert/diff/task.json +++ b/tests/convert/diff/task.json @@ -24,17 +24,17 @@ "env": [], "stdout": { "name": "stdout", - "max": 800000000000000, + "max": 128000000000000000000, "pipe": true }, "stderr": { "name": "stderr", - "max": 800000000000000, + "max": 128000000000000000000, "pipe": true }, - "cpuLimit": 1000000000000000, + "cpuLimit": 1000000000000, "realCpuLimit": 0, - "clockLimit": 2000000000000000, + "clockLimit": 2000000000000, "memoryLimit": 95656304705536, "stackLimit": 0, "procLimit": 50, diff --git a/tests/convert/keyword/task.json b/tests/convert/keyword/task.json index 3753220..c2bceb9 100644 --- a/tests/convert/keyword/task.json +++ b/tests/convert/keyword/task.json @@ -30,18 +30,18 @@ }, "stdout": { "name": "stdout", - "max": 800000000000000, + "max": 128000000000000000000, "pipe": true }, "stderr": { "name": "stderr", - "max": 800000000000000, + "max": 128000000000000000000, "pipe": true }, - "cpuLimit": 1000000000000000, + "cpuLimit": 1000000000000, "realCpuLimit": 0, - "clockLimit": 2000000000000000, - "memoryLimit": 838860800, + "clockLimit": 2000000000000, + "memoryLimit": 134217728000000, "stackLimit": 0, "procLimit": 50, "cpuRateLimit": 0,