toil.batchSystems.awsBatch¶
Batch system for running Toil workflows on AWS Batch.
Useful with the AWS job store.
AWS Batch has no means for scheduling based on disk usage, so the backing machines need to have “enough” disk and other constraints need to guarantee that disk does not fill.
Assumes that an AWS Batch Queue name or ARN is already provided.
Handles creating and destroying a JobDefinition for the workflow run.
Additional containers should be launched with Singularity, not Docker.
Attributes¶
Exceptions¶
Common base class for all non-exit exceptions. |
Classes¶
Enum where members are also (and must be) ints |
|
Adds cleanup support when the last running job leaves a node, for batch |
|
Protocol for the setOption function we get to let us set up CLI options for |
|
Produced when using a batch system, links toil assigned batch ID to |
|
Class to represent configuration operations for a toil workflow run. |
|
A context manager that represents a Toil workflow. |
|
Stores all the information that the Toil Leader ever needs to know about a Job. |
|
Base class implementing the storage and presentation of requirements. |
|
Represents a file or directory that will be deployed to each node before any jobs in the user script are invoked. |
|
Adds cleanup support when the last running job leaves a node, for batch |
Functions¶
|
Return the fully qualified name of the Docker image to start Toil appliance containers from. |
|
Create a command that runs the given command in an environment. |
Return the AWS region that the currently configured AWS zone (see |
|
|
Get a Boto 3 session usable by the current thread. |
|
Convert a number from bytes to mibibytes. |
|
Toil jobs that have completed are not allowed to have taken 0 seconds, but |
Return the current time in milliseconds since the Unix epoch. |
|
|
Retry a function if it fails with any Exception defined in "errors". |
Module Contents¶
- toil.batchSystems.awsBatch.applianceSelf(forceDockerAppliance=False)¶
Return the fully qualified name of the Docker image to start Toil appliance containers from.
The result is determined by the current version of Toil and three environment variables:
TOIL_DOCKER_REGISTRY,TOIL_DOCKER_NAMEandTOIL_APPLIANCE_SELF.TOIL_DOCKER_REGISTRYspecifies an account on a publicly hosted docker registry like Quay or Docker Hub. The default is UCSC’s CGL account on Quay.io where the Toil team publishes the official appliance images.TOIL_DOCKER_NAMEspecifies the base name of the image. The default of toil will be adequate in most cases.TOIL_APPLIANCE_SELFfully qualifies the appliance image, complete with registry, image name and version tag, overriding bothTOIL_DOCKER_NAMEand TOIL_DOCKER_REGISTRY` as well as the version tag of the image. Setting TOIL_APPLIANCE_SELF will not be necessary in most cases.
- toil.batchSystems.awsBatch.EXIT_STATUS_UNAVAILABLE_VALUE = 255¶
- class toil.batchSystems.awsBatch.BatchJobExitReason¶
Bases:
enum.IntEnumEnum where members are also (and must be) ints
- exception toil.batchSystems.awsBatch.InsufficientSystemResources(requirer, resource, available=None, batch_system=None, source=None, details=[])¶
Bases:
ExceptionCommon base class for all non-exit exceptions.
- Parameters:
requirer (toil.job.Requirer)
resource (str)
available (Optional[toil.job.ParsedRequirement])
batch_system (Optional[str])
source (Optional[str])
details (List[str])
- class toil.batchSystems.awsBatch.UpdatedBatchJobInfo¶
Bases:
NamedTuple- exitStatus: int¶
The exit status (integer value) of the job. 0 implies successful.
EXIT_STATUS_UNAVAILABLE_VALUE is used when the exit status is not available (e.g. job is lost, or otherwise died but actual exit code was not reported).
- exitReason: BatchJobExitReason | None¶
- class toil.batchSystems.awsBatch.BatchSystemCleanupSupport(config, maxCores, maxMemory, maxDisk)¶
Bases:
toil.batchSystems.local_support.BatchSystemLocalSupportAdds cleanup support when the last running job leaves a node, for batch systems that can’t provide it using the backing scheduler.
- Parameters:
config (toil.common.Config)
maxCores (float)
maxMemory (int)
maxDisk (int)
- classmethod supportsWorkerCleanup()¶
Whether this batch system supports worker cleanup.
Indicates whether this batch system invokes
BatchSystemSupport.workerCleanup()after the last job for a particular workflow invocation finishes. Note that the term worker refers to an entire node, not just a worker process. A worker process may run more than one job sequentially, and more than one concurrent worker process may exist on a worker node, for the same workflow. The batch system is said to shut down after the last worker process terminates.- Return type:
- getWorkerContexts()¶
Get a list of picklable context manager objects to wrap worker work in, in order.
Can be used to ask the Toil worker to do things in-process (such as configuring environment variables, hot-deploying user scripts, or cleaning up a node) that would otherwise require a wrapping “executor” process.
- Return type:
List[ContextManager[Any]]
- toil.batchSystems.awsBatch.pack_job(command, user_script=None, environment=None)¶
Create a command that runs the given command in an environment.
- Parameters:
command (str) – Worker command to run to run the job.
user_script (Optional[toil.resource.Resource]) – User script that will be loaded before the job is run.
environment (Optional[Dict[str, str]]) – Environment variable dict that will be applied before the job is run.
- Returns:
Command to run the job, as an argument list that can be run inside the Toil appliance container.
- Return type:
List[str]
- class toil.batchSystems.awsBatch.OptionSetter¶
Bases:
ProtocolProtocol for the setOption function we get to let us set up CLI options for each batch system.
Actual functionality is defined in the Config class.
- OptionType¶
- __call__(option_name, parsing_function=None, check_function=None, default=None, env=None, old_names=None)¶
- class toil.batchSystems.awsBatch.ExternalBatchIdMessage¶
Bases:
NamedTupleProduced when using a batch system, links toil assigned batch ID to Batch system ID (Whatever’s returned by local implementation, PID, batch ID, etc)
- class toil.batchSystems.awsBatch.Config¶
Class to represent configuration operations for a toil workflow run.
- batch_logs_dir: str | None¶
The backing scheduler will be instructed, if possible, to save logs to this directory, where the leader can read them.
- workflowID: str | None¶
This attribute uniquely identifies the job store and therefore the workflow. It is necessary in order to distinguish between two consecutive workflows for which self.jobStore is the same, e.g. when a job store name is reused after a previous run has finished successfully and its job store has been clean up.
- defaultAccelerators: List[toil.job.AcceleratorRequirement]¶
- set_from_default_config()¶
- Return type:
None
- prepare_start()¶
After options are set, prepare for initial start of workflow.
- Return type:
None
- prepare_restart()¶
Before restart options are set, prepare for a restart of a workflow. Set up any execution-specific parameters and clear out any stale ones.
- Return type:
None
- setOptions(options)¶
Creates a config object from the options object.
- Parameters:
options (argparse.Namespace)
- Return type:
None
- check_configuration_consistency()¶
Old checks that cannot be fit into an action class for argparse
- Return type:
None
- class toil.batchSystems.awsBatch.Toil(options)¶
Bases:
ContextManager[Toil]A context manager that represents a Toil workflow.
Specifically the batch system, job store, and its configuration.
- Parameters:
options (argparse.Namespace)
- __enter__()¶
Derive configuration from the command line options.
Then load the job store and, on restart, consolidate the derived configuration with the one from the previous invocation of the workflow.
- Return type:
- __exit__(exc_type, exc_val, exc_tb)¶
Clean up after a workflow invocation.
Depending on the configuration, delete the job store.
- Parameters:
exc_type (Optional[Type[BaseException]])
exc_val (Optional[BaseException])
exc_tb (Optional[types.TracebackType])
- Return type:
Literal[False]
- start(rootJob)¶
Invoke a Toil workflow with the given job as the root for an initial run.
This method must be called in the body of a
with Toil(...) as toil:statement. This method should not be called more than once for a workflow that has not finished.- Parameters:
rootJob (toil.job.Job) – The root job of the workflow
- Returns:
The root job’s return value
- Return type:
Any
- restart()¶
Restarts a workflow that has been interrupted.
- Returns:
The root job’s return value
- Return type:
Any
- classmethod getJobStore(locator)¶
Create an instance of the concrete job store implementation that matches the given locator.
- Parameters:
locator (str) – The location of the job store to be represent by the instance
- Returns:
an instance of a concrete subclass of AbstractJobStore
- Return type:
- static createBatchSystem(config)¶
Create an instance of the batch system specified in the given config.
- Parameters:
config (Config) – the current configuration
- Returns:
an instance of a concrete subclass of AbstractBatchSystem
- Return type:
- importFile(srcUrl: str, sharedFileName: str, symlink: bool = True) None¶
- importFile(srcUrl: str, sharedFileName: None = None, symlink: bool = True) toil.fileStores.FileID
- import_file(src_uri: str, shared_file_name: str, symlink: bool = True, check_existence: bool = True) None¶
- import_file(src_uri: str, shared_file_name: None = None, symlink: bool = True, check_existence: bool = True) toil.fileStores.FileID
Import the file at the given URL into the job store.
By default, returns None if the file does not exist.
- Parameters:
check_existence – If true, raise FileNotFoundError if the file does not exist. If false, return None when the file does not exist.
See
toil.jobStores.abstractJobStore.AbstractJobStore.importFile()for a full description
- exportFile(jobStoreFileID, dstUrl)¶
- Parameters:
jobStoreFileID (toil.fileStores.FileID)
dstUrl (str)
- Return type:
None
- export_file(file_id, dst_uri)¶
Export file to destination pointed at by the destination URL.
See
toil.jobStores.abstractJobStore.AbstractJobStore.exportFile()for a full description- Parameters:
file_id (toil.fileStores.FileID)
dst_uri (str)
- Return type:
None
- static normalize_uri(uri, check_existence=False)¶
Given a URI, if it has no scheme, prepend “file:”.
- static getToilWorkDir(configWorkDir=None)¶
Return a path to a writable directory under which per-workflow directories exist.
This directory is always required to exist on a machine, even if the Toil worker has not run yet. If your workers and leader have different temp directories, you may need to set TOIL_WORKDIR.
- classmethod get_toil_coordination_dir(config_work_dir, config_coordination_dir)¶
Return a path to a writable directory, which will be in memory if convenient. Ought to be used for file locking and coordination.
- Parameters:
- Returns:
Path to the Toil coordination directory. Ought to be on a POSIX filesystem that allows directories containing open files to be deleted.
- Return type:
- static get_workflow_path_component(workflow_id)¶
Get a safe filesystem path component for a workflow.
Will be consistent for all processes on a given machine, and different for all processes on different machines.
- classmethod getLocalWorkflowDir(workflowID, configWorkDir=None)¶
Return the directory where worker directories and the cache will be located for this workflow on this machine.
- classmethod get_local_workflow_coordination_dir(workflow_id, config_work_dir, config_coordination_dir)¶
Return the directory where coordination files should be located for this workflow on this machine. These include internal Toil databases and lock files for the machine.
If an in-memory filesystem is available, it is used. Otherwise, the local workflow directory, which may be on a shared network filesystem, is used.
- Parameters:
- Returns:
Path to the local workflow coordination directory on this machine.
- Return type:
- class toil.batchSystems.awsBatch.JobDescription(requirements, jobName, unitName='', displayName='', local=None)¶
Bases:
RequirerStores all the information that the Toil Leader ever needs to know about a Job.
- This includes:
Resource requirements.
Which jobs are children or follow-ons or predecessors of this job.
A reference to the Job object in the job store.
Can be obtained from an actual (i.e. executable) Job object, and can be used to obtain the Job object from the JobStore.
Never contains other Jobs or JobDescriptions: all reference is by ID.
Subclassed into variants for checkpoint jobs and service jobs that have their specific parameters.
- Parameters:
- get_names()¶
Get the names and ID of this job as a named tuple.
- Return type:
- get_chain()¶
Get all the jobs that executed in this job’s chain, in order.
For each job, produces a named tuple with its various names and its original job store ID. The jobs in the chain are in execution order.
If the job hasn’t run yet or it didn’t chain, produces a one-item list.
- Return type:
List[toil.bus.Names]
- serviceHostIDsInBatches()¶
Find all batches of service host job IDs that can be started at the same time.
(in the order they need to start in)
- Return type:
Iterator[List[str]]
- successorsAndServiceHosts()¶
Get an iterator over all child, follow-on, and service job IDs.
- Return type:
Iterator[str]
- allSuccessors()¶
Get an iterator over all child, follow-on, and chained, inherited successor job IDs.
Follow-ons will come before children.
- Return type:
Iterator[str]
- successors_by_phase()¶
Get an iterator over all child/follow-on/chained inherited successor job IDs, along with their phase numbere on the stack.
Phases ececute higher numbers to lower numbers.
- property services¶
- Get a collection of the IDs of service host jobs for this job, in arbitrary order.
Will be empty if the job has no unfinished services.
- attach_body(file_store_id, user_script)¶
Attach a job body to this JobDescription.
Takes the file store ID that the body is stored at, and the required user script module.
The file store ID can also be “firstJob” for the root job, stored as a shared file instead.
- Parameters:
file_store_id (str)
user_script (toil.resource.ModuleDescriptor)
- Return type:
None
- detach_body()¶
Drop the body reference from a JobDescription.
- Return type:
None
- get_body()¶
Get the information needed to load the job body.
- Returns:
a file store ID (or magic shared file name “firstJob”) and a user script module.
- Return type:
Tuple[str, toil.resource.ModuleDescriptor]
Fails if no body is attached; check has_body() first.
- nextSuccessors()¶
Return the collection of job IDs for the successors of this job that are ready to run.
If those jobs have multiple predecessor relationships, they may still be blocked on other jobs.
Returns None when at the final phase (all successors done), and an empty collection if there are more phases but they can’t be entered yet (e.g. because we are waiting for the job itself to run).
- Return type:
Optional[Set[str]]
- filterSuccessors(predicate)¶
Keep only successor jobs for which the given predicate function approves.
The predicate function is called with the job’s ID.
Treats all other successors as complete and forgets them.
- filterServiceHosts(predicate)¶
Keep only services for which the given predicate approves.
The predicate function is called with the service host job’s ID.
Treats all other services as complete and forgets them.
- clear_nonexistent_dependents(job_store)¶
Remove all references to child, follow-on, and associated service jobs that do not exist.
That is to say, all those that have been completed and removed.
- Parameters:
job_store (toil.jobStores.abstractJobStore.AbstractJobStore)
- Return type:
None
- clear_dependents()¶
Remove all references to successor and service jobs.
- Return type:
None
- is_subtree_done()¶
Check if the subtree is done.
- Returns:
True if the job appears to be done, and all related child, follow-on, and service jobs appear to be finished and removed.
- Return type:
- replace(other)¶
Take on the ID of another JobDescription, retaining our own state and type.
When updated in the JobStore, we will save over the other JobDescription.
Useful for chaining jobs: the chained-to job can replace the parent job.
Merges cleanup state and successors other than this job from the job being replaced into this one.
- Parameters:
other (JobDescription) – Job description to replace.
- Return type:
None
- assert_is_not_newer_than(other)¶
Make sure this JobDescription is not newer than a prospective new version of the JobDescription.
- Parameters:
other (JobDescription)
- Return type:
None
- is_updated_by(other)¶
Return True if the passed JobDescription is a distinct, newer version of this one.
- Parameters:
other (JobDescription)
- Return type:
- addChild(childID)¶
Make the job with the given ID a child of the described job.
- Parameters:
childID (str)
- Return type:
None
- addFollowOn(followOnID)¶
Make the job with the given ID a follow-on of the described job.
- Parameters:
followOnID (str)
- Return type:
None
- addServiceHostJob(serviceID, parentServiceID=None)¶
Make the ServiceHostJob with the given ID a service of the described job.
If a parent ServiceHostJob ID is given, that parent service will be started first, and must have already been added.
- hasChild(childID)¶
Return True if the job with the given ID is a child of the described job.
- hasFollowOn(followOnID)¶
Test if the job with the given ID is a follow-on of the described job.
- hasServiceHostJob(serviceID)¶
Test if the ServiceHostJob is a service of the described job.
- Return type:
- renameReferences(renames)¶
Apply the given dict of ID renames to all references to jobs.
Does not modify our own ID or those of finished predecessors. IDs not present in the renames dict are left as-is.
- Parameters:
renames (Dict[TemporaryID, str]) – Rename operations to apply.
- Return type:
None
- addPredecessor()¶
Notify the JobDescription that a predecessor has been added to its Job.
- Return type:
None
- onRegistration(jobStore)¶
Perform setup work that requires the JobStore.
Called by the Job saving logic when this JobDescription meets the JobStore and has its ID assigned.
Overridden to perform setup work (like hooking up flag files for service jobs) that requires the JobStore.
- Parameters:
jobStore (toil.jobStores.abstractJobStore.AbstractJobStore) – The job store we are being placed into
- Return type:
None
- setupJobAfterFailure(exit_status=None, exit_reason=None)¶
Configure job after a failure.
Reduce the remainingTryCount if greater than zero and set the memory to be at least as big as the default memory (in case of exhaustion of memory, which is common).
Requires a configuration to have been assigned (see
toil.job.Requirer.assignConfig()).- Parameters:
exit_status (Optional[int]) – The exit code from the job.
exit_reason (Optional[toil.batchSystems.abstractBatchSystem.BatchJobExitReason]) – The reason the job stopped, if available from the batch system.
- Return type:
None
- getLogFileHandle(jobStore)¶
Create a context manager that yields a file handle to the log file.
Assumes logJobStoreFileID is set.
- property remainingTryCount¶
- Get the number of tries remaining.
The try count set on the JobDescription, or the default based on the retry count from the config if none is set.
- clearRemainingTryCount()¶
Clear remainingTryCount and set it back to its default value.
- Returns:
True if a modification to the JobDescription was made, and False otherwise.
- Return type:
- __repr__()¶
Return repr(self).
- reserve_versions(count)¶
Reserve a job version number for later, for journaling asynchronously.
- Parameters:
count (int)
- Return type:
None
- pre_update_hook()¶
Run before pickling and saving a created or updated version of this job.
Called by the job store.
- Return type:
None
- class toil.batchSystems.awsBatch.Requirer(requirements)¶
Base class implementing the storage and presentation of requirements.
Has cores, memory, disk, and preemptability as properties.
- Parameters:
requirements (Mapping[str, ParseableRequirement])
- assignConfig(config)¶
Assign the given config object to be used to provide default values.
Must be called exactly once on a loaded JobDescription before any requirements are queried.
- Parameters:
config (toil.common.Config) – Config object to query
- Return type:
None
- __getstate__()¶
Return the dict to use as the instance’s __dict__ when pickling.
- Return type:
Dict[str, Any]
- __copy__()¶
Return a semantically-shallow copy of the object, for
copy.copy().- Return type:
- __deepcopy__(memo)¶
Return a semantically-deep copy of the object, for
copy.deepcopy().- Parameters:
memo (Any)
- Return type:
- property requirements: RequirementsDict¶
Get dict containing all non-None, non-defaulted requirements.
- Return type:
- property preemptible: bool¶
Whether a preemptible node is permitted, or a nonpreemptible one is required.
- Return type:
- preemptable(val)¶
- Parameters:
val (ParseableFlag)
- Return type:
None
- property accelerators: List[AcceleratorRequirement]¶
Any accelerators, such as GPUs, that are needed.
- Return type:
List[AcceleratorRequirement]
- scale(requirement, factor)¶
Return a copy of this object with the given requirement scaled up or down.
Only works on requirements where that makes sense.
- toil.batchSystems.awsBatch.get_current_aws_region()¶
Return the AWS region that the currently configured AWS zone (see get_current_aws_zone()) is in.
- Return type:
Optional[str]
- toil.batchSystems.awsBatch.establish_boto3_session(region_name=None)¶
Get a Boto 3 session usable by the current thread.
This function may not always establish a new session; it can be memoized.
- Parameters:
region_name (Optional[str])
- Return type:
boto3.Session
- toil.batchSystems.awsBatch.b_to_mib(n)¶
Convert a number from bytes to mibibytes.
- toil.batchSystems.awsBatch.slow_down(seconds)¶
Toil jobs that have completed are not allowed to have taken 0 seconds, but Kubernetes timestamps round things to the nearest second. It is possible in some batch systems for a pod to have identical start and end timestamps.
This function takes a possibly 0 job length in seconds and enforces a minimum length to satisfy Toil.
- toil.batchSystems.awsBatch.unix_now_ms()¶
Return the current time in milliseconds since the Unix epoch.
- Return type:
- toil.batchSystems.awsBatch.retry(intervals=None, infinite_retries=False, errors=None, log_message=None, prepare=None)¶
Retry a function if it fails with any Exception defined in “errors”.
Does so every x seconds, where x is defined by a list of numbers (ints or floats) in “intervals”. Also accepts ErrorCondition events for more detailed retry attempts.
- Parameters:
intervals (Optional[List]) – A list of times in seconds we keep retrying until returning failure. Defaults to retrying with the following exponential back-off before failing: 1s, 1s, 2s, 4s, 8s, 16s
infinite_retries (bool) – If this is True, reset the intervals when they run out. Defaults to: False.
errors (Optional[Sequence[Union[ErrorCondition, Type[Exception]]]]) –
A list of exceptions OR ErrorCondition objects to catch and retry on. ErrorCondition objects describe more detailed error event conditions than a plain error. An ErrorCondition specifies: - Exception (required) - Error codes that must match to be retried (optional; defaults to not checking) - A string that must be in the error message to be retried (optional; defaults to not checking) - A bool that can be set to False to always error on this condition.
If not specified, this will default to a generic Exception.
log_message (Optional[Tuple[Callable, str]]) – Optional tuple of (“log/print function()”, “message string”) that will precede each attempt.
prepare (Optional[List[Callable]]) – Optional list of functions to call, with the function’s arguments, between retries, to reset state.
- Returns:
The result of the wrapped function or raise.
- Return type:
Callable[[Callable[Ellipsis, RT]], Callable[Ellipsis, RT]]
- class toil.batchSystems.awsBatch.Resource¶
Bases:
namedtuple('Resource', ('name','pathHash','url','contentHash'))Represents a file or directory that will be deployed to each node before any jobs in the user script are invoked.
Each instance is a namedtuple with the following elements:
The pathHash element contains the MD5 (in hexdigest form) of the path to the resource on the leader node. The path, and therefore its hash is unique within a job store.
The url element is a “file:” or “http:” URL at which the resource can be obtained.
The contentHash element is an MD5 checksum of the resource, allowing for validation and caching of resources.
If the resource is a regular file, the type attribute will be ‘file’.
If the resource is a directory, the type attribute will be ‘dir’ and the URL will point at a ZIP archive of that directory.
- resourceEnvNamePrefix = 'JTRES_'¶
- rootDirPathEnvName¶
- classmethod create(jobStore, leaderPath)¶
Saves the content of the file or directory at the given path to the given job store and returns a resource object representing that content for the purpose of obtaining it again at a generic, public URL. This method should be invoked on the leader node.
- Parameters:
leaderPath (str)
- Return type:
- refresh(jobStore)¶
- Parameters:
- Return type:
- classmethod prepareSystem()¶
Prepares this system for the downloading and lookup of resources. This method should only be invoked on a worker node. It is idempotent but not thread-safe.
- Return type:
None
- classmethod cleanSystem()¶
Remove all downloaded, localized resources.
- Return type:
None
- register()¶
Register this resource for later retrieval via lookup(), possibly in a child process.
- Return type:
None
- classmethod lookup(leaderPath)¶
Return a resource object representing a resource created from a file or directory at the given path on the leader.
This method should be invoked on the worker. The given path does not need to refer to an existing file or directory on the worker, it only identifies the resource within an instance of toil. This method returns None if no resource for the given path exists.
- download(callback=None)¶
Download this resource from its URL to a file on the local system.
This method should only be invoked on a worker node after the node was setup for accessing resources via prepareSystem().
- Parameters:
callback (Optional[Callable[[str], None]])
- Return type:
None
- property localPath: str¶
- Abstractmethod:
- Return type:
Get the path to resource on the worker.
The file or directory at the returned path may or may not yet exist. Invoking download() will ensure that it does.
- toil.batchSystems.awsBatch.logger¶
- toil.batchSystems.awsBatch.STATE_TO_EXIT_REASON: Dict[str, toil.batchSystems.abstractBatchSystem.BatchJobExitReason]¶
- toil.batchSystems.awsBatch.MAX_POLL_COUNT = 100¶
- toil.batchSystems.awsBatch.MIN_REQUESTABLE_MIB = 4¶
- toil.batchSystems.awsBatch.MIN_REQUESTABLE_CORES = 1¶
- class toil.batchSystems.awsBatch.AWSBatchBatchSystem(config, maxCores, maxMemory, maxDisk)¶
Bases:
toil.batchSystems.cleanup_support.BatchSystemCleanupSupportAdds cleanup support when the last running job leaves a node, for batch systems that can’t provide it using the backing scheduler.
- Parameters:
config (toil.common.Config)
maxCores (float)
maxMemory (int)
maxDisk (int)
- classmethod supportsAutoDeployment()¶
Whether this batch system supports auto-deployment of the user script itself.
If it does, the
setUserScript()can be invoked to set the resource object representing the user script.Note to implementors: If your implementation returns True here, it should also override
- Return type:
- setUserScript(user_script)¶
Set the user script for this workflow.
This method must be called before the first job is issued to this batch system, and only if
supportsAutoDeployment()returns True, otherwise it will raise an exception.- Parameters:
userScript – the resource object representing the user script or module and the modules it depends on.
user_script (toil.resource.Resource)
- Return type:
None
- issueBatchJob(command, job_desc, job_environment=None)¶
Issues a job with the specified command to the batch system and returns a unique job ID number.
- Parameters:
command (str) – the command to execute somewhere to run the Toil worker process
job_desc (toil.job.JobDescription) – the JobDescription for the job being run
job_environment (Optional[Dict[str, str]]) – a collection of job-specific environment variables to be set on the worker.
- Returns:
a unique job ID number that can be used to reference the newly issued job
- Return type:
- getUpdatedBatchJob(maxWait)¶
Returns information about job that has updated its status (i.e. ceased running, either successfully or with an error). Each such job will be returned exactly once.
Does not return info for jobs killed by killBatchJobs, although they may cause None to be returned earlier than maxWait.
- Parameters:
maxWait (int) – the number of seconds to block, waiting for a result
- Returns:
If a result is available, returns UpdatedBatchJobInfo. Otherwise it returns None. wallTime is the number of seconds (a strictly positive float) in wall-clock time the job ran for, or None if this batch system does not support tracking wall time.
- Return type:
Optional[toil.batchSystems.abstractBatchSystem.UpdatedBatchJobInfo]
- shutdown()¶
Called at the completion of a toil invocation. Should cleanly terminate all worker threads.
- Return type:
None
- getIssuedBatchJobIDs()¶
Gets all currently issued jobs
- Returns:
A list of jobs (as job ID numbers) currently issued (may be running, or may be waiting to be run). Despite the result being a list, the ordering should not be depended upon.
- Return type:
List[int]
- getRunningBatchJobIDs()¶
Gets a map of jobs as job ID numbers that are currently running (not just waiting) and how long they have been running, in seconds.
- killBatchJobs(job_ids)¶
Kills the given job IDs. After returning, the killed jobs will not appear in the results of getRunningBatchJobIDs. The killed job will not be returned from getUpdatedBatchJob.
- Parameters:
jobIDs – list of IDs of jobs to kill
job_ids (List[int])
- Return type:
None
- classmethod add_options(parser)¶
If this batch system provides any command line options, add them to the given parser.
- Parameters:
parser (Union[argparse.ArgumentParser, argparse._ArgumentGroup])
- Return type:
None
- classmethod setOptions(setOption)¶
Process command line or configuration options relevant to this batch system.
- Parameters:
setOption (toil.batchSystems.options.OptionSetter) – A function with signature setOption(option_name, parsing_function=None, check_function=None, default=None, env=None) returning nothing, used to update run configuration as a side effect.
- Return type:
None