mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-17 17:36:08 +08:00
judge: configurable limits (#31)
This commit is contained in:
1 parent
55352ab27b
commit
de40219a88
7 files changed
+12
-11
No files matched your search
@@ -13,12 +13,12 @@ Found {0} testcases.: 총 {0}개의 TC 찾음
|
||||
Invalid judge_extra_files config.: judge_extra_files config 오류
|
||||
Invalid user_extra_files config.: user_extra_files config 오류
|
||||
Problem data not found.: 문제 데이터 없음
|
||||
Read {0}, expect {1}.: '{0}에서 다음을 예상함. {1}
|
||||
Read {0}, expect {1}.: '{0}에서 다음을 예상함. {1}'
|
||||
Standard answer longer than user output.: 출력이 짧습니다.
|
||||
Testdata configuration incorrect.: TC config 오류
|
||||
Too many files.: 파일이 너무 많습니다.
|
||||
Too many testcases. Cancelled.: TC가 너무 많습니다. 채점을 취소합니다.
|
||||
Total time limit longer than 60s. Cancelled.: 총 시간이 60초를 넘습니다. 채점을 취소합니다.
|
||||
Total time limit longer than {0}s. Cancelled.: 총 시간이 {9}초를 넘습니다. 채점을 취소합니다.
|
||||
Unknown checker type {0}.: Checker 형태 {0}을(를) 식별할 수 없습니다.
|
||||
Unknown language type.: 알려지지 않은 언어.
|
||||
Unsupported language {0}.: '{0}은(는) 지원되지 않습니다.'
|
||||
|
||||
@@ -18,7 +18,7 @@ Standard answer longer than user output.: 标准输出比选手输出长。
|
||||
Testdata configuration incorrect.: 题目配置错误。
|
||||
Too many files.: 文件过多。
|
||||
Too many testcases. Cancelled.: 测试数据过多。评测取消。
|
||||
Total time limit longer than 60s. Cancelled.: 总时限超过60s。评测取消。
|
||||
Total time limit longer than {0}s. Cancelled.: 总时限超过{0}s。评测取消。
|
||||
Unknown checker type {0}.: 未知的比较器类型 {0}。
|
||||
Unknown language type.: 未知的语言类型。
|
||||
Unsupported language {0}.: 不支持的语言 {0}。
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@hydrooj/hydrojudge",
|
||||
"bin": "bin/hydrojudge.js",
|
||||
"version": "2.1.26",
|
||||
"version": "2.1.27",
|
||||
"main": "package.json",
|
||||
"author": "masnn",
|
||||
"repository": "https://github.com/hydro-dev/Hydro.git",
|
||||
|
||||
@@ -2,6 +2,7 @@ import fs from 'fs-extra';
|
||||
import path from 'path';
|
||||
import yaml from 'js-yaml';
|
||||
import { Dictionary } from 'lodash';
|
||||
import { argv } from 'yargs';
|
||||
import { FormatError, SystemError } from './error';
|
||||
import { parseTimeMS, parseMemoryMB, ensureFile } from './utils';
|
||||
|
||||
@@ -284,12 +285,14 @@ function convertIniConfig(ini: string) {
|
||||
}
|
||||
|
||||
function isValidConfig(config) {
|
||||
if (config.count > 100) throw new FormatError('Too many testcases. Cancelled.');
|
||||
if (config.count > (argv.max_testcases_count as string || 100)) throw new FormatError('Too many testcases. Cancelled.');
|
||||
let total_time = 0;
|
||||
for (const subtask of config.subtasks) {
|
||||
total_time += subtask.time_limit_ms * subtask.cases.length;
|
||||
}
|
||||
if (total_time > 60 * 1000) throw new FormatError('Total time limit longer than 60s. Cancelled.');
|
||||
if (total_time > (+argv.max_time_limit || 60) * 1000) {
|
||||
throw new FormatError('Total time limit longer than {0}s. Cancelled.', [+argv.max_time_limit || 60]);
|
||||
}
|
||||
}
|
||||
|
||||
export default async function readCases(folder: string, cfg: Record<string, any> = {}, args) {
|
||||
|
||||
@@ -153,7 +153,7 @@ const checkers: Record<string, Checker> = {
|
||||
...config.copyIn,
|
||||
},
|
||||
});
|
||||
if (status !== STATUS.STATUS_ACCEPTED) throw new SystemError('Checker returned a non-zero value', [status]);
|
||||
if (status !== STATUS.STATUS_ACCEPTED) throw new SystemError('Checker returned {0}.', [status]);
|
||||
const score = parseInt(stdout, 10);
|
||||
status = score === config.score ? STATUS.STATUS_ACCEPTED : STATUS.STATUS_WRONG_ANSWER;
|
||||
return { status, score, message: stderr };
|
||||
|
||||
@@ -10,9 +10,6 @@ import log from './log';
|
||||
export let CONFIG_FILE = path.resolve(os.homedir(), '.config', 'hydro', 'judge.yaml');
|
||||
export let CACHE_DIR = path.resolve(os.homedir(), '.cache', 'hydro', 'judge');
|
||||
export let FILES_DIR = path.resolve(os.homedir(), '.cache', 'hydro', 'files', 'judge');
|
||||
export let SYSTEM_MEMORY_LIMIT_MB = 1024;
|
||||
export let SYSTEM_TIME_LIMIT_MS = 16000;
|
||||
export let SYSTEM_PROCESS_LIMIT = 32;
|
||||
export let RETRY_DELAY_SEC = 15;
|
||||
export let TEMP_DIR = path.resolve(os.tmpdir(), 'hydro', 'judge');
|
||||
export let EXECUTION_HOST = 'http://localhost:5050';
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
import Axios from 'axios';
|
||||
import fs from 'fs-extra';
|
||||
import { argv } from 'yargs';
|
||||
import * as STATUS from './status';
|
||||
import { SystemError } from './error';
|
||||
import { cmd } from './utils';
|
||||
|
||||
const env = ['PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', 'HOME=/w'];
|
||||
const axios = Axios.create({ baseURL: 'http://localhost:5050' });
|
||||
const axios = Axios.create({ baseURL: argv.sandbox as string || 'http://localhost:5050' });
|
||||
|
||||
const statusMap = {
|
||||
'Time Limit Exceeded': STATUS.STATUS_TIME_LIMIT_EXCEEDED,
|
||||
|
||||
Reference in new issue
Block a user