-
Notifications
You must be signed in to change notification settings - Fork 7.2k
Add test: running a driver for twice. #2464
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
Add test: running a driver for twice. #2464
Conversation
This reverts commit 32b181e.
|
@robertnishihara, please take a look. Thanks. |
|
Test PASSed. |
test/multi_node_test.py
Outdated
| ray.shutdown() | ||
|
|
||
| def testRunDriverForTwice(self): | ||
| # We used to have issue 2165 and 2288: driver will hang when we run it |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you include the full URL instead of just the issue number? This will make it easier to navigate to the issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK.
| def tearDown(self): | ||
| ray.shutdown() | ||
|
|
||
| def testRunDriverForTwice(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd suggest changing this test to not use Ray tune (since the implementation of Ray tune may change). Instead, I'd consider doing something like the following
driver1 = """
...
def serializer(obj):
return 1
def deserializer(serialized_obj):
assert serialized_obj == 1
return 1
class Foo(object):
pass
ray.register_custom_serializer(serializer=serializer, deserializer=deserializer)
@ray.remote
def f(x):
assert x == 1
return Foo()
for _ in range(10):
time.sleep(0.1)
assert ray.get([f.remote() for _ in range(10)]) == 1
"""In driver2 all of the 1s should be replaced by 2.
I'd make num_cpus=1 so that all tasks run on the same worker.
This is just an example, but I think it isolates the lower-level behavior a little more clearly. What do you think?
Also, please make sure that the test fails without the patch.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer the existing way since:
- What this test covers is whether we can run a driver for twice successfully, I believe we will need this kind of test sooner or later;
- Ray tune is the typical case that used to run into problem, it makes more sense to use it to test the fix for this case;
- I understand that the current test is more like a E2E test, and what you propose is more like unit test. I agree that it will be better for us to have completed unit test, for example we need to test: type register on worker -> verify driver and other workers; type register on driver -> verify all workers. I can do it later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I think having a unit test at some point would be valuable, but I agree that this test makes sense.
|
|
||
| for i in range(2): | ||
| out = run_string_as_driver(driver_script) | ||
| self.assertIn("success", out) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How long does this test take to run? If it's quick then maybe we want both.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It runs about 10 seconds, what do you mean by "both"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I meant "this test" and "the unit test I proposed above."
Anyway, 10 seconds is on the long side. It's ok in this case, but in general we should keep tests as short as possible.
b9d844b to
8e999f3
Compare
|
Thank you @robertnishihara! |
|
Test FAILed. |
|
@robertnishihara, can you help to merge? Thank you! |
What do these changes do?
Add test for PR: Use different serialization context for each driver..
Related issue number
#2406