cellmap_flow.jobs.spec
What a job is, whichever backend runs it.
JobSpec says what to run and with what resources; a backend
(jobs.lsf or jobs.local) turns it into a running Job. The rest
is shared by both: the statuses, the host marker a server prints, a log
file’s tail, and a filesystem-safe stem for its name.
Attributes
Exceptions
A job was asked for and no usable one came of it. |
Classes
One job to submit. |
|
Enumeration of possible job statuses. |
|
Abstract base class for jobs across different execution environments. |
Functions
|
|
|
|
|
Where job logs go unless the spec says otherwise. |
|
Whether |
|
Read the tail of a log file, for surfacing crash output. Returns None if unreadable/empty. |
|
A filesystem-safe stem for this job's log file. |
|
Extract host/URL from command output using configured patterns. |
|
The address to use for a server that reported |
Module Contents
- cellmap_flow.jobs.spec.logger
- cellmap_flow.jobs.spec.IP_PATTERN = ['CELLMAP_FLOW_SERVER_IP(', ')CELLMAP_FLOW_SERVER_IP']
- cellmap_flow.jobs.spec.SERVER_URL_TEMPLATE_ENV = 'CELLMAP_FLOW_SERVER_URL_TEMPLATE'
- cellmap_flow.jobs.spec.shell_quote(part) str
partas one shell word, quoted without ever emitting a single quote.
- cellmap_flow.jobs.spec.shell_join(argv) str
argvas a shell line for a job’sshell(shell_quote’s words).
- class cellmap_flow.jobs.spec.JobSpec
One job to submit.
Exactly one of
argvandshellis given.argvis run as it stands.shellis a command line run bybash -c, which is what servers, finetune runs and blockwise workers have always been given; the finetune command needs it, since it sets LD_LIBRARY_PATH and pipes through tee.queueNone asks for none (-qis left out, so LSF’s default queue), andgpus0 asks for no GPU.walltimeis LSF’s[hours:]minutes; None leaves the queue’s default.log_dirNone isjobs.launch.SERVER_LOG_DIR, read when the job is submitted.envis added to this process’s environment, which the job inherits either way.- name: str
- argv: Tuple[str, ...] | None = None
- shell: str | None = None
- queue: str | None = None
- charge_group: str | None = None
- gpus: int = 1
- cpus: int = 4
- walltime: str | None = None
- log_dir: pathlib.Path | None = None
- env: Mapping[str, str] | None = None
- cellmap_flow.jobs.spec.default_log_dir() pathlib.Path
Where job logs go unless the spec says otherwise.
jobs.launch.SERVER_LOG_DIR, read at call time rather than copied: it is the one setting of it (tests and deployments point it elsewhere). Imported here because launch imports this module.
- class cellmap_flow.jobs.spec.JobStatus(*args, **kwds)
Enumeration of possible job statuses.
- PENDING = 'pending'
- RUNNING = 'running'
- COMPLETED = 'completed'
- FAILED = 'failed'
- KILLED = 'killed'
- exception cellmap_flow.jobs.spec.JobStartError
A job was asked for and no usable one came of it.
- cellmap_flow.jobs.spec.exists_now(path) bool
Whether
pathexists, when another host may have just created it.A job writes its log and ready file on the node it runs on, and the launcher looks for them from another one. Over NFS that host caches “no such file” for a name it looked up, until the directory’s attributes time out (acdirmax, 60 s by default; /groups and /nrs are mounted without actimeo). So a log the trainer had been writing for a minute still did not exist for the dashboard, which meanwhile showed bpeek’s delayed output. Reading the directory makes the client revalidate it, which drops those cached misses; it is only done when the name is not found, so a file already seen costs one stat.
- cellmap_flow.jobs.spec.tail(path: pathlib.Path, max_chars: int = 4000) str | None
Read the tail of a log file, for surfacing crash output. Returns None if unreadable/empty.
Seeks to the end rather than reading the whole file. An inference server log can run to hundreds of megabytes, and this is called from the polling loop in
wait_for_hostwhile the caller is blocked.Reads 4 bytes per requested character so a multi-byte sequence split at the seek boundary still leaves at least
max_charsintact; the leading partial character decodes to a replacement char and is sliced off.
- cellmap_flow.jobs.spec.log_stem(job_name: str) str
A filesystem-safe stem for this job’s log file.
job_namearrives from model names, YAML and HuggingFace repo ids, so it can carry a path separator or... Interpolated straight into a path, that writes the log outside the log directory – or, more quietly, makes the path we read back afterwards differ from the one we handed bsub, so a crashed job looks like it produced no output at all.Both the
-opattern and the path reconstructed after submission are built from this one value, so they cannot drift apart.
- cellmap_flow.jobs.spec.extract_host_from_output(output: str) str | None
Extract host/URL from command output using configured patterns.
- Parameters:
output – String output to search
- Returns:
Host URL if found, None otherwise
- cellmap_flow.jobs.spec.public_server_url(url: str | None) str | None
The address to use for a server that reported
url:urlitself, orurlput through $CELLMAP_FLOW_SERVER_URL_TEMPLATE when that is set (see SERVER_URL_TEMPLATE_ENV). Read at call time.
- class cellmap_flow.jobs.spec.Job(model_name: str | None = None)
Abstract base class for jobs across different execution environments.
Subclasses should implement: - kill(): Terminate the job - get_status(): Get current job status - wait_for_host(): Wait for and extract host information
- model_name = None
- status
- host: str | None = None
- queue: str | None = None
- abstractmethod kill() None
Terminate the job.
- abstractmethod wait_for_host(timeout: int = 300) str | None
Wait for the job to provide host information.
- Parameters:
timeout – Maximum time to wait in seconds
- Returns:
Host URL if found, None otherwise
- peek(max_chars: int = 4000) str | None
The tail of this job’s own output, or None if it cannot be read.
- is_running() bool
Check if the job is currently running.