"""A job and a declared schedule, in a module a worker process can import. Not a test file — pytest does not collect it — and separate from the tests that use it for the same reason `isolated_handlers.py` is: the process under test is a *different* process, and it gets nothing from this one. It imports this by the name in `--bootstrap`, which fills `JOBS` and `SCHEDULES` exactly as an app's own jobs module does. Separate from `isolated_handlers.py` as well, because importing a module that calls `declare` fills a global: a test suite that imported this one would find its own schedule registry non-empty before it had declared anything. """ from __future__ import annotations from pathlib import Path from typing import Any from pipeline import NULL, RunContext, declare, job @job("sw_mark", "Leaving a mark") def sw_mark(config: Any, store: Any, *, context: RunContext = NULL) -> dict[str, Any]: """Touch a file in the store directory, so the parent process can see from outside whether this ran at all.""" (Path(store) / "fired").touch() return {"fired": True} #: The declaration itself is what one half of the worker test is about: a #: worker with no web app around it reconciles declared defaults like any #: other, so a machine running only `python -m pipeline.worker` still gets #: them. declare("marker", "sw_mark", "every 1h", label="Leaving a mark, hourly") def marking(marks: str) -> tuple[Any, Any]: """The bootstrap `pipeline.worker` is given: the marks directory is the store.""" return {}, marks