def load_python_file(python_file, working_directory):
    '\n    Takes a path to a python file and returns a loaded module\n    '
    check.str_param(python_file, 'python_file')
    module_name = os.path.splitext(os.path.basename(python_file))[0]
    cwd = sys.path[0]
    if working_directory:
        with alter_sys_path(to_add=[working_directory], to_remove=[cwd]):
            return import_module_from_path(module_name, python_file)
    error = None
    sys_modules = {k: v for (k, v) in sys.modules.items()}
    with alter_sys_path(to_add=[], to_remove=[cwd]):
        try:
            module = import_module_from_path(module_name, python_file)
        except ImportError as ie:
            to_delete = (set(sys.modules) - set(sys_modules))
            for key in to_delete:
                del sys.modules[key]
            error = ie
    if (not error):
        return module
    try:
        module = import_module_from_path(module_name, python_file)
        warnings.warn('Module `{module}` was resolved using the working directory. The ability to implicitly load modules from the working directory is deprecated and will be removed in a future release. Please explicitly specify the `working_directory` config option in your workspace.yaml or install `{module}` to your python environment.'.format(module=(error.name if hasattr(error, 'name') else module_name)))
        return module
    except ImportError:
        raise error
Takes a path to a python file and returns a loaded module
def load_python_file(python_file, working_directory):
    '\n    \n    '
    check.str_param(python_file, 'python_file')
    module_name = os.path.splitext(os.path.basename(python_file))[0]
    cwd = sys.path[0]
    if working_directory:
        with alter_sys_path(to_add=[working_directory], to_remove=[cwd]):
            return import_module_from_path(module_name, python_file)
    error = None
    sys_modules = {k: v for (k, v) in sys.modules.items()}
    with alter_sys_path(to_add=[], to_remove=[cwd]):
        try:
            module = import_module_from_path(module_name, python_file)
        except ImportError as ie:
            to_delete = (set(sys.modules) - set(sys_modules))
            for key in to_delete:
                del sys.modules[key]
            error = ie
    if (not error):
        return module
    try:
        module = import_module_from_path(module_name, python_file)
        warnings.warn('Module `{module}` was resolved using the working directory. The ability to implicitly load modules from the working directory is deprecated and will be removed in a future release. Please explicitly specify the `working_directory` config option in your workspace.yaml or install `{module}` to your python environment.'.format(module=(error.name if hasattr(error, 'name') else module_name)))
        return module
    except ImportError:
        raise error