subway.components package¶
subway.components.genfiles module¶
smarter file rendered can be utilized in _render_input of SSlurmChk
subway.components.slurmoo module¶
Lower level abstraction of slurm from CLI interaction.
-
class
subway.components.slurmoo.
SlurmJob
(jobname=None, jobid=None, sacct='sacct')[source]¶ Bases:
object
Abstraction for job submitted to slurm.
-
__init__
(jobname=None, jobid=None, sacct='sacct')[source]¶ - Parameters
jobname – Optional[str].
jobid – Optional[str]. One must specify at least one between
jobid
andjobname
.sacct – Optional[str]. Binary for
sacct
in shell, default is “sacct”.
-
_get_jobinfo
(jobid)[source]¶ get job relavant info from sacct by jobid
- Parameters
jobid – str.
- Returns
jobinfo: Dict[str, str],
{'User': 'linuxuser', 'JobID': '4500', 'JobName': 'uuid', 'Partition': 'general', 'State': 'COMPLETED', 'Timelimit': '365-00:00+', 'Start': '2020-02-23T10:05:55', 'End': '2020-02-23T10:06:15', 'Elapsed': '00:00:20', 'NNodes': '1', 'NCPUS': '2'}
-
get_jobid
(jobname, tries=10, interval=0.8)[source]¶ get jobid from jobname via sacct query
- Parameters
jobname – str.
tries – Optional[int]. Default 10. It is worthing noting that query soon after job submitted would meet empty line, so repetitive try is necessary.
interval – Optional[float]. Default 0.8. Seconds between two tries.
- Returns
str. jobid.
- Raises
SlurmException – when failed to get jobid after
tries
tries.
-
get_jobinfo
(jobid, tries=10, interval=0.8)[source]¶ get job info from jobid via sacct query
- Parameters
jobid – str, jobid in slurm system (not jobid in subway which is jobname in slurm!)
tries – Optional[int]. Default 10. It is worthing noting that query soon after job submitted would meet ilegal line, so repetitive try is necessary.
interval – Optional[float]. Default 0.8. Seconds between two tries.
- Returns
Dict. Slurm job info.
-
-
class
subway.components.slurmoo.
SlurmTask
(sbatch='sbatch', scancel='scancel', shebang='#!/bin/bash', sbatch_path=None, sbatch_options=None, sbatch_commands=None)[source]¶ Bases:
object
Abstraction for slurm job to be submitted.
-
__init__
(sbatch='sbatch', scancel='scancel', shebang='#!/bin/bash', sbatch_path=None, sbatch_options=None, sbatch_commands=None)[source]¶ - Parameters
sbatch – string, binary for sbatch
sbatch – string, binary for scancel
shebang – string, the #! line
sbatch_path – string, sbatch script path
sbatch_options – list of strings, such as “–job-name=uuid”
sbatch_commands – list of strings, main command, such as “python test.py”
-
delete
(include_output=False)[source]¶ Delete the sbatch script and slurm output (experimental)
- Parameters
include_output – Optional[bool]. Default False, whether try to delete slurm output
- Returns
None.
-
jobid
()[source]¶ Get jobid from stdout of
sbatch
.- Returns
str. jobid
- Raises
SlurmException – No legal stdout from sbatch command to capture the jobid.
-
-
subway.components.slurmoo.
_slurm_time_trans
(timestr, _format='%Y-%m-%dT%H:%M:%S')[source]¶ Fault tolerant time string translate to time obj and time stamps
- Parameters
timestr – str.
_format – Optional[str]. Default as “%Y-%m-%dT%H:%M:%S” used in sacct output
- Returns
Tuple[Datetime, float]. Datetime obj and timestamp.