Add cooperative task recovery and persistent live status
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 40s
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 1m37s
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 36s
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 42s
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 40s
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 1m37s
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 36s
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 42s
This commit is contained in:
1 parent
034fecbd51
commit
3bfd199b9c
28 files changed
+2356
-172
No files matched your search
@@ -30,6 +30,8 @@ class Run:
|
||||
log_path: str | None
|
||||
message: str | None
|
||||
input_json: str
|
||||
recovery_of_run_id: int | None = None
|
||||
resources_json: str = "[]"
|
||||
|
||||
|
||||
def now() -> str:
|
||||
@@ -72,6 +74,10 @@ class RunStore:
|
||||
connection.execute(
|
||||
"ALTER TABLE runs ADD COLUMN input_json TEXT NOT NULL DEFAULT '{}'"
|
||||
)
|
||||
if "recovery_of_run_id" not in columns:
|
||||
connection.execute("ALTER TABLE runs ADD COLUMN recovery_of_run_id INTEGER REFERENCES runs(id)")
|
||||
if "resources_json" not in columns:
|
||||
connection.execute("ALTER TABLE runs ADD COLUMN resources_json TEXT NOT NULL DEFAULT '[]'")
|
||||
connection.execute(
|
||||
"""
|
||||
CREATE INDEX IF NOT EXISTS runs_queue_index
|
||||
@@ -106,6 +112,8 @@ class RunStore:
|
||||
queue_group: str,
|
||||
trigger: str = "manual",
|
||||
input_data: Mapping[str, str | int | list[str]] | None = None,
|
||||
resources: tuple[str, ...] = (),
|
||||
recovery_of_run_id: int | None = None,
|
||||
) -> tuple[Run, bool]:
|
||||
input_json = json.dumps(input_data or {}, sort_keys=True, separators=(",", ":"))
|
||||
with self._connect() as connection:
|
||||
@@ -126,10 +134,12 @@ class RunStore:
|
||||
cursor = connection.execute(
|
||||
"""
|
||||
INSERT INTO runs (
|
||||
target_kind, target_path, queue_group, trigger, status, created_at, input_json
|
||||
) VALUES (?, ?, ?, ?, 'queued', ?, ?)
|
||||
target_kind, target_path, queue_group, trigger, status, created_at, input_json,
|
||||
resources_json, recovery_of_run_id
|
||||
) VALUES (?, ?, ?, ?, 'queued', ?, ?, ?, ?)
|
||||
""",
|
||||
(target_kind, target_path, queue_group, trigger, now(), input_json),
|
||||
(target_kind, target_path, queue_group, trigger, now(), input_json,
|
||||
json.dumps(resources), recovery_of_run_id),
|
||||
)
|
||||
return self.get(cursor.lastrowid, connection=connection), True
|
||||
|
||||
@@ -162,6 +172,10 @@ class RunStore:
|
||||
).fetchone()
|
||||
if row is None:
|
||||
return None
|
||||
requested = set(json.loads(row["resources_json"]))
|
||||
for active in connection.execute("SELECT resources_json FROM runs WHERE status='running' AND parent_run_id IS NULL"):
|
||||
if requested & set(json.loads(active["resources_json"])):
|
||||
return None
|
||||
run_id = row["id"]
|
||||
connection.execute(
|
||||
"UPDATE runs SET status = 'running', started_at = ? WHERE id = ?",
|
||||
@@ -263,6 +277,26 @@ class RunStore:
|
||||
for row in connection.execute("SELECT id, status, finished_at FROM runs")
|
||||
}
|
||||
|
||||
def active_runs(self) -> list[Run]:
|
||||
with self._connect() as connection:
|
||||
return [self._run(row) for row in connection.execute(
|
||||
"SELECT * FROM runs WHERE status IN ('queued','running') ORDER BY id"
|
||||
)]
|
||||
|
||||
def interrupted_without_recovery(self) -> list[Run]:
|
||||
with self._connect() as connection:
|
||||
return [self._run(row) for row in connection.execute(
|
||||
"""SELECT r.* FROM runs r WHERE r.status='interrupted' AND r.target_kind='task'
|
||||
AND r.cancel_requested_at IS NULL
|
||||
AND NOT EXISTS (SELECT 1 FROM runs child WHERE child.recovery_of_run_id=r.id)
|
||||
ORDER BY r.id"""
|
||||
)]
|
||||
|
||||
def recovery_for(self, run_id: int) -> Run | None:
|
||||
with self._connect() as connection:
|
||||
row = connection.execute("SELECT * FROM runs WHERE recovery_of_run_id=? ORDER BY id DESC LIMIT 1", (run_id,)).fetchone()
|
||||
return self._run(row) if row else None
|
||||
|
||||
def set_log_path(self, run_id: int, path: str) -> None:
|
||||
with self._connect() as connection:
|
||||
connection.execute("UPDATE runs SET log_path = ? WHERE id = ?", (path, run_id))
|
||||
|
||||
Reference in new issue
Block a user