valska.external_tools.bayeseor.submit

Submission helpers for BayesEoR prepared run directories.

Functions

build_submit_plan(run_dir)

Create a submission plan from an existing prepared run_dir.

load_jobs(run_dir)

load_manifest(run_dir)

Load and parse manifest.json from a prepared run directory.

submit_bayeseor_run(run_dir, *[, stage, ...])

Submit BayesEoR prepared scripts for a run_dir.

write_jobs(run_dir, jobs)

Classes

SubmitPlan(run_dir, manifest_path, ...)

Resolved paths needed to submit a prepared BayesEoR run.

Exceptions

InvalidArgumentError

Raised when CLI arguments are invalid for submission.

MissingDependencyError

Raised when required inputs or artefacts are missing.

SbatchError

Raised when sbatch fails or returns unparseable output.

SubmissionError

Raised when submission cannot proceed safely or sbatch fails.

exception valska.external_tools.bayeseor.submit.InvalidArgumentError

Raised when CLI arguments are invalid for submission.

exception valska.external_tools.bayeseor.submit.MissingDependencyError

Raised when required inputs or artefacts are missing.

exception valska.external_tools.bayeseor.submit.SbatchError

Raised when sbatch fails or returns unparseable output.

exception valska.external_tools.bayeseor.submit.SubmissionError

Raised when submission cannot proceed safely or sbatch fails.

class valska.external_tools.bayeseor.submit.SubmitPlan(run_dir: Path, manifest_path: Path, cpu_script: Path, gpu_signal_fit_script: Path | None, gpu_no_signal_script: Path | None, cpu_precompute_driver_hypothesis: str | None)

Resolved paths needed to submit a prepared BayesEoR run.

cpu_precompute_driver_hypothesis: str | None
cpu_script: Path
gpu_no_signal_script: Path | None
gpu_signal_fit_script: Path | None
manifest_path: Path
run_dir: Path
valska.external_tools.bayeseor.submit._ensure_script_exists(path: Path, label: str) None
valska.external_tools.bayeseor.submit._extract_cpu_jobid_from_existing(existing: dict[str, Any] | None) str | None

Try to locate a CPU job id from an existing jobs.json structure.

valska.external_tools.bayeseor.submit._find_completed_cpu_precompute_matrix_dir(run_dir: Path) Path | None

Return a matrix-stack directory when CPU precompute outputs appear complete.

BayesEoR GPU runs require the CPU-built matrix stack, most importantly the Ninv and T_Ninv_T artefacts. For the standard ValSKA-generated configs these are written beneath run_dir/matrices/....

We treat CPU precompute as reusable only when both markers are present in the same matrix directory.

valska.external_tools.bayeseor.submit._jobs_path(run_dir: Path) Path
valska.external_tools.bayeseor.submit._merge_jobs_record(existing: dict[str, Any] | None, new_result: dict[str, Any]) dict[str, Any]

Merge a new submission result into an existing jobs.json record.

  • Keeps stable top-level metadata (run_dir, manifest)

  • Updates “jobs” by stage (cpu_precompute, gpu)

  • Appends to “history” so we don’t lose what happened

valska.external_tools.bayeseor.submit._run_sbatch(script: Path, *, dependency_afterok: str | None = None, sbatch_exe: str = 'sbatch', cwd: Path | None = None, dry_run: bool = False) tuple[str | None, str]

Returns (job_id, command_str). If dry_run=True, job_id is None.

valska.external_tools.bayeseor.submit._safe_int_jobid(x: Any) str | None
valska.external_tools.bayeseor.submit._utc_now_iso() str
valska.external_tools.bayeseor.submit.build_submit_plan(run_dir: Path) SubmitPlan

Create a submission plan from an existing prepared run_dir.

This reads manifest.json and uses manifest[‘artefacts’] paths rather than guessing filenames.

valska.external_tools.bayeseor.submit.load_jobs(run_dir: Path) dict[str, Any] | None
valska.external_tools.bayeseor.submit.load_manifest(run_dir: Path) dict[str, Any]

Load and parse manifest.json from a prepared run directory.

Parameters

run_dir

Prepared run directory containing manifest.json.

Returns

dict

Parsed manifest content.

valska.external_tools.bayeseor.submit.submit_bayeseor_run(run_dir: Path, *, stage: Literal['cpu', 'gpu', 'all'] = 'all', hypothesis: Literal['signal_fit', 'no_signal', 'both'] = 'both', depend_afterok: str | None = None, sbatch_exe: str = 'sbatch', dry_run: bool = False, force: bool = False, record: Literal['jobs.json', 'manifest'] = 'jobs.json') dict[str, Any]

Submit BayesEoR prepared scripts for a run_dir.

Parameters

run_dir

Prepared run directory.

stage

Which stage(s) to submit: “cpu”, “gpu”, or “all”.

hypothesis

Which GPU hypothesis to run: “signal_fit”, “no_signal”, or “both”.

depend_afterok

Optional sbatch job id to depend on for GPU submissions.

sbatch_exe

sbatch executable to invoke.

dry_run

If True, do not submit jobs; return the commands that would run.

force

If True, allow resubmission even if jobs.json indicates prior submissions.

record

Where to record submission metadata. Currently only “jobs.json” is supported.

Returns

dict

A jobs.json-style record of the submission (merged if not dry_run).

Notes on jobs.json recording

jobs.json is treated as a durable record that may be updated across invocations:
  • stage=cpu creates/updates jobs.cpu_precompute

  • stage=gpu appends/updates jobs.gpu

  • stage=all updates both

We also keep a submission ‘history’ list so previous job ids are not lost.

valska.external_tools.bayeseor.submit.write_jobs(run_dir: Path, jobs: dict[str, Any]) Path