# Buggy code
def _loadUserModule(cls, userModule):
    """
    Imports and returns the module object represented by the given module descriptor.

    :type userModule: ModuleDescriptor
    """
    if not userModule.belongsToToil:
        userModule = userModule.localize()
    if userModule.dirPath not in sys.path:
        sys.path.append(userModule.dirPath)
    try:
        return importlib.import_module(userModule.name)
    except ImportError:
        logger.error(
            "Failed to import user module %r from sys.path=%r", userModule, sys.path
        )
        raise


# Traceback (ImportError)
---TOIL WORKER OUTPUT LOG---
f006bc8b-195a-45b8-8e35-2291a2985f14    Next available file descriptor: 8
f006bc8b-195a-45b8-8e35-2291a2985f14    DEBUG:toil.worker:Next available file descriptor: 8
f006bc8b-195a-45b8-8e35-2291a2985f14    DEBUG:toil.jobStores.aws.jobStore:Loaded job f006bc8b-195a-45b8-8e35-2291a2985f14
f006bc8b-195a-45b8-8e35-2291a2985f14    Parsed jobWrapper
f006bc8b-195a-45b8-8e35-2291a2985f14    DEBUG:toil.worker:Parsed jobWrapper
f006bc8b-195a-45b8-8e35-2291a2985f14    Got a command to run: _toil d171ba6d-1842-4f3e-998a-84c3d11cee59 /usr/local/lib/python2.7/dist-packages toil.job False
f006bc8b-195a-45b8-8e35-2291a2985f14    DEBUG:toil.worker:Got a command to run: _toil d171ba6d-1842-4f3e-998a-84c3d11cee59 /usr/local/lib/python2.7/dist-packages toil.job Fals
f006bc8b-195a-45b8-8e35-2291a2985f14    DEBUG:toil.job:Loading user module ModuleDescriptor(dirPath='/usr/local/lib/python2.7/dist-packages', name='toil.job', fromVirtualEnv=F
f006bc8b-195a-45b8-8e35-2291a2985f14    DEBUG:toil.jobStores.aws.jobStore:Reading FileInfo(fileID='d171ba6d-1842-4f3e-998a-84c3d11cee59', ownerID='96b4d6f2-1b56-48f5-b1c4-9f0d
f006bc8b-195a-45b8-8e35-2291a2985f14    DEBUG:toil.job:Getting Job from module toil.job.
f006bc8b-195a-45b8-8e35-2291a2985f14    DEBUG:toil.job:Getting Config from module toil.common.
f006bc8b-195a-45b8-8e35-2291a2985f14    DEBUG:toil.job:Getting defaultdict from module collections.
f006bc8b-195a-45b8-8e35-2291a2985f14    DEBUG:toil.job:Getting list from module __builtin__.
f006bc8b-195a-45b8-8e35-2291a2985f14    DEBUG:toil.job:Getting ModuleDescriptor from module toil.resource.
f006bc8b-195a-45b8-8e35-2291a2985f14    DEBUG:toil.job:Getting set from module __builtin__.
f006bc8b-195a-45b8-8e35-2291a2985f14    INFO:toil.fileStore:Starting job (d171ba6d-1842-4f3e-998a-84c3d11cee59) with ID (d9a3bddaadfb045480c8964cb490dcba2493d8f9).
f006bc8b-195a-45b8-8e35-2291a2985f14    DEBUG:toil.fileStore:CACHE: Obtained lock on file /var/lib/toil/toil-17daa335-7e62-4772-9308-53456ca4b46a/cache-17daa335-7e62-4772-9308
f006bc8b-195a-45b8-8e35-2291a2985f14    DEBUG:toil.fileStore:CACHE: Released lock
f006bc8b-195a-45b8-8e35-2291a2985f14    Traceback (most recent call last):
f006bc8b-195a-45b8-8e35-2291a2985f14      File "/usr/local/lib/python2.7/dist-packages/toil/worker.py", line 323, in main
f006bc8b-195a-45b8-8e35-2291a2985f14        caching=not config.disableCaching)
f006bc8b-195a-45b8-8e35-2291a2985f14      File "/usr/local/lib/python2.7/dist-packages/toil/fileStore.py", line 109, in createFileStore
f006bc8b-195a-45b8-8e35-2291a2985f14        return fileStoreCls(jobStore, jobWrapper, localTempDir, inputBlockFn)
f006bc8b-195a-45b8-8e35-2291a2985f14      File "/usr/local/lib/python2.7/dist-packages/toil/fileStore.py", line 104, in __init__
f006bc8b-195a-45b8-8e35-2291a2985f14        self._setupCache()
f006bc8b-195a-45b8-8e35-2291a2985f14      File "/usr/local/lib/python2.7/dist-packages/toil/fileStore.py", line 624, in _setupCache
f006bc8b-195a-45b8-8e35-2291a2985f14        with self._CacheState.open(self) as cacheInfo:
f006bc8b-195a-45b8-8e35-2291a2985f14      File "/usr/lib/python2.7/contextlib.py", line 17, in __enter__
f006bc8b-195a-45b8-8e35-2291a2985f14        return self.gen.next()
f006bc8b-195a-45b8-8e35-2291a2985f14      File "/usr/local/lib/python2.7/dist-packages/toil/fileStore.py", line 986, in open
f006bc8b-195a-45b8-8e35-2291a2985f14        cacheInfo = cls._load(outer.cacheStateFile)
f006bc8b-195a-45b8-8e35-2291a2985f14      File "/usr/local/lib/python2.7/dist-packages/toil/fileStore.py", line 999, in _load
f006bc8b-195a-45b8-8e35-2291a2985f14        cacheInfoDict = dill.load(fH)
f006bc8b-195a-45b8-8e35-2291a2985f14      File "/usr/local/lib/python2.7/dist-packages/dill/dill.py", line 250, in load
f006bc8b-195a-45b8-8e35-2291a2985f14        obj = pik.load()
f006bc8b-195a-45b8-8e35-2291a2985f14      File "/usr/lib/python2.7/pickle.py", line 864, in load
f006bc8b-195a-45b8-8e35-2291a2985f14        dispatch[key](self)
f006bc8b-195a-45b8-8e35-2291a2985f14      File "/usr/lib/python2.7/pickle.py", line 1096, in load_global
f006bc8b-195a-45b8-8e35-2291a2985f14        klass = self.find_class(module, name)
f006bc8b-195a-45b8-8e35-2291a2985f14      File "/usr/local/lib/python2.7/dist-packages/dill/dill.py", line 406, in find_class
f006bc8b-195a-45b8-8e35-2291a2985f14        return StockUnpickler.find_class(self, module, name)
f006bc8b-195a-45b8-8e35-2291a2985f14      File "/usr/lib/python2.7/pickle.py", line 1130, in find_class
f006bc8b-195a-45b8-8e35-2291a2985f14        __import__(module)
f006bc8b-195a-45b8-8e35-2291a2985f14    ImportError: No module named toil_lib.programs
f006bc8b-195a-45b8-8e35-2291a2985f14    Exiting the worker because of a failed jobWrapper on host ip-172-31-3-245
f006bc8b-195a-45b8-8e35-2291a2985f14    ERROR:toil.worker:Exiting the worker because of a failed jobWrapper on host ip-172-31-3-245
f006bc8b-195a-45b8-8e35-2291a2985f14    DEBUG:toil.jobStores.aws.jobStore:Loaded job f006bc8b-195a-45b8-8e35-2291a2985f14
f006bc8b-195a-45b8-8e35-2291a2985f14    WARNING:toil.jobWrapper:Due to failure we are reducing the remaining retry count of job f006bc8b-195a-45b8-8e35-2291a2985f14 to 0
f006bc8b-195a-45b8-8e35-2291a2985f14    WARNING:toil.jobWrapper:We have increased the default memory of the failed job to 2147483648 bytes

# Fixed code
def _loadUserModule(cls, userModule):
    """
    Imports and returns the module object represented by the given module descriptor.

    :type userModule: ModuleDescriptor
    """
    return userModule.load()