How to use ray.put() with a regular python class instance defined in another python file?

Hi, I try to instantiate a Python class from another python file and then use ray.put() to store the instance into the object store. The code is like this:

import ray
import myclass

ray.init()
instance = myclass.model()
ray.put(instance)

then such a mistake has occurred:

**
File “C:\Users\win10\AppData\Local\conda\conda\envs\drl\lib\site-packages\ray\util\client\worker.py”, line 407, in _put_pickled
raise cloudpickle.loads(resp.error)
ModuleNotFoundError: No module named ‘myclass’

Process finished with exit code 1
**

I guess this is because the file myclass.py is not in the same directory with worker.py.
How could I solve it?

I solve it by starting the head node in the path where I store the code!

1 Like