registry
tit.jobs.registry ¶
On-disk job state: <project>/code/ti-toolbox/jobs/<id>/{spec.json,
status.json, events.jsonl, stdout.log}.
Persisted inside the project (not a temp dir) so notebook users and a restarted server both see
the same jobs. Writes that must never leave a half-written file behind (spec.json,
status.json) go through a temp-file + :func:os.replace.
JobRegistry ¶
JobRegistry(project_dir: str)
Filesystem operations for the job store of one project.
Source code in tit/jobs/registry.py
read_spec ¶
The job's spec.json, or None when it is missing, unreadable or malformed.
read_status ¶
The job's status.json, or None when it is missing, unreadable or malformed.
prune ¶
prune(*, keep_count: int = DEFAULT_RETENTION_COUNT, keep_days: float = DEFAULT_RETENTION_DAYS, now: float | None = None) -> list[str]
Drop old, terminal jobs beyond keep_count / keep_days. Returns removed ids.
Never removes a job that is not in a terminal state (queued/running survive regardless of age — a long-lived job should never disappear out from under it).
Source code in tit/jobs/registry.py
expired ¶
expired(finished: list[tuple[str, str, str | None]], *, keep_count: int = DEFAULT_RETENTION_COUNT, keep_days: float = DEFAULT_RETENTION_DAYS, now: float | None = None) -> list[str]
The retention rule for finished records: which of finished to drop.
finished is (id, created_at, finished_at) per finished record (ISO-8601 times). A record
finished more than keep_days ago goes, and so do the oldest beyond the newest keep_count.
Shared by the job registry (:meth:JobRegistry.prune) and the agent proposals
(:func:tit.server.proposals.prune), so both keep the same history.
Source code in tit/jobs/registry.py
ensure_bidsignore ¶
ensure_bidsignore(project_dir: str) -> None
Make sure project_dir's .bidsignore lists :data:BIDSIGNORE_LINE.
Idempotent: a no-op once the line is present. Creates .bidsignore if it doesn't exist
yet; otherwise appends to whatever is already there without touching existing lines (same
"users curate this file by hand" convention as :func:tit.pre.utils.ensure_bidsignore,
which does the same for CT files -- kept separate here rather than imported so
:mod:tit.jobs.registry never has to import :mod:tit.pre).
Source code in tit/jobs/registry.py
job_file_path ¶
A metadata file whose existing symlinks stay within the project.