Submit
submit
submit(
cluster: str,
job_script: Path | None,
sbatch_args: list[str],
program_args: list[str],
) -> Job | None
Submit a SLURM job on a remote cluster.
Enforces a clean git state, syncs the project, sets GIT_COMMIT and any
environment variables configured in [tool.cluv.env] / [tool.cluv.clusters.<name>.env],
then calls sbatch on the remote.
sbatch_args are forwarded as flags to sbatch; program_args are passed to
the job script.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cluster
|
str
|
SSH hostname of the target cluster. Can be set to "first" to launch the job on all clusters and keep only the first one to starts. |
required |
job_script
|
Path | None
|
Path to the job script to submit, relative to the project root. When omitted, uses the configured default for the target cluster. |
required |
sbatch_args
|
list[str]
|
List of additional flags to pass to |
required |
program_args
|
list[str]
|
List of arguments to pass to the job script, for example |
required |
Returns:
| Type | Description |
|---|---|
Job | None
|
The job ID of the submitted job or None if the sbatch command fails. |
Examples:
submit(
"mila",
"scripts/job.sh",
sbatch_args=["--time=00:00:10"],
program_args=["python", "--version"],
)
Source code in cluv/cli/submit.py
submit_first
submit_first(
job_script: Path | None,
sbatch_args: list[str],
program_args: list[str],
git_commit: str,
) -> Job | None
Submit the job on all clusters, and wait until one of them starts. Once one starts, cancel the others.
Source code in cluv/cli/submit.py
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 | |
wait_for_running_job
wait_for_running_job(
cluster_and_jobid_to_jobstate: dict[
tuple[str, int], str
],
cluster_to_remote: dict[str, Remote | None],
max_wait_time_seconds: int = 60,
) -> JobHandle | None
Watch the jobs with sacct until one of them starts (or completes).
Source code in cluv/cli/submit.py
ensure_clean_git_state
ensure_clean_git_state() -> str
Check git is clean locally and return the current commit hash.
Source code in cluv/cli/submit.py
get_job_script_path
Resolve the job script path for a cluster.
Source code in cluv/cli/submit.py
get_sbatch_command
get_sbatch_command(
cluster: str,
job_script: Path,
sbatch_args: list[str],
program_args: list[str],
git_commit: str,
) -> str
Generate the command to submit the job via sbatch on the remote cluster, with the appropriate env vars set.
Source code in cluv/cli/submit.py
sbatch
sbatch(
remote: Remote | None,
job_script: Path,
sbatch_args: list[str],
program_args: list[str],
git_commit: str,
) -> CompletedProcess[str]
Submit the job via sbatch on the remote cluster, and return the job id.
Source code in cluv/cli/submit.py
get_job_state
Get the state of the job with the given id on the remote cluster with sacct.
Source code in cluv/cli/submit.py
cancel_job
Cancel the job with the given id on the remote cluster.