Job.Service API¶
The Service class allows databases and servers to be spawned within a Toil workflow.
-
class
Job.
Service
(memory=None, cores=None, disk=None, preemptable=None, unitName=None)[source]¶ Abstract class used to define the interface to a service.
Should be subclassed by the user to define services.
Is not executed as a job; runs within a ServiceHostJob.
-
__init__
(memory=None, cores=None, disk=None, preemptable=None, unitName=None)[source]¶ Memory, core and disk requirements are specified identically to as in
toil.job.Job.__init__()
.
-
start
(job)[source]¶ Start the service.
Parameters: job (toil.job.Job) – The underlying host job that the service is being run in. Can be used to register deferred functions, or to access the fileStore for creating temporary files. Returns: An object describing how to access the service. The object must be pickleable and will be used by jobs to access the service (see toil.job.Job.addService()
).
-
stop
(job)[source]¶ Stops the service. Function can block until complete.
Parameters: job (toil.job.Job) – The underlying host job that the service is being run in. Can be used to register deferred functions, or to access the fileStore for creating temporary files.
-
check
()[source]¶ Checks the service is still running.
Raises: exceptions.RuntimeError – If the service failed, this will cause the service job to be labeled failed. Returns: True if the service is still running, else False. If False then the service job will be terminated, and considered a success. Important point: if the service job exits due to a failure, it should raise a RuntimeError, not return False!
-