def workerCleanup(info): """ Cleans up the worker node on batch system shutdown. Also see :meth:`supportsWorkerCleanup`. :param WorkerCleanupInfo info: A named tuple consisting of all the relevant information for cleaning up the worker. """ assert isinstance(info, WorkerCleanupInfo) workflowDir = Toil.getWorkflowDir(info.workflowID, info.workDir) workflowDirContents = os.listdir(workflowDir) shutdownCache(os.path.join(workflowDir, cacheDirName(info.workflowID))) if (info.cleanWorkDir == 'always' or info.cleanWorkDir in ('onSuccess', 'onError') and workflowDirContents in ([], [cacheDirName(info.workflowID)])): shutil.rmtree(workflowDir)
def workerCleanup(info): """ Cleans up the worker node on batch system shutdown. Also see :meth:`supportsWorkerCleanup`. :param WorkerCleanupInfo info: A named tuple consisting of all the relevant information for cleaning up the worker. """ assert isinstance(info, WorkerCleanupInfo) workflowDir = Toil.getWorkflowDir(info.workflowID, info.workDir) workflowDirContents = os.listdir(workflowDir) shutdownCache(os.path.join(workflowDir, cacheDirName(info.workflowID))) if (info.cleanWorkDir == 'always' or info.cleanWorkDir in ('onSuccess', 'onError') and workflowDirContents in ([], [cacheDirName(info.workflowID)])): shutil.rmtree(workflowDir)
def shutdownFileStore(workflowDir, workflowID): """ Carry out any necessary filestore-specific cleanup. This is a destructive operation and it is important to ensure that there are no other running processes on the system that are modifying or using the file store for this workflow. This is the intended to be the last call to the file store in a Toil run, called by the batch system cleanup function upon batch system shutdown. :param str workflowDir: The path to the cache directory :param str workflowID: The workflow ID for this invocation of the workflow """ # Defer these imports until runtime, since these classes depend on our file from toil.fileStores.cachingFileStore import CachingFileStore from toil.fileStores.nonCachingFileStore import NonCachingFileStore cacheDir = os.path.join(workflowDir, cacheDirName(workflowID)) if os.path.exists(cacheDir): # The presence of the cacheDir suggests this was a cached run. We don't need the cache lock # for any of this since this is the final cleanup of a job and there should be no other # conflicting processes using the cache. CachingFileStore.shutdown(cacheDir) else: # This absence of cacheDir suggests otherwise. NonCachingFileStore.shutdown(workflowDir)
def workerCleanup(info): """ Cleans up the worker node on batch system shutdown. Also see :meth:`supportsWorkerCleanup`. :param WorkerCleanupInfo info: A named tuple consisting of all the relevant information for cleaning up the worker. """ assert isinstance(info, WorkerCleanupInfo) workflowDir = Toil.getLocalWorkflowDir(info.workflowID, info.workDir) DeferredFunctionManager.cleanupWorker(workflowDir) workflowDirContents = os.listdir(workflowDir) AbstractFileStore.shutdownFileStore(workflowDir, info.workflowID) if (info.cleanWorkDir == 'always' or info.cleanWorkDir in ('onSuccess', 'onError') and workflowDirContents in ([], [cacheDirName(info.workflowID)])): shutil.rmtree(workflowDir, ignore_errors=True)