feat: add get_job_logs tool with tail

This commit is contained in:
Claude
2026-06-24 14:43:56 +08:00
parent e443f96756
commit 1cd3128522
2 changed files with 70 additions and 0 deletions
+23
View File
@@ -0,0 +1,23 @@
# coding=utf-8
"""
@Time :2026/6/24
@Author :tao.chen
"""
from common.logging import logger
from spark_executor.core.job_store import JobStore
from spark_executor.core.yarn_client import get_application_logs
store = JobStore()
def get_job_logs(job_id: str, tail_chars: int = 5000) -> str:
job = store.get(job_id)
if job is None:
raise KeyError(f"Unknown job_id: {job_id}")
full = get_application_logs(job.application_id)
tailed = full[-tail_chars:] if len(full) > tail_chars else full
logger.info(
f"get_job_logs job_id={job_id} application_id={job.application_id} "
f"chars={len(tailed)}"
)
return tailed