Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Function definitions are not always updated when redefined. #6130

Closed
robertnishihara opened this issue Nov 10, 2019 · 0 comments · Fixed by #6175
Closed

Function definitions are not always updated when redefined. #6130

robertnishihara opened this issue Nov 10, 2019 · 0 comments · Fixed by #6175
Labels
bug Something that is supposed to be working; but isn't

Comments

@robertnishihara
Copy link
Collaborator

System information

  • OS Platform and Distribution (e.g., Linux Ubuntu 16.04): MacOS
  • Ray installed from (source or binary): source at ccbcc4b
  • Python version: 3.6

Run the following in IPython.

import ray

ray.init()

@ray.remote
def f():
    time.sleep(1)

ray.get(f.remote())  # This will raise an exception because 'time' is not defined.

Then in the same interpreter, run

import time

@ray.remote
def f():
    time.sleep(1)

ray.get(f.remote())

It should work the second time, since time has now been imported and f has been redefined. However, instead it fails with the same error as the first time.

RayTaskError(NameError): ray_worker:__main__.f() (pid=27630, ip=192.168.42.11)
  File "python/ray/_raylet.pyx", line 548, in ray._raylet.execute_task
    with core_worker.profile_event(b"task:execute"):
  File "python/ray/_raylet.pyx", line 550, in ray._raylet.execute_task
    outputs = function_executor(*args, **kwargs)
  File "<ipython-input-1-eadbd19a0c80>", line 7, in f
NameError: name 'time' is not defined

Note that if I modify the code in f slightly, e.g., to sleep for 2 seconds instead of 1, then it works.

@edoakes @pcmoritz I assume that we're hashing the function source code instead of the pickled function and that's what's causing the issue. Forgetting import statements happens all the time in interactive development in IPython and you often need to import them and then redefine the function.

@robertnishihara robertnishihara added the bug Something that is supposed to be working; but isn't label Nov 10, 2019
@robertnishihara robertnishihara changed the title Function definitions appear to not be are sometimes not updated when redefined? Function definitions are not updated when redefined. Nov 10, 2019
@robertnishihara robertnishihara changed the title Function definitions are not updated when redefined. Function definitions are not always updated when redefined. Nov 10, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something that is supposed to be working; but isn't
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants