chore: 忽略离线部署包,提交安全加固、数据库初始化与文档
- .gitignore: 忽略 docker/offline 离线部署包(镜像/运行时等大文件) - 安全加固: 新增 compute/api/security.py 及各端安全测试,补充 docs/security-hardening.md - 数据库: 新增完整初始化 SQL 与 docs/database-config.md - 数据转换与评测: 修复类型检查、增强校验并补充测试 - Docker 配置与环境变量更新 Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
42
compute/tests/test_eval_runner.py
Normal file
42
compute/tests/test_eval_runner.py
Normal file
@@ -0,0 +1,42 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
|
||||
from compute.engines.llama_factory.eval_runner import _load_dataset
|
||||
|
||||
|
||||
def _write(tmp_path, name: str, text: str) -> str:
|
||||
path = tmp_path / name
|
||||
path.write_text(text, encoding="utf-8")
|
||||
return str(path)
|
||||
|
||||
|
||||
def test_load_jsonl_multiline(tmp_path) -> None:
|
||||
path = _write(
|
||||
tmp_path,
|
||||
"eval.jsonl",
|
||||
'{"question": "q1", "answer": "a1"}\n{"question": "q2", "answer": "a2"}\n',
|
||||
)
|
||||
assert _load_dataset(path) == [
|
||||
{"question": "q1", "answer": "a1"},
|
||||
{"question": "q2", "answer": "a2"},
|
||||
]
|
||||
|
||||
|
||||
def test_load_json_array(tmp_path) -> None:
|
||||
path = _write(
|
||||
tmp_path,
|
||||
"eval.json",
|
||||
json.dumps([{"question": "x", "answer": "y"}]),
|
||||
)
|
||||
assert _load_dataset(path) == [{"question": "x", "answer": "y"}]
|
||||
|
||||
|
||||
def test_load_jsonl_with_bom_and_embedded_array(tmp_path) -> None:
|
||||
"""jsonl 带 BOM 且单行内嵌 JSON 数组,都应正常加载。"""
|
||||
path = _write(
|
||||
tmp_path,
|
||||
"eval.jsonl",
|
||||
"" + json.dumps([{"question": "a", "answer": "b"}, {"question": "c", "answer": "d"}]),
|
||||
)
|
||||
assert len(_load_dataset(path)) == 2
|
||||
Reference in New Issue
Block a user