valska_hera_beam.external_tools.bayeseor.sweep

Sweep orchestration for BayesEoR perturbation studies.

Functions

archive_jobs_json(run_dir)

Archive run_dir/jobs.json -> run_dir/jobs_<UTCSTAMP>.json

run_fwhm_sweep(*, template_yaml, install, ...)

Orchestrate a sweep over multiple perturbation values.

sweep_point_dir(results_root, beam_model, ...)

Per-point run directory for sweeps.

sweep_root(results_root, beam_model, ...)

Central sweep output location.

write_sweep_manifest(*, results_root, ...[, ...])

Write sweep_manifest.json under the sweep directory.

Classes

SweepPoint(perturb_parameter, perturb_frac, ...)

Metadata for a single sweep point.

SweepResult(results_root, beam_model, ...)

Summary of a completed sweep run (prepare + optional submit).

class valska_hera_beam.external_tools.bayeseor.sweep.SweepPoint(perturb_parameter: Literal['fwhm_deg', 'antenna_diameter'], perturb_frac: float, run_label: str, run_dir: Path, manifest_json: Path)

Metadata for a single sweep point.

property fwhm_perturb_frac: float | None

Backward-compatible alias for legacy FWHM-only callers.

manifest_json: Path
perturb_frac: float
perturb_parameter: Literal['fwhm_deg', 'antenna_diameter']
run_dir: Path
run_label: str
class valska_hera_beam.external_tools.bayeseor.sweep.SweepResult(results_root: Path, beam_model: str, sky_model: str, variant: str, run_id: str, perturb_parameter: Literal['fwhm_deg', 'antenna_diameter'], data_path: Path, created_utc: str, sweep_dir: Path, sweep_manifest_json: Path, template_yaml: Path, points: list[SweepPoint], submit_results: list[dict[str, Any]])

Summary of a completed sweep run (prepare + optional submit).

beam_model: str
created_utc: str
data_path: Path
perturb_parameter: Literal['fwhm_deg', 'antenna_diameter']
points: list[SweepPoint]
results_root: Path
run_id: str
sky_model: str
submit_results: list[dict[str, Any]]
sweep_dir: Path
sweep_manifest_json: Path
template_yaml: Path
variant: str
valska_hera_beam.external_tools.bayeseor.sweep._default_fwhm_fracs() list[float]
valska_hera_beam.external_tools.bayeseor.sweep._format_run_label(*, perturb_parameter: Literal['fwhm_deg', 'antenna_diameter'], frac: float) str
valska_hera_beam.external_tools.bayeseor.sweep._format_run_label_from_antenna_diameter_frac(frac: float) str

Must match cli_prepare.py formatting so directory layout is predictable.

valska_hera_beam.external_tools.bayeseor.sweep._format_run_label_from_fwhm_frac(frac: float) str

Must match cli_prepare.py formatting so directory layout is predictable.

valska_hera_beam.external_tools.bayeseor.sweep._jobs_path(run_dir: Path) Path
valska_hera_beam.external_tools.bayeseor.sweep._utc_now_compact() str
valska_hera_beam.external_tools.bayeseor.sweep._utc_now_iso() str
valska_hera_beam.external_tools.bayeseor.sweep.archive_jobs_json(run_dir: Path) Path | None

Archive run_dir/jobs.json -> run_dir/jobs_<UTCSTAMP>.json

Returns the archived path if an archive was created, else None.

valska_hera_beam.external_tools.bayeseor.sweep.run_fwhm_sweep(*, template_yaml: Path, install: BayesEoRInstall, runner: CondaRunner | ContainerRunner, results_root: Path, beam_model: str, sky_model: str, variant: str, run_id: str, data_path: Path, slurm_cpu: dict[str, object] | None = None, slurm_gpu: dict[str, object] | None = None, overrides: dict[str, str] | None = None, perturb_parameter: Literal['fwhm_deg', 'antenna_diameter'] = 'fwhm_deg', perturb_fracs: Iterable[float] | None = None, fwhm_fracs: Iterable[float] | None = None, unique: bool = False, submit: Literal['none', 'cpu', 'gpu', 'all'] = 'none', hypothesis: Literal['signal_fit', 'no_signal', 'both'] = 'both', depend_afterok: str | None = None, sbatch_exe: str = 'sbatch', submit_dry_run: bool = False, force: bool = False, resubmit: bool = False, record: Literal['jobs.json', 'manifest'] = 'jobs.json', dry_run: bool = False) SweepResult

