Skip to content

[bug] relative file paths when using Cache #906

@jan-janssen

Description

@jan-janssen

Example code:

from executorlib.api import TestClusterExecutor
from time import sleep
import shutil
import os

funct_str = """
from time import sleep

def echo_with_delay(i):
    sleep(10)
    return i
"""

with open("myfunctions.py", "w") as f:
    f.write(funct_str)

from myfunctions import echo_with_delay
# os.environ["PYTHONPATH"] = os.path.abspath(os.getcwd())
exe = TestClusterExecutor()
f1 = exe.submit(echo_with_delay, 1)
f2 = exe.submit(echo_with_delay, 2)
f3 = exe.submit(echo_with_delay, 3)
exe.shutdown(wait=True, cancel_futures=False)

Error:

Traceback (most recent call last):
  File "/srv/conda/envs/notebook/lib/python3.13/site-packages/executorlib/backend/cache_serial.py", line 6, in <module>
    backend_execute_task_in_file(file_name=sys.argv[1])
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^
  File "/srv/conda/envs/notebook/lib/python3.13/site-packages/executorlib/task_scheduler/file/backend.py", line 71, in backend_execute_task_in_file
    apply_dict = backend_load_file(file_name=file_name)
  File "/srv/conda/envs/notebook/lib/python3.13/site-packages/executorlib/task_scheduler/file/backend.py", line 21, in backend_load_file
    apply_dict = load(file_name=file_name)
  File "/srv/conda/envs/notebook/lib/python3.13/site-packages/executorlib/standalone/hdf.py", line 54, in load
    data_dict["fn"] = cloudpickle.loads(np.void(hdf["/function"]))
                      ~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^
ModuleNotFoundError: No module named 'myfunctions'

The error does not appear on MacOS and adding the current path to the PYTHONPATH fixes the issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions