Allow uploaded review files to be reused for execution
Build custom container images / build (map[base_image:php:8-fpm-alpine build_args:PHP_VERSION=8 context:php8-pgsql fingerprint_command:{ apk info -v | LC_ALL=C sort; find /usr/local/lib/php/extensions /usr/local/etc/php/conf.d -type f -exec sha256sum {} + | LC_ALL=C sort; } name:ph… (push) Successful in 38s
Build custom container images / build (map[base_image:postgres:18 build_args:PG_VERSION=18 POSTGIS_VERSION=3 VCHORD_VERSION=0.5.3 context:postgres fingerprint_command:{ dpkg-query -W -f='${binary:Package}=${Version}\n' | LC_ALL=C sort; find /usr/lib/postgresql -type f -exec sha256su… (push) Successful in 49s
Build custom container images / build (map[base_image:python:3 build_args:PYTHON_VERSION=3 context:python-tools fingerprint_command:{ dpkg-query -W -f='${binary:Package}=${Version}\n' | LC_ALL=C sort; pip freeze | LC_ALL=C sort; } name:python-tools oci_labels:org.opencontainers.ima… (push) Successful in 1m15s
Build custom container images / build (map[base_image:python:3.12-slim build_args:PYTHON_VERSION=3.12-slim context:linkki-tiedotus fingerprint_command:{ dpkg-query -W -f='${binary:Package}=${Version}\n' | LC_ALL=C sort; pip freeze | LC_ALL=C sort; } name:linkki-tiedotus oci_labels:… (push) Successful in 25s
Build custom container images / build (map[base_image:python:3.12-slim build_args:PYTHON_VERSION=3.12-slim context:timepoll fingerprint_command:{ dpkg-query -W -f='${binary:Package}=${Version}\n' | LC_ALL=C sort; pip freeze | LC_ALL=C sort; } name:timepoll oci_labels:org.opencontai… (push) Successful in 33s

This commit is contained in:
ajp_anton committed 2026-10-27 04:10:10 +00:00
1 parent 55bbbe2fd7
commit 034fecbd51
4 files changed
+213 -16

No files matched your search

+43 -2
View File
@@ -21,6 +21,7 @@ from .store import Run, RunStore
ORPHANED_TASK_STATE_FILENAME = ".orphaned-groups.json"
ORPHANED_TASK_STATE_RETENTION_SECONDS = 14 * 86400
REVIEW_UPLOAD_RETENTION_SECONDS = 86400
class RunManager:
@@ -117,6 +118,41 @@ class RunManager:
except OSError:
pass
def review_upload_paths(self, run: Run, task: Task) -> dict[str, Path] | None:
"""Return reusable uploads, or None when a run cannot be executed again."""
if run.status != "succeeded" or run.target_kind != "task" or task.execution is None:
return None
if any(field.sensitive for field in task.inputs):
return None
try:
values = json.loads(run.input_json)
except json.JSONDecodeError:
return None
if not isinstance(values, dict) or values.get(task.execution.field.name) != task.execution.dry_run_value:
return None
root = self._upload_root(run.id)
paths = {}
for field in task.inputs:
if field.type != "file":
continue
value = values.get(field.name)
if not value and not field.required:
continue
if not isinstance(value, str) or not run.finished_at:
return None
if time.time() - datetime.fromisoformat(run.finished_at).timestamp() >= REVIEW_UPLOAD_RETENTION_SECONDS:
return None
path = Path(value)
if root.is_symlink() or path.parent != root or path.is_symlink() or not path.is_file():
return None
if path.name != field.name + path.suffix or (field.accept and path.suffix.lower() not in field.accept):
return None
paths[field.name] = path
return paths
def discard_review_uploads(self, run_id: int) -> None:
self._delete_uploads(run_id)
def cleanup_transient_files(
self,
*,
@@ -144,7 +180,10 @@ class RunManager:
if kind in {"input.json", "execution-input.json"} and path.is_file():
path.unlink(missing_ok=True)
elif kind == "uploads" and path.is_dir():
shutil.rmtree(path, ignore_errors=True)
run = self.store.get(run_id)
task = self.catalog.task(run.target_path) if run and run.target_kind == "task" else None
if task is None or not self.review_upload_paths(run, task):
shutil.rmtree(path, ignore_errors=True)
elif kind == "artifacts" and path.is_dir():
if status in {"failed", "interrupted", "cancelled"}:
self._keep_diagnostic_reports(path)
@@ -370,13 +409,13 @@ class RunManager:
finally:
with self._lock:
self._processes.pop(run.id, None)
self._delete_uploads(run.id)
self._delete_execution_input(run.id)
(self.settings.state_root / "runs" / f"{run.id}.input.json").unlink(missing_ok=True)
if self.store.is_cancel_requested(run.id) or (
parent_run_id is not None and self.store.is_cancel_requested(parent_run_id)
):
self._delete_uploads(run.id)
self._keep_diagnostic_reports(artifact_root)
return self.store.finish(
run.id,
@@ -390,6 +429,8 @@ class RunManager:
exit_code=exit_code,
log_path=str(log_path),
)
if not self.review_upload_paths(completed, task):
self._delete_uploads(run.id)
if completed.status != "succeeded":
self._keep_diagnostic_reports(artifact_root)
else: