Integrate task runner into python tools

This commit is contained in:
ajp_anton
2026-08-08 17:21:50 +00:00
parent f8fb1eed75
commit 56d6194324
22 changed files with 1137 additions and 7 deletions
View File
+44
View File
@@ -0,0 +1,44 @@
from __future__ import annotations
import sys
from pathlib import Path
import pytest
from app.config import Settings
from app.discovery import TaskCatalog
from app.runner import RunManager
from app.store import RunStore
@pytest.fixture
def settings(tmp_path: Path) -> Settings:
return Settings(
task_root=tmp_path / "tasks",
state_root=tmp_path / "state",
credentials_root=tmp_path / "credentials",
python_executable=sys.executable,
timezone_name="Etc/UTC",
allowed_proxy_ips=frozenset(),
cancel_grace_seconds=0.1,
)
@pytest.fixture
def manager(settings: Settings) -> RunManager:
settings.task_root.mkdir(parents=True)
store = RunStore(settings.database_path)
store.initialize()
return RunManager(settings, TaskCatalog(settings.task_root), store)
def write_task(
task_root: Path,
group: str,
filename: str,
source: str,
) -> Path:
path = task_root / group / filename
path.parent.mkdir(parents=True, exist_ok=True)
path.write_text(source, encoding="utf-8")
return path
+21
View File
@@ -0,0 +1,21 @@
from __future__ import annotations
from app.store import RunStore
def test_restart_marks_unfinished_runs_interrupted(settings) -> None:
store = RunStore(settings.database_path)
store.initialize()
run, created = store.enqueue(
target_kind="task",
target_path="checks/status.py",
queue_group="checks",
)
assert created is True
store.mark_interrupted()
interrupted = store.get(run.id)
assert interrupted is not None
assert interrupted.status == "interrupted"
assert interrupted.finished_at is not None