valska.external_tools.pyuvsim

pyuvsim integration helpers.

Primary entry points: - prepare_pyuvsim_run: render a pyuvsim config + SLURM submit script into a ValSKA results dir. - submit_pyuvsim_run: submit a prepared pyuvsim run directory to SLURM. - get_template_path: access shipped validation templates.

class valska.external_tools.pyuvsim.CondaRunner(conda_activate: str | None, env_name: str | None)

Run pyuvsim via a named conda environment.

If conda_activate/env_name are both None, no activation lines are emitted.

bash_prefix() str

Return shell lines to activate the conda environment.

conda_activate: str | None
env_name: str | None
class valska.external_tools.pyuvsim.ContainerRunner(apptainer_exe: str, image_path: Path, bind_paths: tuple[Path, ...] = ())

Future: Run pyuvsim inside a container (Apptainer/Singularity).

This is included now so we don’t need to redesign the API later. The only thing that should change is how we construct the command line; config rendering and output directory conventions stay identical.

Example future command:

apptainer exec –bind <binds> <image.sif> python -m pyuvsim.uvsim <obsparam.yaml>

apptainer_exe: str
bind_paths: tuple[Path, ...] = ()
image_path: Path
exception valska.external_tools.pyuvsim.SubmissionError

Raised when submission cannot proceed safely or sbatch fails.

valska.external_tools.pyuvsim.get_template_path(name: str) Path

Return a filesystem Path to a shipped template.

Uses importlib.resources so this works both from a source checkout and from an installed wheel.

valska.external_tools.pyuvsim.list_templates() list[str]

List shipped pyuvsim validation templates bundled with the package.

valska.external_tools.pyuvsim.prepare_pyuvsim_run(*, template_yaml: Path, install: pyuvsimInstall | None, runner: CondaRunner | ContainerRunner, results_root: Path, beam_model: str, sky_model: str, run_label: str, beamdata_path: Path | None = None, valska_root: Path | None = None, overrides: Mapping[str, Any] | None = None, slurm: Mapping[str, object] | None = None, slurm_cpu: Mapping[str, object] | None = None, run_dir: Path | None = None, run_id: str = 'default', variant: str | None = None, unique: bool = False, fwhm_perturb_frac: float | None = None) dict[str, Path]

Prepare a pyuvsim run directory containing a single simulation-stage artefact set.

Canonical non-sweep layout (when run_dir is None):

<results_root>/pyuvsim/<beam_model>/<sky_model>/<variant>/<run_label>/<run_id>[/<UTCSTAMP>]

Variant defaults to a name derived from the template filename stem (first occurrence of ‘_template’ removed).

Returns

dict

Paths to created artefacts (obsparam yaml, submit script, manifest), plus run_dir.

class valska.external_tools.pyuvsim.pyuvsimInstall(install_path: 'Path | None' = None)
install_path: Path | None = None
valska.external_tools.pyuvsim.submit_pyuvsim_run(run_dir: Path, *, stage: Literal['simulate', 'all'] = 'all', sbatch_exe: str = 'sbatch', dry_run: bool = False, force: bool = False, record: Literal['jobs.json', 'manifest'] = 'jobs.json') dict[str, Any]

Submit pyuvsim prepared scripts for a run_dir.

Parameters

run_dir

Prepared run directory.

stage

Which stage(s) to submit: “simulate” or “all”.

sbatch_exe

sbatch executable to invoke.

dry_run

If True, do not submit jobs; return the command 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).

Modules

cli_prepare

Prepare a pyuvsim validation run "kit" under the ValSKA results directory.

cli_submit

CLI entrypoint for submitting prepared pyuvsim runs.

constants

Constants for the Pyuvsim integration.

runner

Runner abstractions for executing pyuvsim via conda or containers.

setup

Prepare pyuvsim run directories, configs, and submit scripts.

slurm

SLURM submit-script rendering for pyuvsim runs.

submit

Submission helpers for pyuvsim prepared run directories.

templates

Access to bundled pyuvsim validation templates.