fix: 缺省匹配年度收敛最新年度 + 批量坏文件跳过 + 匹配理由据实化 + 职称档位补全(P1+P2)
This commit is contained in:
@@ -478,7 +478,10 @@ def cmd_match(*, teacher: str = "", year: Optional[int] = None) -> int:
|
||||
print(f"ERROR:TEACHER_NOT_FOUND {message}")
|
||||
return 1
|
||||
if not tracks:
|
||||
message = "指南赛道库为空:请先录入赛道(add-track / import-tracks)"
|
||||
if year:
|
||||
message = f"指南赛道库中没有 {year} 年度赛道:请核对年度或先录入(add-track / import-tracks)"
|
||||
else:
|
||||
message = "指南赛道库为空:请先录入赛道(add-track / import-tracks)"
|
||||
log.warning("task_failed task_type=match error_code=TRACK_EMPTY stage=match")
|
||||
finish(status="failed", message=message, skill=SKILL_SLUG, error_code="TRACK_EMPTY", stage="match")
|
||||
print(f"ERROR:TRACK_EMPTY {message}")
|
||||
@@ -529,9 +532,13 @@ def cmd_match(*, teacher: str = "", year: Optional[int] = None) -> int:
|
||||
|
||||
|
||||
def cmd_match_batch_input() -> int:
|
||||
"""批量匹配(async Action 入口):匹配 input/ 目录中的教师画像 JSON 与库内赛道。"""
|
||||
"""批量匹配(async Action 入口):匹配 input/ 目录中的教师画像 JSON 与库内赛道。
|
||||
|
||||
坏文件(解析失败/非对象数组)跳过并告警,不中断整批;画像不完整教师同样跳过并记录(E1)。
|
||||
缺省匹配赛道库最新年度赛道。
|
||||
"""
|
||||
log = _get_task_logger()
|
||||
from service.match_service import load_tracks, run_match
|
||||
from service.match_service import collect_input_teachers, load_tracks, run_match
|
||||
from util.runtime_paths import get_input_dir
|
||||
|
||||
with job_context(skill=SKILL_SLUG):
|
||||
@@ -546,26 +553,17 @@ def cmd_match_batch_input() -> int:
|
||||
return 1
|
||||
|
||||
input_dir = get_input_dir()
|
||||
files = sorted(
|
||||
os.path.join(input_dir, name)
|
||||
for name in os.listdir(input_dir)
|
||||
if name.lower().endswith(".json")
|
||||
)
|
||||
if not files:
|
||||
message = f"input 目录没有教师画像 JSON:{input_dir}"
|
||||
teachers, skipped_files = collect_input_teachers(input_dir)
|
||||
for entry in skipped_files:
|
||||
log.warning("batch_input_file_skipped file=%s reason=%s stage=batch", entry["file"], entry["reason"])
|
||||
emit(f"{entry['file']}:{entry['reason']},该文件已跳过", type="warn", skill=SKILL_SLUG, stage="batch")
|
||||
if not teachers:
|
||||
message = f"input 目录没有可用的教师画像 JSON({len(skipped_files)} 个文件无法解析):{input_dir}"
|
||||
log.warning("task_failed task_type=match_batch error_code=TEACHER_NOT_FOUND stage=batch")
|
||||
finish(status="failed", message=message, skill=SKILL_SLUG, error_code="TEACHER_NOT_FOUND", stage="batch")
|
||||
print(f"ERROR:TEACHER_NOT_FOUND {message}")
|
||||
return 1
|
||||
|
||||
teachers = []
|
||||
for path in files:
|
||||
with open(path, encoding="utf-8") as f:
|
||||
payload = json.load(f)
|
||||
if isinstance(payload, dict):
|
||||
payload = payload.get("teachers") or [payload]
|
||||
teachers.extend(payload)
|
||||
|
||||
tracks = load_tracks()
|
||||
if not tracks:
|
||||
message = "指南赛道库为空:请先录入赛道(add-track / import-tracks)"
|
||||
@@ -597,6 +595,7 @@ def cmd_match_batch_input() -> int:
|
||||
"batch_no": result["batch_no"],
|
||||
"count": result["count"],
|
||||
"skipped": result.get("skipped") or [],
|
||||
"skipped_files": skipped_files,
|
||||
"tier_counts": result["tier_counts"],
|
||||
"brief_file": result["brief_file"],
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user