anyscale / academy

Ray tutorials from Anyscale
https://anyscale.com
Apache License 2.0
580 stars 195 forks source link

AssertionError when run 01-Ray-Tasks.ipynb #39

Closed qingtian1771 closed 3 years ago

qingtian1771 commented 3 years ago

When I run first cell:

from task_lesson_util import make_dmaps, run_simulations, stop_simulations
from pi_calc import str_large_n

It appears following error:

---------------------------------------------------------------------------
AssertionError                            Traceback (most recent call last)
<ipython-input-1-9c851064aaf9> in <module>
----> 1 from task_lesson_util import make_dmaps, run_simulations, stop_simulations
      2 from pi_calc import str_large_n

~/code/ray/academy/ray-crash-course/task_lesson_util.py in <module>
     15 from bokeh.plotting import figure, output_file, show
     16 
---> 17 from pi_calc import MonteCarloPi, compute_pi_for
     18 
     19 

~/code/ray/academy/ray-crash-course/pi_calc.py in <module>
    104 
    105 @ray.remote
--> 106 class RayMonteCarloPi(MonteCarloPi):
    107     @ray.method(num_returns=5)
    108     def sample(self, num_samples):

~/code/ray/academy/ray-crash-course/pi_calc.py in RayMonteCarloPi()
    105 @ray.remote
    106 class RayMonteCarloPi(MonteCarloPi):
--> 107     @ray.method(num_returns=5)
    108     def sample(self, num_samples):
    109         return super().sample(num_samples)

~/anaconda3/envs/anyscale-academy/lib/python3.7/site-packages/ray/actor.py in method(*args, **kwargs)
     37     assert len(args) == 0
     38     assert len(kwargs) == 1
---> 39     assert "num_return_vals" in kwargs
     40     num_return_vals = kwargs["num_return_vals"]
     41 

AssertionError: 

What's the problem? Could you please help!

grechaw commented 3 years ago

I've experienced the same issue. I'll see if I can get to a root cause.

grechaw commented 3 years ago

Indeed, the keyword argument in line 107 does not match the assertion. When I change the ray academy code, the assertion succeeds - will prepare a PR that fixes this issue.

grechaw commented 3 years ago

Actually, this keyword argument appears to have been updated for ray 1.2.0, so the assertion is indeed wrong for the version of ray provided in environment.yml. Fixing #38 will resolve this problem.

ceteri commented 3 years ago

Should be fixed now.