Orchestrate a sweep over multiple perturbation values.

Parameters

template_yaml

BayesEoR template YAML to render.

install

BayesEoR installation metadata.

runner

Runner configuration (conda or container).

results_root

Root directory for results.

beam_model, sky_model, variant, run_id

Taxonomy fields and sweep identifier.

data_path

Input data path.

slurm_cpu, slurm_gpu

SLURM settings for CPU and GPU stages.

overrides

Template overrides applied to each run.

perturb_parameter

Which config key to perturb: fwhm_deg or antenna_diameter.

perturb_fracs

Iterable of perturbation fractions to apply to perturb_parameter.

fwhm_fracs

Backward-compatible alias for perturb_fracs when using perturb_parameter='fwhm_deg'.

unique

If True, append a UTC timestamp to each run directory.

submit

Stage(s) to submit after prepare (“none”, “cpu”, “gpu”, “all”).

hypothesis

Which GPU hypothesis to submit (“signal_fit”, “no_signal”, “both”).

depend_afterok

Optional sbatch job id to depend on for GPU submissions.

sbatch_exe

sbatch executable to invoke.

submit_dry_run

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

force

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

resubmit

If True, archive jobs.json before submitting.

record

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

dry_run

If True, do not prepare or submit; only compute intended run paths.

Returns

SweepResult

Summary of the sweep, including prepared points and submit results.

Sweep directory layout

For sweeps we intentionally colocate all points so they can be archived/removed as a unit:

<results_root>/bayeseor/<beam_model>/<sky_model>/_sweeps/<run_id>/<variant>/<run_label>/

Behaviour

  • Prepares one run_dir per perturbation frac (stable unless unique=True).

  • Optionally submits per run_dir via submit_bayeseor_run with stage cpu/gpu/all.

  • Writes/updates sweep_manifest.json under:

    <results_root>/bayeseor/<beam_model>/<sky_model>/_sweeps/<run_id>/

Resubmission behaviour

  • If resubmit=True and submit_dry_run=False, for each point we archive jobs.json (if present) to jobs_<timestamp>.json before submitting.

  • This enables “GPU-only resubmit across sweep” safely:

    submit=”gpu”, resubmit=True

valska_hera_beam.external_tools.bayeseor.sweep.sweep_point_dir(results_root: Path, beam_model: str, sky_model: str, run_id: str, *, variant: str, run_label: str) Path

Per-point run directory for sweeps.

Layout:

<results_root>/bayeseor/<beam_model>/<sky_model>/_sweeps/<run_id>/<variant>/<run_label>/

valska_hera_beam.external_tools.bayeseor.sweep.sweep_root(results_root: Path, beam_model: str, sky_model: str, run_id: str) Path

Central sweep output location.

Layout:

<results_root>/bayeseor/<beam_model>/<sky_model>/_sweeps/<run_id>/

valska_hera_beam.external_tools.bayeseor.sweep.write_sweep_manifest(*, results_root: Path, beam_model: str, sky_model: str, variant: str, run_id: str, perturb_parameter: Literal['fwhm_deg', 'antenna_diameter'], data_path: Path, template_yaml: Path, sweep_dir: Path, points: list[SweepPoint], submit_results: list[dict[str, Any]] | None = None) Path

Write sweep_manifest.json under the sweep directory.

Parameters

results_root, beam_model, sky_model, variant, run_id

Identify the sweep location and taxonomy.

data_path

Data path used for the sweep.

template_yaml

Template used for the sweep points.

sweep_dir

Target sweep directory.

points

Prepared sweep points.

submit_results

Optional submission results to include.

Returns

Path

Path to the written sweep_manifest.json.