fix: unit of time
All checks were successful
build / build (push) Successful in 2m35s
build / build (pull_request) Successful in 2m33s

This commit is contained in:
李衍志523370910113 2025-03-02 11:47:31 +08:00
parent 94dc847a11
commit 45765e29e0
9 changed files with 77 additions and 79 deletions

View File

@ -2,7 +2,6 @@ from typing import Any, Dict, List, Optional, Union
import humanfriendly
from pydantic import BaseModel, Field
from pytimeparse.timeparse import timeparse
class LocalFile(BaseModel):
@ -44,9 +43,9 @@ class Cmd(BaseModel):
stdin: Optional[Union[InputFile | StreamIn]] = None
stdout: Optional[Union[Collector | StreamOut]] = None
stderr: Optional[Union[Collector | StreamOut]] = None
cpu_limit: int = Field(0, serialization_alias="cpuLimit")
real_cpu_limit: int = Field(0, serialization_alias="realCpuLimit")
clock_limit: int = Field(2 * timeparse("1s"), serialization_alias="clockLimit")
cpu_limit: int = Field(1_000_000_000, serialization_alias="cpuLimit")
real_cpu_limit: int = Field(1_000_000_000, serialization_alias="realCpuLimit")
clock_limit: int = Field(2 * 1_000_000_000, serialization_alias="clockLimit")
memory_limit: int = Field(
humanfriendly.parse_size("128m"), serialization_alias="memoryLimit"
)
@ -77,7 +76,7 @@ class OptionalCmd(BaseModel):
cpu_limit: Optional[int] = Field(None, serialization_alias="cpuLimit")
real_cpu_limit: Optional[int] = Field(None, serialization_alias="realCpuLimit")
clock_limit: Optional[int] = Field(
2 * timeparse("1s"), serialization_alias="clockLimit"
2 * 1_000_000_000, serialization_alias="clockLimit"
)
memory_limit: Optional[int] = Field(
humanfriendly.parse_size("128m"), serialization_alias="memoryLimit"

View File

@ -4,7 +4,6 @@ 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):
@ -54,7 +53,7 @@ class Files(BaseModel):
class Limit(BaseModel):
mem: int = humanfriendly.parse_size("128M")
cpu: int = timeparse("1s")
cpu: int = 1_000_000_000
stderr: int = humanfriendly.parse_size("128M")
stdout: int = humanfriendly.parse_size("128M")

View File

