subway.plugins package¶
subway.plugins.debug module¶
debug for plain submitter and checker
-
class
subway.plugins.debug.
DebugChk
(params=None, is_next=False, **kwargs)[source]¶ Bases:
subway.framework.PlainChk
-
_abc_impl
= <_abc_data object>¶
-
check_checking
(jobid)[source]¶ DIY: must. Check job whose state is
checking
. Jobs are sent to this method only whenis_checked()
returnsTrue
. Generate possible new jobs and inputs based on results from main task and possibly check task. The very core of checker class.- Parameters
jobid – str.
- Returns
List[Tuple[str, Dict]]. [(jobid, resource dict), …]
-
subway.plugins.dslurm module¶
Provide DSlurmSub and DSlurmChk class, with consideration on check scripts into slurm system
-
class
subway.plugins.dslurm.
DSlurmChk
(params=None, _from='conf', **kwargs)[source]¶ Bases:
subway.plugins.sslurm.SSlurmChk
Slurm checker for DS scheme.
-
_abc_impl
= <_abc_data object>¶
-
check_finished
(jobid)[source]¶ DIY: depends. Check job whose state is
finished
. Namely, the main task has been computed sucessfully, we need to check output of main task to further generate check job and associated check input. On the other hand, if there is no need for check job to be controlled by submitter (i.e. one simply check the main output in checker and generate new jobs), one can omit this method, since the default implementation is used for such case (no check job scenario).- Parameters
jobid – str.
- Returns
List[Tuple[str, Dict]]. The length of the list must be 0 (no check job) or 1 (namely check job must be one to one correspondence with main job).
-
-
class
subway.plugins.dslurm.
DSlurmSub
(**kwargs)[source]¶ Bases:
subway.plugins.sslurm.SSlurmSub
Slurm submitter for DS scheme.
-
_abc_impl
= <_abc_data object>¶
-
submit_aborted
(jobid)[source]¶ DIY: depends. If you have to deal with DS scheme as in Double vs. Single Submitter together with fault tolerance, then you must implement this method.
- Parameters
jobid – str.
- Returns
-
submit_finished
(jobid)[source]¶ DIY: depends. If you have to deal with DS scheme as in Double vs. Single Submitter, then you must implement this method.
- Parameters
jobid – str.
- Returns
-
subway.plugins.nohup module¶
puerly linux nohup interface for job submission
-
class
subway.plugins.nohup.
NHSChk
(params=None, **kwargs)[source]¶ Bases:
subway.framework.PlainChk
,subway.plugins.renderer.PlainRenderer
checker using non-blocking subprocess.Popen
-
_abc_impl
= <_abc_data object>¶
-
check_checking
(jobid)[source]¶ DIY: must. Check job whose state is
checking
. Jobs are sent to this method only whenis_checked()
returnsTrue
. Generate possible new jobs and inputs based on results from main task and possibly check task. The very core of checker class.- Parameters
jobid – str.
- Returns
List[Tuple[str, Dict]]. [(jobid, resource dict), …]
-
abstract
check_checking_main
(jobid)[source]¶ DIY:MUST.
- Parameters
jobid – str.
- Returns
List[Union[Dict, List]]. list of param for new jobs
-
check_kickstart
()[source]¶ DIY: strongly recommended. Generate jobs with inputs at the beginning. The default impl does nothing. If the user doesn’t define this method in subclass, then the user must add inputs files and possible items in empty history.json by hand.
- Returns
List[Tuple[str, Dict]]. [(jobid, resource dict)]
-
is_aborted
(jobid)[source]¶ Default to False. One can hack history in check_finished and manually change the state to aborted.
- Parameters
jobid – str.
- Returns
bool.
-
is_checked
(jobid)[source]¶ DIY: depends. Whether a
checking
task is finished.- Parameters
jobid – str.
- Returns
bool.
-
is_failed
(jobid)[source]¶ DIY: depends. Whether a
resolving
task is failed.- Parameters
jobid – str.
- Returns
bool.
-
is_finished
(jobid)[source]¶ Using Popen.poll() to detect whether job is finished. For restarted subway run which lose popen object in the memory, use ps pid instead.
- Parameters
jobid – str.
- Returns
-
-
class
subway.plugins.nohup.
NHSSub
(**kwargs)[source]¶ Bases:
subway.framework.PlainSub
submitter using non-blocking subprocess.Popen
-
_abc_impl
= <_abc_data object>¶
-
subway.plugins.renderer module¶
Mixin for checker for higher level render and workflow
-
class
subway.plugins.renderer.
PlainRenderer
[source]¶ Bases:
object
-
_render_check
(params, jobid=None, _type='main', prefix='')[source]¶ DIY: not recommend. main entrance to rendered mixin, shall be called in checker class, check_* methods.
- Parameters
params – List[Union[Dict, List]].
jobid – Optional[str]. Default None for new job render, and jobid is give for assoc job render.
_type – Optional[str]. Default “main”. Current options also include “check”.
prefix – Optional[str]. Default
""
.
- Returns
List[Tuple[str, Dict[str, Any]]]. List of pairs with jobid and resource dict for new jobs or assoc job.
-
_render_input
(jobid, checkid='', param=None, prefix='')[source]¶ DIY: depends. If you try to customize this method, include
super()._render_input
is strongly recommended. Generate input files based on jobid and param. The default impl can render param to input.template. But this is not general enough for all user case, the user can simply rewrite this method.- Parameters
jobid – str.
param – Unoin[Dict, List, Tuple].
- Returns
None.
-
_render_newid
()[source]¶ DIY: depends. generate new job id. In most cases, the default implementation by
uuid4
is good enough.- Returns
str. jobid
-
_render_resource
(jobid, checkid='', param=None, prefix='')[source]¶ DIY: depends Default impl adds param and job_count=1 to resource dict. Even if you customize this method, we recommend you add
super()._render_resource
in your method.- Parameters
jobid – str.
checkid – Optional[str], default “”.
param – Optional[Union[List, Dict]].
prefix – Optiona[str], default “”.
- Returns
Dict, resource dict.
-
subway.plugins.slurm module¶
basic slurm plugin with some improvement on bool and time relevant methods.
-
class
subway.plugins.slurm.
SlurmChk
(params=None, **kwargs)[source]¶ Bases:
subway.framework.PlainChk
Low level checker for slurm with only some
is_*
and*_time
methods redefined. General users are recommended to usesubway.plugins.sslurm.SSlurmChk
instead.-
_abc_impl
= <_abc_data object>¶
-
ending_time
(jobid)[source]¶ For DS scheme, return finish time of check slurm job. For SS scheme, simply return now.
- Parameters
jobid – str.
- Returns
float, timestamp.
-
finishing_time
(jobid)[source]¶ get finish time from sacct.
- Parameters
jobid – str.
- Returns
float, timestamp.
-
is_aborted
(jobid)[source]¶ Determine job states based on sacct of main job.
- Parameters
jobid – str.
- Returns
bool.
-
is_checked
(jobid)[source]¶ For DS scheme, judge based on slurm job state of check job. For SS scheme, always return True.
- Parameters
jobid – str.
- Returns
bool.
-
is_failed
(jobid)[source]¶ DIY: depends. Whether a
resolving
task is failed.- Parameters
jobid – str.
- Returns
bool.
-
is_finished
(jobid)[source]¶ Determine job states based on sacct of main job.
- Parameters
jobid – str.
- Returns
bool.
-
-
class
subway.plugins.slurm.
SlurmSub
(**kwargs)[source]¶ Bases:
subway.framework.PlainSub
Exactly the same as
subway.framework.PlainSub
.-
_abc_impl
= <_abc_data object>¶
-
subway.plugins.sslurm module¶
More specific slurm plugin for checker and submitter, Extra S is for specific or single (indicates that check job not go through slurm)
-
class
subway.plugins.sslurm.
SSlurmChk
(params=None, _from='conf', **kwargs)[source]¶ Bases:
subway.plugins.slurm.SlurmChk
,subway.plugins.renderer.PlainRenderer
Slurm submitter with SS scheme and PlainRender mixin.
-
__init__
(params=None, _from='conf', **kwargs)[source]¶ - Parameters
params – List[Dict, List].
_from – str. conf, template.
kwargs –
-
_abc_impl
= <_abc_data object>¶
-
_render_input
(jobid, checkid='', param=None, prefix='')[source]¶ DIY: depends. Generate input files based on jobid and param. The default impl can render param to input.template and similar to sbatch.template. But this is not general enough for all user case, the user can simply rewrite this method.
- Parameters
jobid – str.
param – Unoin[Dict, List, Tuple].
- Returns
None.
-
_render_sbatch
(jobid, checkid='', param=None, prefix='')[source]¶ render sbatch script from template file or config.json. called from
_render_input
- Parameters
jobid – str.
checkid – Optiona[str].
param – Union[List, Dict].
prefix – Optional[str].
- Returns
None.
-
_substitue_opts
(opts, jobid, checkid='', param=None)[source]¶ inner function to render slurm commands from templates.
- Parameters
opts – List[str].
- Returns
List[str].
-
check_checking
(jobid)[source]¶ Call
check_checking_main
to get params and then call_render_check
.- Parameters
jobid – str.
- Returns
-
-
class
subway.plugins.sslurm.
SSlurmSub
(**kwargs)[source]¶ Bases:
subway.plugins.slurm.SlurmSub
Slurm checker with SS scheme.
-
_abc_impl
= <_abc_data object>¶
-