# Buggy code
def globalize(self):
    try:
        with open(os.path.join(self.dirPath, ".original")) as f:
            return self.__class__(*json.loads(f.read()))
    except IOError as e:
        if e.errno == errno.ENOENT:
            log.warn("Can't globalize module %r.", self)
            return self
        else:
            raise


# Traceback (ImportError)
INFO:toil.batchSystems.mesos.batchSystem:Preparing to launch Mesos task 0 using offer 20151120-222317-83886090-5050-35148-O5...
INFO:toil.batchSystems.mesos.batchSystem:...launching Mesos task 0
WARNING:toil.leader:The jobWrapper seems to have left a log file, indicating failure: 46c1efec_0849_4ce3_b74d_c74f1f0602a4
WARNING:toil.leader:Reporting file: 46c1efec_0849_4ce3_b74d_c74f1f0602a4
WARNING:toil.leader:46c1efec_0849_4ce3_b74d_c74f1f0602a4:       ---TOIL WORKER OUTPUT LOG---
WARNING:toil.leader:46c1efec_0849_4ce3_b74d_c74f1f0602a4:       Traceback (most recent call last):
WARNING:toil.leader:46c1efec_0849_4ce3_b74d_c74f1f0602a4:         File "/usr/local/lib/python2.7/dist-packages/toil/worker.py", line
266, in main
WARNING:toil.leader:46c1efec_0849_4ce3_b74d_c74f1f0602a4:           job = Job._loadJob(jobWrapper.command, jobStore)
WARNING:toil.leader:46c1efec_0849_4ce3_b74d_c74f1f0602a4:         File "/usr/local/lib/python2.7/dist-packages/toil/job.py", line 936, in _loadJob
WARNING:toil.leader:46c1efec_0849_4ce3_b74d_c74f1f0602a4:           userModule = cls._loadUserModule(userModule)
WARNING:toil.leader:46c1efec_0849_4ce3_b74d_c74f1f0602a4:         File "/usr/local/lib/python2.7/dist-packages/toil/job.py", line 914, in _loadUserModule
WARNING:toil.leader:46c1efec_0849_4ce3_b74d_c74f1f0602a4:           return importlib.import_module(userModule.name)
WARNING:toil.leader:46c1efec_0849_4ce3_b74d_c74f1f0602a4:         File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
WARNING:toil.leader:46c1efec_0849_4ce3_b74d_c74f1f0602a4:           __import__(name)
WARNING:toil.leader:46c1efec_0849_4ce3_b74d_c74f1f0602a4:         File "/tmp/tmpflu3Jl/5b3f3d5ba2a95124e308998df2ab7bb2/parallelMappingEvaluation.py", line 16, in <module>
WARNING:toil.leader:46c1efec_0849_4ce3_b74d_c74f1f0602a4:           from toillib import *
WARNING:toil.leader:46c1efec_0849_4ce3_b74d_c74f1f0602a4:       ImportError: No module named toillib
WARNING:toil.leader:46c1efec_0849_4ce3_b74d_c74f1f0602a4:       Exiting the worker because of a failed jobWrapper on host c4agent1
WARNING:toil.leader:46c1efec_0849_4ce3_b74d_c74f1f0602a4:       ERROR:toil.worker:Exiting the worker because of a failed jobWrapper on host c4agent1
WARNING:toil.leader:46c1efec_0849_4ce3_b74d_c74f1f0602a4:       WARNING:toil.jobWrapper:Due to failure we are reducing the remaining retry count of job 46c1efec_0849_4ce3_b74d_c74f1f0602a4 to 0
WARNING:toil.leader:Job: 46c1efec_0849_4ce3_b74d_c74f1f0602a4 is completely failed

# Fixed code
def globalize(self):
    """
    Reverse the effect of localize().
    """
    try:
        with open(os.path.join(self.dirPath, ".original")) as f:
            return self.__class__(*json.loads(f.read()))
    except IOError as e:
        if e.errno == errno.ENOENT:
            if self._runningOnWorker():
                log.warn("Can't globalize module %r.", self)
            return self
        else:
            raise