_id stringlengths 2 7 | title stringlengths 1 88 | partition stringclasses 3
values | text stringlengths 31 13.1k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q28800 | Leader.run | train | def run(self):
"""
This runs the leader process to issue and manage jobs.
:raises: toil.leader.FailedJobsException if at the end of function their remain \
failed jobs
:return: The return value of the root job's run function.
:rtype: Any
"""
# Start the ... | python | {
"resource": ""
} |
q28801 | Leader.create_status_sentinel_file | train | def create_status_sentinel_file(self, fail):
"""Create a file in the jobstore indicating failure or success."""
logName = 'failed.log' if fail else 'succeeded.log'
localLog = os.path.join(os.getcwd(), logName)
open(localLog, 'w').close()
| python | {
"resource": ""
} |
q28802 | Leader._checkSuccessorReadyToRunMultiplePredecessors | train | def _checkSuccessorReadyToRunMultiplePredecessors(self, jobGraph, jobNode, successorJobStoreID):
"""Handle the special cases of checking if a successor job is
ready to run when there are multiple predecessors"""
# See implementation note at the top of this file for discussion of multiple predece... | python | {
"resource": ""
} |
q28803 | Leader._makeJobSuccessorReadyToRun | train | def _makeJobSuccessorReadyToRun(self, jobGraph, jobNode):
"""make a successor job ready to run, returning False if they should
not yet be run"""
successorJobStoreID = jobNode.jobStoreID
#Build map from successor to predecessors.
if successorJobStoreID not in self.toilState.succes... | python | {
"resource": ""
} |
q28804 | Leader._processFailedSuccessors | train | def _processFailedSuccessors(self, jobGraph):
"""Some of the jobs successors failed then either fail the job
or restart it if it has retries left and is a checkpoint job"""
if jobGraph.jobStoreID in self.toilState.servicesIssued:
# The job has services running, signal for them to be... | python | {
"resource": ""
} |
q28805 | Leader._startServiceJobs | train | def _startServiceJobs(self):
"""Start any service jobs available from the service manager"""
self.issueQueingServiceJobs()
while True:
serviceJob = self.serviceManager.getServiceJobsToStart(0)
# Stop trying to get jobs when function returns None
if serviceJob | python | {
"resource": ""
} |
q28806 | Leader._processJobsWithRunningServices | train | def _processJobsWithRunningServices(self):
"""Get jobs whose services have started"""
while True:
jobGraph = self.serviceManager.getJobGraphWhoseServicesAreRunning(0)
if jobGraph is None: # Stop trying to get jobs when function returns None
| python | {
"resource": ""
} |
q28807 | Leader._gatherUpdatedJobs | train | def _gatherUpdatedJobs(self, updatedJobTuple):
"""Gather any new, updated jobGraph from the batch system"""
jobID, result, wallTime = updatedJobTuple
# easy, track different state
try:
updatedJob = self.jobBatchSystemIDToIssuedJob[jobID]
except KeyError:
l... | python | {
"resource": ""
} |
q28808 | Leader._processLostJobs | train | def _processLostJobs(self):
"""Process jobs that have gone awry"""
# In the case that there is nothing happening (no updated jobs to
# gather for rescueJobsFrequency seconds) check if there are any jobs
# that have run too long (see self.reissueOverLongJobs) or which have
# gone ... | python | {
"resource": ""
} |
q28809 | Leader.innerLoop | train | def innerLoop(self):
"""
The main loop for processing jobs by the leader.
"""
self.timeSinceJobsLastRescued = time.time()
while self.toilState.updatedJobs or \
self.getNumberOfJobsIssued() or \
self.serviceManager.jobsIssuedToServiceManager:
... | python | {
"resource": ""
} |
q28810 | Leader.checkForDeadlocks | train | def checkForDeadlocks(self):
"""
Checks if the system is deadlocked running service jobs.
"""
totalRunningJobs = len(self.batchSystem.getRunningBatchJobIDs())
totalServicesIssued = self.serviceJobsIssued + self.preemptableServiceJobsIssued
# If there are no updated jobs a... | python | {
"resource": ""
} |
q28811 | Leader.issueJob | train | def issueJob(self, jobNode):
"""Add a job to the queue of jobs."""
jobNode.command = ' '.join((resolveEntryPoint('_toil_worker'),
jobNode.jobName,
self.jobStoreLocator,
jobNode.jobStoreID))
... | python | {
"resource": ""
} |
q28812 | Leader.issueServiceJob | train | def issueServiceJob(self, jobNode):
"""
Issue a service job, putting it on a queue if the maximum number of service
jobs to be scheduled has been | python | {
"resource": ""
} |
q28813 | Leader.issueQueingServiceJobs | train | def issueQueingServiceJobs(self):
"""Issues any queuing service jobs up to the limit of the maximum allowed."""
while len(self.serviceJobsToBeIssued) > 0 and self.serviceJobsIssued < self.config.maxServiceJobs:
| python | {
"resource": ""
} |
q28814 | Leader.removeJob | train | def removeJob(self, jobBatchSystemID):
"""Removes a job from the system."""
assert jobBatchSystemID in self.jobBatchSystemIDToIssuedJob
jobNode = self.jobBatchSystemIDToIssuedJob[jobBatchSystemID]
if jobNode.preemptable:
# len(jobBatchSystemIDToIssuedJob) should always be gre... | python | {
"resource": ""
} |
q28815 | Leader.killJobs | train | def killJobs(self, jobsToKill):
"""
Kills the given set of jobs and then sends them for processing
"""
| python | {
"resource": ""
} |
q28816 | Leader.reissueOverLongJobs | train | def reissueOverLongJobs(self):
"""
Check each issued job - if it is running for longer than desirable
issue a kill instruction.
Wait for the job to die then we pass the job to processFinishedJob.
"""
maxJobDuration = self.config.maxJobDuration
jobsToKill = []
... | python | {
"resource": ""
} |
q28817 | Leader.processFinishedJob | train | def processFinishedJob(self, batchSystemID, resultStatus, wallTime=None):
"""
Function reads a processed jobGraph file and updates its state.
"""
jobNode = self.removeJob(batchSystemID)
jobStoreID = jobNode.jobStoreID
if wallTime is not None and self.clusterScaler is not ... | python | {
"resource": ""
} |
q28818 | Leader.getSuccessors | train | def getSuccessors(jobGraph, alreadySeenSuccessors, jobStore):
"""
Gets successors of the given job by walking the job graph recursively.
Any successor in alreadySeenSuccessors is ignored and not traversed.
Returns the set of found successors. This set is added to alreadySeenSuccessors.
... | python | {
"resource": ""
} |
q28819 | Leader.processTotallyFailedJob | train | def processTotallyFailedJob(self, jobGraph):
"""
Processes a totally failed job.
"""
# Mark job as a totally failed job
self.toilState.totalFailedJobs.add(JobNode.fromJobGraph(jobGraph))
if self.toilMetrics:
self.toilMetrics.logFailedJob(jobGraph)
if ... | python | {
"resource": ""
} |
q28820 | Leader._updatePredecessorStatus | train | def _updatePredecessorStatus(self, jobStoreID):
"""
Update status of predecessors for finished successor job.
"""
if jobStoreID in self.toilState.serviceJobStoreIDToPredecessorJob:
# Is a service job
predecessorJob = self.toilState.serviceJobStoreIDToPredecessorJo... | python | {
"resource": ""
} |
q28821 | simplify_list | train | def simplify_list(maybe_list):
"""Turn a length one list loaded by cwltool into a scalar.
Anything else is passed as-is, by reference."""
if isinstance(maybe_list, MutableSequence):
is_list | python | {
"resource": ""
} |
q28822 | toil_get_file | train | def toil_get_file(file_store, index, existing, file_store_id):
"""Get path to input file from Toil jobstore."""
if not file_store_id.startswith("toilfs:"):
return file_store.jobStore.getPublicUrl(file_store.jobStore.importFile(file_store_id))
| python | {
"resource": ""
} |
q28823 | write_file | train | def write_file(writeFunc, index, existing, x):
"""Write a file into the Toil jobstore.
'existing' is a set of files retrieved as inputs from toil_get_file. This
ensures they are mapped back as the same name if passed through.
"""
# Toil fileStore reference
if x.startswith("toilfs:"):
r... | python | {
"resource": ""
} |
q28824 | uploadFile | train | def uploadFile(uploadfunc, fileindex, existing, uf, skip_broken=False):
"""Update a file object so that the location is a reference to the toil file
store, writing it to the file store if necessary.
"""
if uf["location"].startswith("toilfs:") or uf["location"].startswith("_:"):
return
if u... | python | {
"resource": ""
} |
q28825 | toilStageFiles | train | def toilStageFiles(file_store, cwljob, outdir, index, existing, export,
destBucket=None):
"""Copy input files out of the global file store and update location and
path."""
def _collectDirEntries(obj):
# type: (Union[Dict[Text, Any], List[Dict[Text, Any]]]) -> Iterator[Dict[Text, Any]... | python | {
"resource": ""
} |
q28826 | _makeNestedTempDir | train | def _makeNestedTempDir(top, seed, levels=2):
"""
Gets a temporary directory in the hierarchy of directories under a given
top directory.
This exists to avoid placing too many temporary directories under a single
top in a flat structure, which can slow down metadata updates such as
deletes on th... | python | {
"resource": ""
} |
q28827 | remove_pickle_problems | train | def remove_pickle_problems(obj):
"""doc_loader does not pickle correctly, causing Toil errors, remove from
objects.
"""
if hasattr(obj, "doc_loader"):
obj.doc_loader = None
if hasattr(obj, "embedded_tool"): | python | {
"resource": ""
} |
q28828 | cleanTempDirs | train | def cleanTempDirs(job):
"""Remove temporarly created directories."""
if job is CWLJob and job._succeeded: # Only CWLJobs have this attribute.
for tempDir in job.openTempDirs:
| python | {
"resource": ""
} |
q28829 | StepValueFrom.do_eval | train | def do_eval(self, inputs, ctx):
"""Evalute ourselves."""
| python | {
"resource": ""
} |
q28830 | DefaultWithSource.resolve | train | def resolve(self):
"""Determine the final input value."""
if self.source:
result = self.source[1][self.source[0]]
| python | {
"resource": ""
} |
q28831 | find | train | def find(basedir, string):
"""
walk basedir and return all files matching string
"""
matches = []
for root, | python | {
"resource": ""
} |
q28832 | find_first_match | train | def find_first_match(basedir, string):
"""
return the first file that matches string | python | {
"resource": ""
} |
q28833 | tokenize_conf_stream | train | def tokenize_conf_stream(conf_handle):
"""
convert the key=val pairs in a LSF config stream to tuples of tokens
"""
for line in conf_handle: | python | {
"resource": ""
} |
q28834 | apply_bparams | train | def apply_bparams(fn):
"""
apply fn to each line of bparams, returning the result
"""
cmd = ["bparams", "-a"]
try:
output = | python | {
"resource": ""
} |
q28835 | apply_lsadmin | train | def apply_lsadmin(fn):
"""
apply fn to each line of lsadmin, returning the result
"""
cmd = ["lsadmin", "showconf", | python | {
"resource": ""
} |
q28836 | get_lsf_units | train | def get_lsf_units(resource=False):
"""
check if we can find LSF_UNITS_FOR_LIMITS in lsadmin and lsf.conf
files, preferring the value in bparams, then lsadmin, then the lsf.conf file
"""
lsf_units = apply_bparams(get_lsf_units_from_stream)
if lsf_units:
return lsf_units
lsf_units = a... | python | {
"resource": ""
} |
q28837 | parse_memory | train | def parse_memory(mem, resource):
"""
Parse memory parameter
"""
lsf_unit = | python | {
"resource": ""
} |
q28838 | per_core_reservation | train | def per_core_reservation():
"""
returns True if the cluster is configured for reservations to be per core,
False if it is per job
"""
per_core = apply_bparams(per_core_reserve_from_stream)
if per_core:
if per_core.upper() == "Y":
return True
else:
return F... | python | {
"resource": ""
} |
q28839 | addOptions | train | def addOptions(parser, config=Config()):
"""
Adds toil options to a parser object, either optparse or argparse.
"""
# Wrapper function that allows toil to be used with both the optparse and
# argparse option parsing modules
addLoggingOptions(parser) # This adds the logging stuff.
if isinsta... | python | {
"resource": ""
} |
q28840 | parseSetEnv | train | def parseSetEnv(l):
"""
Parses a list of strings of the form "NAME=VALUE" or just "NAME" into a dictionary. Strings
of the latter from will result in dictionary entries whose value is None.
:type l: list[str]
:rtype: dict[str,str]
>>> parseSetEnv([])
{}
>>> parseSetEnv(['a'])
{'a':... | python | {
"resource": ""
} |
q28841 | getDirSizeRecursively | train | def getDirSizeRecursively(dirPath):
"""
This method will return the cumulative number of bytes occupied by the files
on disk in the directory and its subdirectories.
This method will raise a 'subprocess.CalledProcessError' if it is unable to
access a folder or file because of insufficient permissio... | python | {
"resource": ""
} |
q28842 | getFileSystemSize | train | def getFileSystemSize(dirPath):
"""
Return the free space, and total size of the file system hosting `dirPath`.
:param str dirPath: A valid path to a directory.
:return: free space | python | {
"resource": ""
} |
q28843 | Toil.restart | train | def restart(self):
"""
Restarts a workflow that has been interrupted.
:return: The root job's return value
"""
self._assertContextManagerUsed()
self.writePIDFile()
if not self.config.restart:
raise ToilRestartException('A Toil workflow must be initiat... | python | {
"resource": ""
} |
q28844 | Toil.getJobStore | train | def getJobStore(cls, locator):
"""
Create an instance of the concrete job store implementation that matches the given locator.
:param str locator: The location of the job store to be represent by the instance
:return: an instance of a concrete subclass of AbstractJobStore
:rtyp... | python | {
"resource": ""
} |
q28845 | Toil.createBatchSystem | train | def createBatchSystem(config):
"""
Creates an instance of the batch system specified in the given config.
:param toil.common.Config config: the current configuration
:rtype: batchSystems.abstractBatchSystem.AbstractBatchSystem
:return: an instance of a concrete subclass of Abs... | python | {
"resource": ""
} |
q28846 | Toil._setupAutoDeployment | train | def _setupAutoDeployment(self, userScript=None):
"""
Determine the user script, save it to the job store and inject a reference to the saved
copy into the batch system such that it can auto-deploy the resource on the worker
nodes.
:param toil.resource.ModuleDescriptor userScript... | python | {
"resource": ""
} |
q28847 | Toil.importFile | train | def importFile(self, srcUrl, sharedFileName=None):
"""
Imports the file at the given URL into job store.
See :func:`toil.jobStores.abstractJobStore.AbstractJobStore.importFile` for a
full description
| python | {
"resource": ""
} |
q28848 | Toil._setBatchSystemEnvVars | train | def _setBatchSystemEnvVars(self):
"""
Sets the environment variables required by the job store and those passed on command line.
"""
| python | {
"resource": ""
} |
q28849 | Toil._serialiseEnv | train | def _serialiseEnv(self):
"""
Puts the environment in a globally accessible pickle file.
"""
# Dump out the environment of this process in the environment pickle file.
with self._jobStore.writeSharedFileStream("environment.pickle") as fileHandle:
| python | {
"resource": ""
} |
q28850 | Toil._cacheAllJobs | train | def _cacheAllJobs(self):
"""
Downloads all jobs in the current job store into self.jobCache.
"""
logger.debug('Caching all jobs in job store')
self._jobCache = {jobGraph.jobStoreID: jobGraph for | python | {
"resource": ""
} |
q28851 | Toil.getWorkflowDir | train | def getWorkflowDir(workflowID, configWorkDir=None):
"""
Returns a path to the directory where worker directories and the cache will be located
for this workflow.
:param str workflowID: Unique identifier for the workflow
:param str configWorkDir: Value passed to the program using... | python | {
"resource": ""
} |
q28852 | Toil._shutdownBatchSystem | train | def _shutdownBatchSystem(self):
"""
Shuts down current batch system if it has been created.
"""
assert self._batchSystem is not None
| python | {
"resource": ""
} |
q28853 | Toil.writePIDFile | train | def writePIDFile(self):
"""
Write a the pid of this process to a file in the jobstore.
Overwriting the current contents of pid.log is a feature, not a bug of this method.
Other methods will rely on always having the most current pid available.
So far there is no reason to | python | {
"resource": ""
} |
q28854 | AnalyzeWDL.find_asts | train | def find_asts(self, ast_root, name):
'''
Finds an AST node with the given name and the entire subtree under it.
A function borrowed from scottfrazer. Thank you Scott Frazer!
:param ast_root: The WDL AST. The whole thing generally, but really
any portion that y... | python | {
"resource": ""
} |
q28855 | AnalyzeWDL.dict_from_JSON | train | def dict_from_JSON(self, JSON_file):
'''
Takes a WDL-mapped json file and creates a dict containing the bindings.
The 'return' value is only used for unittests.
:param JSON_file: A required JSON file containing WDL variable bindings.
:return: Returns the self.json_dict purely fo... | python | {
"resource": ""
} |
q28856 | AnalyzeWDL.create_tasks_dict | train | def create_tasks_dict(self, ast):
'''
Parse each "Task" in the AST. This will create self.tasks_dictionary,
where each task name is a key.
:return: Creates the self.tasks_dictionary necessary for much of the
parser. Returning it is only necessary for unittests.
'''
| python | {
"resource": ""
} |
q28857 | AnalyzeWDL.parse_task | train | def parse_task(self, task):
'''
Parses a WDL task AST subtree.
Currently looks at and parses 4 sections:
1. Declarations (e.g. string x = 'helloworld')
2. Commandline (a bash command with dynamic variables inserted)
3. Runtime (docker image; disk; CPU; RAM; etc.)
... | python | {
"resource": ""
} |
q28858 | AnalyzeWDL.parse_task_declaration | train | def parse_task_declaration(self, declaration_subAST):
'''
Parses the declaration section of the WDL task AST subtree.
Examples:
String my_name
String your_name
Int two_chains_i_mean_names = 0
:param declaration_subAST: Some subAST representing a task declaratio... | python | {
"resource": ""
} |
q28859 | AnalyzeWDL.parse_task_rawcommand | train | def parse_task_rawcommand(self, rawcommand_subAST):
'''
Parses the rawcommand section of the WDL task AST subtree.
Task "rawcommands" are divided into many parts. There are 2 types of
parts: normal strings, & variables that can serve as changeable inputs.
The following example... | python | {
"resource": ""
} |
q28860 | AnalyzeWDL.parse_task_runtime | train | def parse_task_runtime(self, runtime_subAST):
'''
Parses the runtime section of the WDL task AST subtree.
The task "runtime" section currently supports context fields for a
docker container, CPU resources, RAM resources, and disk resources.
:param runtime_subAST: A subAST repre... | python | {
"resource": ""
} |
q28861 | AnalyzeWDL.parse_task_outputs | train | def parse_task_outputs(self, i):
'''
Parse the WDL output section.
Outputs are like declarations, with a type, name, and value. Examples:
------------
Simple Cases
------------
'Int num = 7'
var_name: 'num'
var_type: 'Int'
v... | python | {
"resource": ""
} |
q28862 | AnalyzeWDL.parse_workflow | train | def parse_workflow(self, workflow):
'''
Parses a WDL workflow AST subtree.
Currently looks at and parses 3 sections:
1. Declarations (e.g. string x = 'helloworld')
2. Calls (similar to a python def)
3. Scatter (which expects to map to a Call or multiple Calls)
R... | python | {
"resource": ""
} |
q28863 | AnalyzeWDL.parse_declaration_expressn_ternaryif | train | def parse_declaration_expressn_ternaryif(self, cond, iftrue, iffalse, es):
"""
Classic if statement. This needs to be rearranged.
In wdl, this looks like:
if <condition> then <iftrue> else <iffalse>
In python, this needs to be:
<iftrue> if <condition> else <iffalse>
... | python | {
"resource": ""
} |
q28864 | AnalyzeWDL.parse_declaration_expressn_tupleliteral | train | def parse_declaration_expressn_tupleliteral(self, values, es):
"""
Same in python. Just a parenthesis enclosed tuple.
:param values:
| python | {
"resource": ""
} |
q28865 | AnalyzeWDL.parse_declaration_expressn_arrayliteral | train | def parse_declaration_expressn_arrayliteral(self, values, es):
"""
Same in python. Just a square bracket enclosed array.
:param values:
| python | {
"resource": ""
} |
q28866 | AnalyzeWDL.parse_declaration_expressn_operator | train | def parse_declaration_expressn_operator(self, lhsAST, rhsAST, es, operator):
"""
Simply joins the left and right hand arguments lhs and rhs with an operator.
:param lhsAST:
:param rhsAST:
:param es:
:param operator:
:return:
"""
if isinstance(lhsA... | python | {
"resource": ""
} |
q28867 | AnalyzeWDL.parse_declaration_expressn_fncall | train | def parse_declaration_expressn_fncall(self, name, params, es):
"""
Parses out cromwell's built-in function calls.
Some of these are special
and need minor adjustments, for example length(), which is equivalent to
python's len() function. Or sub, which is equivalent to re.sub(),... | python | {
"resource": ""
} |
q28868 | AnalyzeWDL.parse_workflow_declaration | train | def parse_workflow_declaration(self, wf_declaration_subAST):
'''
Parses a WDL declaration AST subtree into a string and a python
dictionary containing its 'type' and 'value'.
For example:
var_name = refIndex
var_map = {'type': File,
'value': bamIndex}
... | python | {
"resource": ""
} |
q28869 | AWSJobStore._registered | train | def _registered(self):
"""
A optional boolean property indidcating whether this job store is registered. The
registry is the authority on deciding if a job store exists or not. If True, this job
store exists, if None the job store is transitioning from True to False or vice versa,
... | python | {
"resource": ""
} |
q28870 | AWSJobStore._bindBucket | train | def _bindBucket(self, bucket_name, create=False, block=True, versioning=False):
"""
Return the Boto Bucket object representing the S3 bucket with the given name. If the
bucket does not exist and `create` is True, it will be created.
:param str bucket_name: the name of the bucket to bind... | python | {
"resource": ""
} |
q28871 | AWSJobStore._bindDomain | train | def _bindDomain(self, domain_name, create=False, block=True):
"""
Return the Boto Domain object representing the SDB domain of the given name. If the
domain does not exist and `create` is True, it will be created.
:param str domain_name: the name of the domain to bind to
:param... | python | {
"resource": ""
} |
q28872 | AWSJobStore.__getBucketVersioning | train | def __getBucketVersioning(self, bucket):
"""
For newly created buckets get_versioning_status returns an empty dict. In the past we've
seen None in this case. We map both to a return value of False.
Otherwise, the 'Versioning' entry in the dictionary returned by get_versioning_status can... | python | {
"resource": ""
} |
q28873 | flatten | train | def flatten( iterables ):
""" Flatten an iterable, except for string elements. """
for it in iterables:
if isinstance(it, str):
| python | {
"resource": ""
} |
q28874 | BatchSystemSupport.checkResourceRequest | train | def checkResourceRequest(self, memory, cores, disk):
"""
Check resource request is not greater than that available or allowed.
:param int memory: amount of memory being requested, in bytes
:param float cores: number of cores being requested
:param int disk: amount of disk spac... | python | {
"resource": ""
} |
q28875 | BatchSystemLocalSupport.handleLocalJob | train | def handleLocalJob(self, jobNode): # type: (JobNode) -> Optional[int]
"""
To be called by issueBatchJobs.
Returns the jobID if the jobNode has been submitted to the local queue,
otherwise returns None
"""
if (not self.config.runCwlInternalJobsOnWorkers
| python | {
"resource": ""
} |
q28876 | BatchSystemLocalSupport.getNextJobID | train | def getNextJobID(self): # type: () -> int
"""
Must be used to get job IDs so that the local and batch jobs do not
conflict.
"""
with self.localBatch.jobIndexLock:
| python | {
"resource": ""
} |
q28877 | shutdownFileStore | train | def shutdownFileStore(workflowDir, workflowID):
"""
Run the deferred functions from any prematurely terminated jobs still lingering on the system
and carry out any necessary filestore-specific cleanup.
This is a destructive operation and it is important to ensure that there are no other running
pro... | python | {
"resource": ""
} |
q28878 | DeferredFunction.create | train | def create(cls, function, *args, **kwargs):
"""
Capture the given callable and arguments as an instance of this class.
:param callable function: The deferred action to take in the form of a function
:param tuple args: Non-keyword arguments to the function
:param dict kwargs: Key... | python | {
"resource": ""
} |
q28879 | DeferredFunction.invoke | train | def invoke(self):
"""
Invoke the captured function with the captured arguments.
"""
logger.debug('Running deferred function %s.', self)
self.module.makeLoadable()
| python | {
"resource": ""
} |
q28880 | FileStore.getLocalTempDir | train | def getLocalTempDir(self):
"""
Get a new local temporary directory in which to write files that persist for the duration of
the job.
:return: The absolute path to a new local temporary directory. This directory will exist
for the duration of the job only, and is guarant... | python | {
"resource": ""
} |
q28881 | FileStore.getLocalTempFile | train | def getLocalTempFile(self):
"""
Get a new local temporary file that will persist for the duration of the job.
:return: The absolute path to a local temporary file. This file will exist for the
duration of the job only, and is guaranteed to be deleted once the job terminates.
| python | {
"resource": ""
} |
q28882 | FileStore.writeGlobalFileStream | train | def writeGlobalFileStream(self, cleanup=False):
"""
Similar to writeGlobalFile, but allows the writing of a stream to the job store.
The yielded file handle does not need to and should not be closed explicitly.
:param bool cleanup: is as in :func:`toil.fileStore.FileStore.writeGlobalFil... | python | {
"resource": ""
} |
q28883 | FileStore.readGlobalFile | train | def readGlobalFile(self, fileStoreID, userPath=None, cache=True, mutable=False, symlink=False):
"""
Makes the file associated with fileStoreID available locally. If mutable is True,
then a copy of the file will be created locally so that the original is not modified
and does not change t... | python | {
"resource": ""
} |
q28884 | FileStore._runDeferredFunctions | train | def _runDeferredFunctions(deferredFunctions):
"""
Invoke the specified deferred functions and return a list of names of functions that
raised an exception while being invoked.
:param list[DeferredFunction] deferredFunctions: the DeferredFunctions to run
:rtype: list[str]
... | python | {
"resource": ""
} |
q28885 | FileStore.logToMaster | train | def logToMaster(self, text, level=logging.INFO):
"""
Send a logging message to the leader. The message will also be \
logged by the worker at the same level.
:param text: The string to log.
:param int level: The logging level.
| python | {
"resource": ""
} |
q28886 | FileStore._pidExists | train | def _pidExists(pid):
"""
This will return True if the process associated with pid is still running on the machine.
This is based on stackoverflow question 568271.
:param int pid: ID of the process to check for
:return: True/False
:rtype: bool
"""
assert p... | python | {
"resource": ""
} |
q28887 | CachingFileStore.open | train | def open(self, job):
"""
This context manager decorated method allows cache-specific operations to be conducted
before and after the execution of a job in worker.py
"""
# Create a working directory for the job
startingDir = os.getcwd()
self.localTempDir = makePubl... | python | {
"resource": ""
} |
q28888 | CachingFileStore._setupCache | train | def _setupCache(self):
"""
Setup the cache based on the provided values for localCacheDir.
"""
# we first check whether the cache directory exists. If it doesn't, create it.
if not os.path.exists(self.localCacheDir):
# Create a temporary directory as this worker's pri... | python | {
"resource": ""
} |
q28889 | CachingFileStore._createCacheLockFile | train | def _createCacheLockFile(self, tempCacheDir):
"""
Create the cache lock file file to contain the state of the cache on the node.
:param str tempCacheDir: Temporary directory to use for setting up a cache lock file the
first time.
"""
# The nlink threshold is setup... | python | {
"resource": ""
} |
q28890 | CachingFileStore.decodedFileID | train | def decodedFileID(self, cachedFilePath):
"""
Decode a cached fileName back to a job store file ID.
:param str cachedFilePath: Path to the cached file
:return: The jobstore file ID associated with the file
:rtype: str
"""
fileDir, fileName = os.path.split(cachedFi... | python | {
"resource": ""
} |
q28891 | CachingFileStore.addToCache | train | def addToCache(self, localFilePath, jobStoreFileID, callingFunc, mutable=False):
"""
Used to process the caching of a file. This depends on whether a file is being written
to file store, or read from it.
WRITING
The file is in localTempDir. It needs to be linked into cache if pos... | python | {
"resource": ""
} |
q28892 | CachingFileStore.cleanCache | train | def cleanCache(self, newJobReqs):
"""
Cleanup all files in the cache directory to ensure that at lead newJobReqs are available
for use.
:param float newJobReqs: the total number of bytes of files allowed in the cache.
"""
with self._CacheState.open(self) as cacheInfo:
... | python | {
"resource": ""
} |
q28893 | CachingFileStore.removeSingleCachedFile | train | def removeSingleCachedFile(self, fileStoreID):
"""
Removes a single file described by the fileStoreID from the cache forcibly.
"""
with self._CacheState.open(self) as cacheInfo:
cachedFile = self.encodedFileID(fileStoreID)
cachedFileStats = os.stat(cachedFile)
... | python | {
"resource": ""
} |
q28894 | CachingFileStore._accountForNlinkEquals2 | train | def _accountForNlinkEquals2(self, localFilePath):
"""
This is a utility function that accounts for the fact that if nlinkThreshold == 2, the
size of the file is accounted for by the file store copy of the file and thus the file
size shouldn't be added to the cached file sizes.
| python | {
"resource": ""
} |
q28895 | CachingFileStore.returnJobReqs | train | def returnJobReqs(self, jobReqs):
"""
This function returns the effective job requirements back to the pool after the job
completes. It also deletes the local copies of files with the cache lock held.
:param float jobReqs: Original size requirement of the job
"""
# Since... | python | {
"resource": ""
} |
q28896 | CachingFileStore.asyncWrite | train | def asyncWrite(self):
"""
A function to write files asynchronously to the job store such that subsequent jobs are
not delayed by a long write operation.
"""
try:
while True:
try:
# Block for up to two seconds waiting for a file
... | python | {
"resource": ""
} |
q28897 | CachingFileStore._updateJobWhenDone | train | def _updateJobWhenDone(self):
"""
Asynchronously update the status of the job on the disk, first waiting \
until the writing threads have finished and the input blockFn has stopped \
blocking.
"""
def asyncUpdate():
try:
# Wait till all file w... | python | {
"resource": ""
} |
q28898 | NonCachingFileStore._getAllJobStates | train | def _getAllJobStates(workflowDir):
"""
Generator function that deserializes and yields the job state for every job on the node,
one at a time.
:param str workflowDir: The location of the workflow directory on the node.
:return: dict with keys (jobName, jobPID, jobDir, deferredF... | python | {
"resource": ""
} |
q28899 | NonCachingFileStore._createJobStateFile | train | def _createJobStateFile(self):
"""
Create the job state file for the current job and fill in the required
values.
:return: Path to the job state file
:rtype: str
"""
jobStateFile = os.path.join(self.localTempDir, '.jobState')
jobState = {'jobPID': os.getp... | python | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.