submit
JobSubmissionFailed ¶
SubmissionProgress ¶
Live, mutable tracking of one Submission's progress.
Tracks a submission from before it's even synced (state="SYNCING", no job yet),
through submission (job known, state polled from sacct), to running and, possibly,
cancellation.
A single flat list of these -- covering every submission, on every cluster, for one
submit() call -- is all a live display needs to render the whole picture, from a plain
rich.Live table (see render_job_table below) up to, eventually, a table shared across
several concurrent submit/submit_first calls (rich.Live only supports one live region
per console, so that would fuse several such lists together instead of replacing this one).
- Reference CLI submit wait_for_first_running_job
Source code in cluv/cli/submit.py
render_job_table ¶
render_job_table(
rows: list[SubmissionProgress],
*,
cancelling: bool = False,
) -> Table
Render the current state of every submission as a single table.
A plain rich.Live for now; the natural place to plug in a registry that fuses several
concurrent submit/submit_first calls' rows into one shared live region later on.
Source code in cluv/cli/submit.py
submit ¶
submit(
cluster: str,
job_script: Path | None,
sbatch_args: list[str],
program_args: list[str],
autocommit: bool = False,
chunking: int | None = None,
_skip_sync: bool = False,
) -> Job | None
Submit a job to the given cluster (or all clusters if cluster=="first"),
and return the Job object if successful.
Returns None if the submission failed.
Source code in cluv/cli/submit.py
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 | |
wait_for_first_running_job ¶
wait_for_first_running_job(
job_submissions: list[SubmissionProgress],
cluster_to_remote: dict[str, Remote | None],
tasks: list[Task],
found_running_job: Event,
max_wait_time_seconds: int = 60,
) -> SubmissionProgress | None
Poll sacct until one submitted job starts running, or every submission has failed.
Mutates rows in place with the latest known job id / state, so a live display can render
them at any point during this wait. Sets found_running_job the moment a job starts, so
that clusters which haven't submitted their own jobs yet can skip doing so.
Returns the row for the job that started, or None if every submission ended up failing.
Source code in cluv/cli/submit.py
wait_for_jobs_to_cancel ¶
wait_for_jobs_to_cancel(
job_submissions: list[SubmissionProgress],
cluster_to_remote: dict[str, Remote | None],
max_wait_time_seconds: int = 60,
) -> None
Cancel every (already-submitted) job in rows, and wait until they're all done.
Source code in cluv/cli/submit.py
run_scancel ¶
run_scancel(rows: list[SubmissionProgress]) -> None
Cancel the (already-submitted) jobs behind rows, grouped by remote.
Source code in cluv/cli/submit.py
submit_to_cluster ¶
submit_to_cluster(
cluster: str,
remote: Remote | None,
job_submissions: list[SubmissionProgress],
found_running_job: Event,
_skip_sync: bool = False,
) -> None
Sync then submit every submission for one cluster, in parallel.
Source code in cluv/cli/submit.py
get_submissions ¶
get_submissions(
cluster: str,
remote: Remote | None,
*,
job_script: Path | None,
sbatch_args: list[str],
program_args: list[str],
chunking: int | None,
git_commit: str,
) -> list[Submission]
Expand the possible job configurations for a cluster. Returns a list of Submission objects.
Does not do the actual job submission with sbatch.
Source code in cluv/cli/submit.py
sbatch_args_from_args_list ¶
sbatch_args_from_args_list(
sbatch_args_list: list[str],
) -> SbatchArgs
Convert a list of sbatch flags (from the CLI) to a dict of sbatch options.
Behaves like argparse, where if the flags are passed multiple times, the last value is kept. Aliases for common commands are also kept.
sbatch_args_from_args_list(["--time=2:00:00", "-t=00:00:30"]) {'time': '00:00:30'} sbatch_args_from_args_list(["--time=2:00:00", "--gpus=1"]) {'time': '2:00:00', 'gpus': '1'} sbatch_args_from_args_list(["--exclusive"]) {'exclusive': True} sbatch_args_from_args_list(["-N", "2"]) {'nodes': '2'} sbatch_args_from_args_list(["-f", "2"]) {'f': '2'} sbatch_args_from_args_list(["--gpus", "--requeue=False"]) {'gpus': True, 'requeue': 'False'} sbatch_args_from_args_list(["-n"]) {'n': True} sbatch_args_from_args_list(["--array=0-3%2", "-a=0-1%1"])
Source code in cluv/cli/submit.py
merge_sbatch_args ¶
merge_sbatch_args(
from_config: SbatchArgs, from_cli: list[str]
) -> SbatchArgs
Merge the sbatch args from the config and from the CLI, with CLI args taking precedence.
-t is normalized to time (its long-flag alias) as it's merged in, so --time=1:00:00
-t=2:00:00 -- config or CLI, either order -- resolves to a single time value (the last
one written) instead of leaving two separate keys for what's really the same sbatch option.
Source code in cluv/cli/submit.py
sbatch_args_from_dict ¶
sbatch_args_from_dict(d: SbatchArgs) -> list[str]
Convert a dict of sbatch options to a list of command-line flags.
Key-to-flag conversion:
- multi-char key + non-empty string value →
--key=value - single-char key + non-empty string value →
-k value(two separate args) - any key +
True→ bare flag (--keyor-k) - any key +
""orFalse→ omitted entirely
sbatch_args_from_dict({"time": "2:00:00", "gpus": "1"}) ['--time=2:00:00', '--gpus=1'] sbatch_args_from_dict({"exclusive": True}) ['--exclusive'] sbatch_args_from_dict({"N": "2"}) ['-N', '2'] sbatch_args_from_dict({"gpus": "", "requeue": False}) [] sbatch_args_from_dict({"n": True}) ['-n']
Source code in cluv/cli/submit.py
get_sbatch_command ¶
get_sbatch_command(
cluster: str,
job_script: Path,
sbatch_args: SbatchArgs,
program_args: list[str],
git_commit: str,
) -> str
Generate the command to submit the job via sbatch on cluster, with the appropriate
sbatch arguments, environment variables and paths set.
Source code in cluv/cli/submit.py
submit_job ¶
Does the actual sbatch call.
Raise a JobSubmissionFailed if the job submission fails for some reason.
Source code in cluv/cli/submit.py
build_submit_command ¶
build_submit_command(
cluster: str,
job_script: str | Path | PurePosixPath | None,
sbatch_args: list[str],
program_args: list[str],
) -> str
Build the local cluv submit command line used to launch the job.
Source code in cluv/cli/submit.py
create_submit_commit ¶
create_submit_commit(submit_command: str) -> None
Create a commit with tracked changes and include the launched job command in the body.
Source code in cluv/cli/submit.py
ensure_clean_git_state ¶
Check git is clean locally and return the current commit hash.