1. Build & push

Generates the SLURM/runner scripts, uploads the project to the cluster, creates the conda environment, and runs a preflight check.

Run 0_config.ipynb first — this notebook just loads the settings it saved.

import nb2slurm

wf, cfg = nb2slurm.load_config("control_config.json")
cfg.test_connection()  # sanity-check the SSH connection before build/push

Generate the scripts

Renders scripts/ (runner, job.slurm, the submitters) and environment.yml into the project root, and writes jobs.txt from jobs.json.

for kind, path in wf.build().items():
    print(f"{kind:13s} -> {path}")

Push the project to the cluster

Uploads source only (notebooks/, scripts/, jobs.json, …). It excludes output/ and done/, so pushing can never wipe results already on the cluster. (Requires rsync on your machine.)

wf.push(ssh=cfg, dry_run=True)  # preview the rsync command
wf.push(ssh=cfg)  # for real

Create the conda environment (one-time, optional)

Commented out code so a ‘run all cells’ does not immediately break it, but the user needs to run the creation once!!!

Skip if the cluster provides your environment.

# wf.create_environment(ssh=cfg)

If this cell fails, the environment will still exists, so it needs to be deleted, which can be done in 2 ways:

# wf.remove_environment(ssh=cfg)                  # delete the env + its Jupyter kernel
# wf.create_environment(ssh=cfg, overwrite=True)  # force a clean rebuild from scratch

Preflight check

Confirm the cluster is ready before submitting.

wf.check(ssh=cfg)