# Buggy code
def restart(self):
    """
    Restarts a workflow that has been interrupted. This method should be called if and only
    if a workflow has previously been started and has not finished.

    :return: The root job's return value
    """
    self._assertContextManagerUsed()
    if not self.config.restart:
        raise ToilRestartException(
            "A Toil workflow must be initiated with Toil.start(), not restart()."
        )

    self._batchSystem = self.createBatchSystem(self.config, jobStore=self._jobStore)
    try:
        self._setBatchSystemEnvVars()
        self._serialiseEnv()
        self._cacheAllJobs()
        self._setProvisioner()
        rootJob = self._jobStore.clean(jobCache=self._jobCache)
        return self._runMainLoop(rootJob)
    finally:
        self._shutdownBatchSystem()


# Traceback (ImportError)
WARNING:toil.leader:fc48619f_e141_4211_8ab9_3004f95b16df:   ---TOIL WORKER OUTPUT LOG---
WARNING:toil.leader:fc48619f_e141_4211_8ab9_3004f95b16df:   Next available file descriptor: 10
WARNING:toil.leader:fc48619f_e141_4211_8ab9_3004f95b16df:   DEBUG:toil.worker:Next available file descriptor: 10
WARNING:toil.leader:fc48619f_e141_4211_8ab9_3004f95b16df:   DEBUG:urllib3.connectionpool:Setting read timeout to 65
WARNING:toil.leader:fc48619f_e141_4211_8ab9_3004f95b16df:   DEBUG:urllib3.connectionpool:"GET /acmarkellotoilvgjobstore11xxjobitems(PartitionKey='default',RowKey='fc48619f_e141_4211_8ab9_3004f95b16df')?$select= HTTP/1.1" 200 None
WARNING:toil.leader:fc48619f_e141_4211_8ab9_3004f95b16df:   Parsed jobWrapper
WARNING:toil.leader:fc48619f_e141_4211_8ab9_3004f95b16df:   DEBUG:toil.worker:Parsed jobWrapper
WARNING:toil.leader:fc48619f_e141_4211_8ab9_3004f95b16df:   Got a command to run: _toil b5feca2d_3cbf_46a6_81cc_43d5f3a43cb6 /home/cmarkello/toilvenv/local/lib/python2.7/site-packages toil_vg.vg_evaluation_pipeline
WARNING:toil.leader:fc48619f_e141_4211_8ab9_3004f95b16df:   DEBUG:toil.worker:Got a command to run: _toil b5feca2d_3cbf_46a6_81cc_43d5f3a43cb6 /home/cmarkello/toilvenv/local/lib/python2.7/site-packages toil_vg.vg_evaluation_pipeline
WARNING:toil.leader:fc48619f_e141_4211_8ab9_3004f95b16df:   DEBUG:toil.job:Loading user module ModuleDescriptor(dirPath='/home/cmarkello/toilvenv/local/lib/python2.7/site-packages', name='toil_vg.vg_evaluation_pipeline').
WARNING:toil.leader:fc48619f_e141_4211_8ab9_3004f95b16df:   WARNING:toil.resource:Can't find resource for leader path '/home/cmarkello/toilvenv/local/lib/python2.7/site-packages/toil_vg'
WARNING:toil.leader:fc48619f_e141_4211_8ab9_3004f95b16df:   WARNING:toil.resource:Can't localize module ModuleDescriptor(dirPath='/home/cmarkello/toilvenv/local/lib/python2.7/site-packages', name='toil_vg.vg_evaluation_pipeline')
WARNING:toil.leader:fc48619f_e141_4211_8ab9_3004f95b16df:   ERROR:toil.job:Failed to import user module ModuleDescriptor(dirPath='/home/cmarkello/toilvenv/local/lib/python2.7/site-packages', name='toil_vg.vg_evaluation_pipeline') from sys.path=['/home/cmarkello/toilvenv/bin', '/home/cmarkello/toilvenv/lib/python2.7', '/home/cmarkello/toilvenv/lib/python2.7/plat-x86_64-linux-gnu', '/home/cmarkello/toilvenv/lib/python2.7/lib-tk', '/home/cmarkello/toilvenv/lib/python2.7/lib-old', '/home/cmarkello/toilvenv/lib/python2.7/lib-dynload', '/usr/lib/python2.7', '/usr/lib/python2.7/plat-x86_64-linux-gnu', '/usr/lib/python2.7/lib-tk', '/home/cmarkello/toilvenv/local/lib/python2.7/site-packages', '/home/cmarkello/toil/src', '/home/cmarkello/toilvenv/lib/python2.7/site-packages', '/usr/local/lib/python2.7/dist-packages/mesos.interface-0.22.0-py2.7.egg', '/usr/local/lib/python2.7/dist-packages/mesos-0.22.0-py2.7-linux-x86_64.egg', '/home/cmarkello/toil-scripts/src', '/usr/local/lib/python2.7/site-packages', '/usr/local/lib/python2.7/dist-packages', '/usr/lib/python2.7/site-packages', '/usr/lib/python2.7/dist-packages']
WARNING:toil.leader:fc48619f_e141_4211_8ab9_3004f95b16df:   Traceback (most recent call last):
WARNING:toil.leader:fc48619f_e141_4211_8ab9_3004f95b16df:     File "/home/cmarkello/toil/src/toil/worker.py", line 316, in main
WARNING:toil.leader:fc48619f_e141_4211_8ab9_3004f95b16df:       job = Job._loadJob(jobWrapper.command, jobStore)
WARNING:toil.leader:fc48619f_e141_4211_8ab9_3004f95b16df:     File "/home/cmarkello/toil/src/toil/job.py", line 666, in _loadJob
WARNING:toil.leader:fc48619f_e141_4211_8ab9_3004f95b16df:       userModule = cls._loadUserModule(userModule)
WARNING:toil.leader:fc48619f_e141_4211_8ab9_3004f95b16df:     File "/home/cmarkello/toil/src/toil/job.py", line 640, in _loadUserModuleWARNING:toil.leader:fc48619f_e141_4211_8ab9_3004f95b16df:       return importlib.import_module(userModule.name)
WARNING:toil.leader:fc48619f_e141_4211_8ab9_3004f95b16df:     File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
WARNING:toil.leader:fc48619f_e141_4211_8ab9_3004f95b16df:       __import__(name)
WARNING:toil.leader:fc48619f_e141_4211_8ab9_3004f95b16df:   ImportError: No module named toil_vg.vg_evaluation_pipeline
WARNING:toil.leader:fc48619f_e141_4211_8ab9_3004f95b16df:   Exiting the worker because of a failed jobWrapper on host c1agent3
WARNING:toil.leader:fc48619f_e141_4211_8ab9_3004f95b16df:   ERROR:toil.worker:Exiting the worker because of a failed jobWrapper on host c1agent3
WARNING:toil.leader:fc48619f_e141_4211_8ab9_3004f95b16df:   DEBUG:urllib3.connectionpool:Setting read timeout to 65
WARNING:toil.leader:fc48619f_e141_4211_8ab9_3004f95b16df:   DEBUG:urllib3.connectionpool:"GET /acmarkellotoilvgjobstore11xxjobitems(PartitionKey='default',RowKey='fc48619f_e141_4211_8ab9_3004f95b16df')?$select= HTTP/1.1" 200 None
WARNING:toil.leader:fc48619f_e141_4211_8ab9_3004f95b16df:   WARNING:toil.jobWrapper:Due to failure we are reducing the remaining retry count of job fc48619f_e141_4211_8ab9_3004f95b16df to 0

# Fixed code
def restart(self):
    """
    Restarts a workflow that has been interrupted. This method should be called if and only
    if a workflow has previously been started and has not finished.

    :return: The root job's return value
    """
    self._assertContextManagerUsed()
    if not self.config.restart:
        raise ToilRestartException(
            "A Toil workflow must be initiated with Toil.start(), not restart()."
        )

    self._batchSystem = self.createBatchSystem(self.config)
    self._setupHotDeployment()
    try:
        self._setBatchSystemEnvVars()
        self._serialiseEnv()
        self._cacheAllJobs()
        self._setProvisioner()
        rootJob = self._jobStore.clean(jobCache=self._jobCache)
        return self._runMainLoop(rootJob)
    finally:
        self._shutdownBatchSystem()