remove dead code
This commit is contained in:
@@ -41,5 +41,6 @@ VOICE_FILE_LOG_PATH: str = "logs/voice_{surgery_id}.txt"
|
||||
VOICE_UPLOAD_MAX_BYTES: int = 10 * 1024 * 1024
|
||||
VOICE_CONFIRM_MAX_FAILED_PARSE_ROUNDS: int = 2
|
||||
|
||||
# --- 非实时 batch 标注视频临时保留(小时)---
|
||||
# --- 非实时 batch 标注视频 / digest 级 pipeline 输入临时保留(小时)---
|
||||
VIDEO_BATCH_VIS_TTL_HOURS: int = 24
|
||||
VIDEO_BATCH_PIPELINE_INPUT_TTL_HOURS: int = 24
|
||||
|
||||
@@ -26,6 +26,7 @@ from app.baked import pipeline as bp
|
||||
from app.services.synthetic_rtsp import SyntheticRtspManager
|
||||
from app.services.video_batch_cleanup import (
|
||||
purge_batch_artifacts,
|
||||
purge_expired_pipeline_inputs,
|
||||
purge_expired_visualizations,
|
||||
purge_surgery_batch_tree,
|
||||
stage_visualization_pending,
|
||||
@@ -75,6 +76,10 @@ def _background_finalize_visualization(
|
||||
runner.root_dir,
|
||||
ttl_hours=float(bp.VIDEO_BATCH_VIS_TTL_HOURS),
|
||||
)
|
||||
purge_expired_pipeline_inputs(
|
||||
runner.root_dir,
|
||||
ttl_hours=float(bp.VIDEO_BATCH_PIPELINE_INPUT_TTL_HOURS),
|
||||
)
|
||||
|
||||
|
||||
class OfflineBatchResponse(BaseModel):
|
||||
|
||||
@@ -165,3 +165,36 @@ def purge_expired_visualizations(root_dir: Path, *, ttl_hours: float = 24.0) ->
|
||||
if removed:
|
||||
logger.info("video batch visualization TTL sweep removed {} file(s)", removed)
|
||||
return removed
|
||||
|
||||
|
||||
def purge_expired_pipeline_inputs(root_dir: Path, *, ttl_hours: float = 24.0) -> int:
|
||||
"""Delete ``cache/{digest}/input/pipeline*`` older than *ttl_hours*."""
|
||||
|
||||
cache_root = root_dir / "cache"
|
||||
if not cache_root.is_dir():
|
||||
return 0
|
||||
|
||||
cutoff = time.time() - float(ttl_hours) * 3600.0
|
||||
removed = 0
|
||||
for digest_dir in cache_root.iterdir():
|
||||
if not digest_dir.is_dir():
|
||||
continue
|
||||
input_dir = digest_dir / "input"
|
||||
if not input_dir.is_dir():
|
||||
continue
|
||||
for pipeline_file in input_dir.glob("pipeline*"):
|
||||
if not pipeline_file.is_file():
|
||||
continue
|
||||
try:
|
||||
if pipeline_file.stat().st_mtime >= cutoff:
|
||||
continue
|
||||
except OSError:
|
||||
continue
|
||||
pipeline_file.unlink(missing_ok=True)
|
||||
removed += 1
|
||||
logger.info("purged expired pipeline input {}", pipeline_file)
|
||||
_prune_empty_parents(input_dir, stop_at=cache_root)
|
||||
|
||||
if removed:
|
||||
logger.info("video batch pipeline input TTL sweep removed {} file(s)", removed)
|
||||
return removed
|
||||
|
||||
@@ -50,14 +50,22 @@ async def lifespan(app: FastAPI):
|
||||
"Database connection verified; ensure schema is applied with `alembic upgrade head` before serving traffic"
|
||||
)
|
||||
from app.baked import pipeline as bp
|
||||
from app.services.video_batch_cleanup import purge_expired_visualizations
|
||||
from app.services.video_batch_cleanup import (
|
||||
purge_expired_pipeline_inputs,
|
||||
purge_expired_visualizations,
|
||||
)
|
||||
from app.algo_host.batch_service import BatchAlgorithmService
|
||||
|
||||
repo_root = Path(__file__).resolve().parent
|
||||
batch_root = BatchAlgorithmService(root_dir=repo_root / "logs" / "video_batch").root_dir
|
||||
purge_expired_visualizations(
|
||||
BatchAlgorithmService(root_dir=repo_root / "logs" / "video_batch").root_dir,
|
||||
batch_root,
|
||||
ttl_hours=float(bp.VIDEO_BATCH_VIS_TTL_HOURS),
|
||||
)
|
||||
purge_expired_pipeline_inputs(
|
||||
batch_root,
|
||||
ttl_hours=float(bp.VIDEO_BATCH_PIPELINE_INPUT_TTL_HOURS),
|
||||
)
|
||||
container = build_container(settings)
|
||||
app.state.container = container
|
||||
await container.start()
|
||||
|
||||
Reference in New Issue
Block a user