@ -77,37 +77,37 @@ def get_executor_with_config(
copy_in_cached={file: file for file in cached},
copy_out_cached=file_export if file_export is not None else [],
cpu_limit=(
task_stage.limit.cpu * 1_000_000_000_000
task_stage.limit.cpu * 1_000_000_000
if task_stage.limit is not None and task_stage.limit.cpu is not None
else 80 * 1_000_000_000_000
else 80 * 1_000_000_000
),
clock_limit=(
2 * task_stage.limit.cpu * 1_000_000_000_000
2 * task_stage.limit.cpu * 1_000_000_000
if task_stage.limit is not None and task_stage.limit.cpu is not None
else 80 * 1_000_000_000_000
else 80 * 1_000_000_000
),
memory_limit=(
task_stage.limit.mem * 1_024 * 1_024
if task_stage.limit is not None and task_stage.limit.mem is not None
else 800 * 1_024 * 1_024
else 128 * 1_024 * 1_024
),
stderr=result.Collector(
name="stderr",
max=(
task_stage.limit.stderr * 1_000_000_000_000
task_stage.limit.stderr * 1_000_000_000
if task_stage.limit is not None
and task_stage.limit.stderr is not None
else 800 * 1_024 * 1_024
else 128 * 1_024 * 1_024
),
pipe=True,
),
stdout=result.Collector(
name="stdout",
max=(
task_stage.limit.stdout * 1_000_000_000_000
task_stage.limit.stdout * 1_000_000_000
if task_stage.limit is not None
and task_stage.limit.stdout is not None
else 800 * 1_024 * 1_024
else 128 * 1_024 * 1_024
),
pipe=True,
),

View File

@ -18,9 +18,9 @@
"with": {
"default": {
"env": [],
"cpuLimit": 0,
"realCpuLimit": 0,
"clockLimit": 2,
"cpuLimit": 1000000000,
"realCpuLimit": 1000000000,
"clockLimit": 2000000000,
"memoryLimit": 128000000,
"stackLimit": 0,
"procLimit": 50,
@ -52,7 +52,7 @@
"-checkFileSumList=a5b63323a692d3d8b952442969649b4f823d58dae26429494f613df160710dfc,b1bbad25b830db0a77b15a033f9ca1b7ab44c1d2d05056412bd3e4421645f0bf,f6740081487ca34963a005209e2e9adfdf6f3561719af082d40fe80145e0cceb,bbeca1491c2f8364821a328a6677c0c5d59ccd60250abac3cec0887eeb9bde3e",
"-checkFileNameList=.gitignore,.gitattributes,.gitea/workflows/push.yaml,.gitea/workflows/release.yaml"
],
"clockLimit": 2,
"clockLimit": 2000000000,
"memoryLimit": 128000000,
"procLimit": 50,
"copyOut": [
@ -73,7 +73,7 @@
"env": [
"LOG_FILE_PATH=/home/tt/.cache/joint-teapot-debug.log"
],
"clockLimit": 2,
"clockLimit": 2000000000,
"memoryLimit": 128000000,
"procLimit": 50,
"copyOut": [
@ -115,17 +115,17 @@
},
"stdout": {
"name": "stdout",
"max": 128000000000000000000,
"max": 128000000000000000,
"pipe": true
},
"stderr": {
"name": "stderr",
"max": 128000000000000000000,
"max": 128000000000000000,
"pipe": true
},
"cpuLimit": 1000000000000,
"realCpuLimit": 0,
"clockLimit": 2000000000000,
"cpuLimit": 1000000000000000000,
"realCpuLimit": 1000000000,
"clockLimit": 2000000000000000000,
"memoryLimit": 134217728000000,
"stackLimit": 0,
"procLimit": 50,
@ -203,17 +203,17 @@
},
"stdout": {
"name": "stdout",
"max": 128000000000000000000,
"max": 128000000000000000,
"pipe": true
},
"stderr": {
"name": "stderr",
"max": 128000000000000000000,
"max": 128000000000000000,
"pipe": true
},
"cpuLimit": 1000000000000,
"realCpuLimit": 0,
"clockLimit": 2000000000000,
"cpuLimit": 1000000000000000000,
"realCpuLimit": 1000000000,
"clockLimit": 2000000000000000000,
"memoryLimit": 134217728000000,
"stackLimit": 0,
"procLimit": 50,
@ -304,17 +304,17 @@
},
"stdout": {
"name": "stdout",
"max": 65000000000000,
"max": 65000000000,
"pipe": true
},
"stderr": {
"name": "stderr",
"max": 128000000000000000000,
"max": 128000000000000000,
"pipe": true
},
"cpuLimit": 1000000000000,
"realCpuLimit": 0,
"clockLimit": 2000000000000,
"cpuLimit": 1000000000000000000,
"realCpuLimit": 1000000000,
"clockLimit": 2000000000000000000,
"memoryLimit": 134217728000000,
"stackLimit": 0,
"procLimit": 50,
@ -431,17 +431,17 @@
},
"stdout": {
"name": "stdout",
"max": 128000000000000000000,
"max": 128000000000000000,
"pipe": true
},
"stderr": {
"name": "stderr",
"max": 65000000000000,
"max": 65000000000,
"pipe": true
},
"cpuLimit": 1000000000000,
"realCpuLimit": 0,
"clockLimit": 2000000000000,
"cpuLimit": 1000000000000000000,
"realCpuLimit": 1000000000,
"clockLimit": 2000000000000000000,
"memoryLimit": 134217728000000,
"stackLimit": 0,
"procLimit": 50,
@ -530,17 +530,17 @@
},
"stdout": {
"name": "stdout",
"max": 65000000000000,
"max": 65000000000,
"pipe": true
},
"stderr": {
"name": "stderr",
"max": 128000000000000000000,
"max": 128000000000000000,
"pipe": true
},
"cpuLimit": 1000000000000,
"realCpuLimit": 0,
"clockLimit": 2000000000000,
"cpuLimit": 1000000000000000000,
"realCpuLimit": 1000000000,
"clockLimit": 2000000000000000000,
"memoryLimit": 134217728000000,
"stackLimit": 0,
"procLimit": 50,
@ -625,17 +625,17 @@
"env": [],
"stdout": {
"name": "stdout",
"max": 128000000000000000000,
"max": 128000000000000000,
"pipe": true
},
"stderr": {
"name": "stderr",
"max": 128000000000000000000,
"max": 128000000000000000,
"pipe": true
},
"cpuLimit": 1000000000000,
"realCpuLimit": 0,
"clockLimit": 2000000000000,
"cpuLimit": 1000000000000000000,
"realCpuLimit": 1000000000,
"clockLimit": 2000000000000000000,
"memoryLimit": 95656304705536,
"stackLimit": 0,
"procLimit": 50,
@ -762,9 +762,9 @@
"env": [
"LOG_FILE_PATH=/home/tt/.cache/joint-teapot-debug.log"
],
"cpuLimit": 0,
"realCpuLimit": 0,
"clockLimit": 2,
"cpuLimit": 1000000000,
"realCpuLimit": 1000000000,
"clockLimit": 2000000000,
"memoryLimit": 128000000,
"stackLimit": 0,
"procLimit": 50,

