Prune old job executions
This commit is contained in:
parent
813f19f355
commit
710ac76192
6 changed files with 552 additions and 11 deletions
|
|
@ -50,6 +50,16 @@ class JobArtifacts:
|
|||
stats_path=log_dir / f"{prefix}.jsonl",
|
||||
)
|
||||
|
||||
def existing_paths(self) -> tuple[Path, ...]:
|
||||
prefix = self.log_path.with_suffix("").name
|
||||
return tuple(
|
||||
sorted(
|
||||
path
|
||||
for path in self.log_path.parent.glob(f"{prefix}.*")
|
||||
if path.is_file()
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
@dataclass
|
||||
class RunningWorker:
|
||||
|
|
@ -793,8 +803,12 @@ def clear_completed_executions(*, log_dir: str | Path) -> int:
|
|||
|
||||
for execution in completed_executions:
|
||||
job = cast(Job, execution.job)
|
||||
prefix = f"job-{_job_id(job)}-execution-{_execution_id(execution)}"
|
||||
for artifact_path in resolved_log_dir.glob(f"{prefix}.*"):
|
||||
artifacts = JobArtifacts.for_execution(
|
||||
log_dir=resolved_log_dir,
|
||||
job_id=_job_id(job),
|
||||
execution_id=_execution_id(execution),
|
||||
)
|
||||
for artifact_path in artifacts.existing_paths():
|
||||
artifact_path.unlink(missing_ok=True)
|
||||
|
||||
execution_ids = tuple(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue