2. Submit & monitor

Launches the jobs from jobs.json and lets you watch / cancel them. Run 1_build.ipynb first (and again whenever you change a notebook — see 3_sync).

import nb2slurm

wf, cfg = nb2slurm.load_config("control_config.json")

Submit

submit() reads jobs.json by default — one job per leaf path.

wf.submit(ssh=cfg, dry_run=True)  # preview the sbatch commands
job_ids = wf.submit(ssh=cfg)  # for real

# run a custom subset instead:
#   wf.submit([("Netherlands", "south", "climate_as_we_are")], ssh=cfg)

# concurrency is set on the Workflow (in 0_config); override per call to cap
# how many run at once, or submit all at once with no dependencies:
#   wf.submit(ssh=cfg, concurrency=0)

Monitor

Parsed squeue for your jobs.

for row in wf.status(ssh=cfg):
    print(row)

Cancel (if needed)

Cancels the jobs submitted in this session.

wf.cancel(ssh=cfg)