View File

@ -32,17 +32,17 @@
},
"stdout": {
"name": "stdout",
"max": 65000000000000,
"max": 65000000000,
"pipe": true
},
"stderr": {
"name": "stderr",
"max": 128000000000000000000,
"max": 128000000000000000,
"pipe": true
},
"cpuLimit": 1000000000000,
"realCpuLimit": 0,
"clockLimit": 2000000000000,
"cpuLimit": 1000000000000000000,
"realCpuLimit": 1000000000,
"clockLimit": 2000000000000000000,
"memoryLimit": 134217728000000,
"stackLimit": 0,
"procLimit": 50,

View File

@ -32,17 +32,17 @@
},
"stdout": {
"name": "stdout",
"max": 128000000000000000000,
"max": 128000000000000000,
"pipe": true
},
"stderr": {
"name": "stderr",
"max": 65000000000000,
"max": 65000000000,
"pipe": true
},
"cpuLimit": 1000000000000,
"realCpuLimit": 0,
"clockLimit": 2000000000000,
"cpuLimit": 1000000000000000000,
"realCpuLimit": 1000000000,
"clockLimit": 2000000000000000000,
"memoryLimit": 134217728000000,
"stackLimit": 0,
"procLimit": 50,

View File

@ -31,17 +31,17 @@
},
"stdout": {
"name": "stdout",
"max": 65000000000000,
"max": 65000000000,
"pipe": true
},
"stderr": {
"name": "stderr",
"max": 128000000000000000000,
"max": 128000000000000000,
"pipe": true
},
"cpuLimit": 1000000000000,
"realCpuLimit": 0,
"clockLimit": 2000000000000,
"cpuLimit": 1000000000000000000,
"realCpuLimit": 1000000000,
"clockLimit": 2000000000000000000,
"memoryLimit": 134217728000000,
"stackLimit": 0,
"procLimit": 50,

View File

@ -24,17 +24,17 @@
"env": [],
"stdout": {
"name": "stdout",
"max": 128000000000000000000,
"max": 128000000000000000,
"pipe": true
},
"stderr": {
"name": "stderr",
"max": 128000000000000000000,
"max": 128000000000000000,
"pipe": true
},
"cpuLimit": 1000000000000,
"realCpuLimit": 0,
"clockLimit": 2000000000000,
"cpuLimit": 1000000000000000000,
"realCpuLimit": 1000000000,
"clockLimit": 2000000000000000000,
"memoryLimit": 95656304705536,
"stackLimit": 0,
"procLimit": 50,

View File

@ -30,17 +30,17 @@
},
"stdout": {
"name": "stdout",
"max": 128000000000000000000,
"max": 128000000000000000,
"pipe": true
},
"stderr": {
"name": "stderr",
"max": 128000000000000000000,
"max": 128000000000000000,
"pipe": true
},
"cpuLimit": 1000000000000,
"realCpuLimit": 0,
"clockLimit": 2000000000000,
"cpuLimit": 1000000000000000000,
"realCpuLimit": 1000000000,
"clockLimit": 2000000000000000000,
"memoryLimit": 134217728000000,
"stackLimit": 0,
"procLimit": 50,