- common/logging.py: improve format to timestamp|LEVEL|module:func:line - message - core/ layer: DEBUG log every subprocess invocation (cmd, rc, byte counts), JSON load/dump events, parsed application_id. ERROR log on failures. - tools/ layer: DEBUG log every public tool entry with key parameters, INFO log on business outcomes (saved/submitted/killed/...). - New tests/unit/test_logging.py: capture loguru output via in-memory sink and assert DEBUG + INFO messages are emitted for representative flows.
22 lines
724 B
Python
22 lines
724 B
Python
# 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_status
|
|
from spark_executor.models import JobStatus
|
|
|
|
store = JobStore()
|
|
|
|
|
|
def get_job_status(job_id: str) -> JobStatus:
|
|
logger.debug(f"get_job_status enter job_id={job_id}")
|
|
job = store.get(job_id)
|
|
if job is None:
|
|
raise KeyError(f"Unknown job_id: {job_id}")
|
|
state, raw = get_application_status(job.application_id)
|
|
logger.info(f"get_job_status ok job_id={job_id} application_id={job.application_id} state={state}")
|
|
return JobStatus(application_id=job.application_id, state=state, raw=raw)
|