How severe does this issue affect your experience of using Ray?
- High: It blocks me to complete my task.
Hello guys,
I have a problem using ray in the context of using it as a module.
I have the following code (main.py), which is a simplified version of the actual file, but it has the same structure and error messages:
import ray
import importlib
from pathlib import Path
import sys
import os
try:
from parallel.rayParallel import mainWrapper
except ImportError:
from rayParallel import mainWrapper
if __name__ == "__main__":
if not ray.is_initialized():
ray.init()
path = Path("path/to/python_script")
sys.path.insert(0, f"{path.parent}{os.sep}")
func = importlib.import_module(path.stem)
run_func = func.mainWrapper
run_func()
It initializes ray and than interanalizes my simulation script as a module and than runs the “mainWrapper” function which actually does the computation and parallelization with ray.
The thing is, when I run this script as a normal python script (python3 main.py) it works just fine.
But when I want to run it as a module (which is my ultimate goal) with
python3 -m parallel (the test module is named parallel, which has a init.py and the above main.py) function, I get the following error:
RuntimeError: The remote function failed to import on the worker. This may be because needed library dependencies are not installed in the worker environment:
ray::parallel() (pid=96716, ip=134.61.193.179)
ModuleNotFoundError: No module named 'rayParallel'
I already tried debugging, searched the internet, but did not find any solution.
Thank in advance