Skip to content

Commit

Permalink
Unskipped tests for Windows (ray-project#21809)
Browse files Browse the repository at this point in the history
These tests are passing without issues on my Windows machine, so unskipping them to check on CI.
I will push the linting changes separately to execute the test suite twice for confirming that flakyness is removed.

Co-authored-by: Philipp Moritz <pcmoritz@gmail.com>
  • Loading branch information
czgdp1807 and pcmoritz authored Feb 15, 2022
1 parent a8341df commit 7dc097a
Show file tree
Hide file tree
Showing 9 changed files with 43 additions and 20 deletions.
5 changes: 3 additions & 2 deletions python/ray/tests/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -271,8 +271,9 @@ py_test(
# because they requires globs and it might be refactored in the future.
py_test(
name = "test_typing",
size = "small",
srcs = SRCS + ["test_typing.py"] + glob(["typing_files"]),
size = "medium",
srcs = SRCS + ["test_typing.py", "typing_files/check_typing_bad.py",
"typing_files/check_typing_good.py"],
tags = ["exclusive", "small_size_python_tests", "team:core"],
deps = ["//:ray_lib"],
)
Expand Down
1 change: 0 additions & 1 deletion python/ray/tests/test_actor.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ def get_val(self):
assert ray.get(f.get_val.remote()) == 3


@pytest.mark.skipif(sys.platform == "win32", reason="Failing on Windows.")
def test_remote_function_within_actor(ray_start_10_cpus):
# Make sure we can use remote funtions within actors.

Expand Down
1 change: 0 additions & 1 deletion python/ray/tests/test_actor_resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,6 @@ def blocking_method(self):
assert remaining_ids == [x_id]


@pytest.mark.skipif(sys.platform == "win32", reason="Very flaky.")
def test_lifetime_and_transient_resources(ray_start_regular):
# This actor acquires resources only when running methods.
@ray.remote
Expand Down
1 change: 0 additions & 1 deletion python/ray/tests/test_multi_tenancy.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ def test_initial_workers(shutdown_only):
# all the PIDs don't overlap. If overlapped, it means that tasks owned by
# different drivers were scheduled to the same worker process, that is, tasks
# of different jobs were not correctly isolated during execution.
@pytest.mark.skipif(sys.platform == "win32", reason="Failing on Windows.")
def test_multi_drivers(shutdown_only):
info = ray.init(num_cpus=10)

Expand Down
1 change: 0 additions & 1 deletion python/ray/tests/test_multinode_failures.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ def ray_start_workers_separate_multinode(request):
cluster.shutdown()


@pytest.mark.skipif(sys.platform == "win32", reason="Failing on Windows.")
def test_worker_failed(ray_start_workers_separate_multinode):
num_nodes, num_initial_workers = ray_start_workers_separate_multinode

Expand Down
1 change: 0 additions & 1 deletion python/ray/tests/test_reference_counting.py
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,6 @@ def _all_actors_dead():
)


@pytest.mark.skipif(sys.platform == "win32", reason="Failing on Windows.")
def test_kill_actor_immediately_after_creation(ray_start_regular):
@ray.remote
class A:
Expand Down
1 change: 0 additions & 1 deletion python/ray/tests/test_shuffle.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ def test_shuffle_hang():
ray.shutdown()


@pytest.mark.skipif(sys.platform == "win32", reason="Failing on Windows.")
def test_shuffle_no_streaming():
try:
shuffle.run(no_streaming=True)
Expand Down
19 changes: 14 additions & 5 deletions python/ray/tests/test_traceback.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,6 @@ def f():
assert clean_noqa(expected_output) == scrub_traceback(str(ex))


@pytest.mark.skipif(sys.platform == "win32", reason="Broken on Windows")
def test_serialization_error_message(shutdown_only):
expected_output_task = """Could not serialize the argument <unlocked _thread.lock object at ADDRESS> for a task or actor test_traceback.test_serialization_error_message.<locals>.task_with_unserializable_arg. Check https://docs.ray.io/en/master/serialization.html#troubleshooting for more information.""" # noqa
expected_output_actor = """Could not serialize the argument <unlocked _thread.lock object at ADDRESS> for a task or actor test_traceback.test_serialization_error_message.<locals>.A.__init__. Check https://docs.ray.io/en/master/serialization.html#troubleshooting for more information.""" # noqa
Expand Down Expand Up @@ -351,27 +350,37 @@ def __init__(self):
def scrub_traceback(ex):
return re.sub("object at .*> for a", "object at ADDRESS> for a", ex)

assert clean_noqa(expected_output_task) == scrub_traceback(str(excinfo.value))
test_prefix = "com_github_ray_project_ray.python.ray.tests."

assert clean_noqa(expected_output_task) == scrub_traceback(
str(excinfo.value)
).replace(test_prefix, "")
"""
Test an actor with an unserializable object.
"""
with pytest.raises(TypeError) as excinfo:
a = A.remote(lock)
print(a)
assert clean_noqa(expected_output_actor) == scrub_traceback(str(excinfo.value))
assert clean_noqa(expected_output_actor) == scrub_traceback(
str(excinfo.value)
).replace(test_prefix, "")
"""
Test the case where an unserializable object is captured by tasks.
"""
with pytest.raises(TypeError) as excinfo:
capture_lock.remote()
assert clean_noqa(expected_capture_output_task) == str(excinfo.value)
assert clean_noqa(expected_capture_output_task) == str(excinfo.value).replace(
test_prefix, ""
)
"""
Test the case where an unserializable object is captured by actors.
"""
with pytest.raises(TypeError) as excinfo:
b = B.remote()
print(b)
assert clean_noqa(expected_capture_output_actor) == str(excinfo.value)
assert clean_noqa(expected_capture_output_actor) == str(excinfo.value).replace(
test_prefix, ""
)


if __name__ == "__main__":
Expand Down
33 changes: 26 additions & 7 deletions python/ray/tests/test_typing.py
Original file line number Diff line number Diff line change
@@ -1,28 +1,47 @@
import sys
import os
import shutil
import sys

import mypy.api as mypy_api
import pytest

TYPING_TEST_DIRS = os.path.join(os.path.dirname(__file__), "typing_files")


@pytest.mark.skipif(sys.platform == "win32", reason="Failing on Windows.")
def test_typing_good():
script = os.path.join(TYPING_TEST_DIRS, "check_typing_good.py")
msg, _, status_code = mypy_api.run([script])
script = "check_typing_good.py"
# the following check indicates that check_typing_good.py
# is not present in the current directory, so follow
# the path specified TYPING_TEST_DIRS
if not os.path.exists(script):
script = os.path.join(TYPING_TEST_DIRS, script)
_, msg, status_code = mypy_api.run([script])
assert status_code == 0, msg


@pytest.mark.skipif(sys.platform == "win32", reason="Failing on Windows.")
def test_typing_bad():
script = os.path.join(TYPING_TEST_DIRS, "check_typing_bad.py")
msg, _, status_code = mypy_api.run([script])
script = "check_typing_bad.py"
# the following check indicates that check_typing_bad.py
# is not present in the current directory, so follow
# the path specified TYPING_TEST_DIRS
if not os.path.exists(script):
script = os.path.join(TYPING_TEST_DIRS, script)
_, msg, status_code = mypy_api.run([script])
assert status_code == 1, msg


if __name__ == "__main__":
# Make subprocess happy in bazel.
os.environ["LC_ALL"] = "en_US.UTF-8"
os.environ["LANG"] = "en_US.UTF-8"
# copying is necessary because otherwise, ray is imported from the source
# files in directory, `Bazel.runfiles_*/runfiles/com_github_ray_project_ray/python`
# and mypy is unable to detect attributes that should be present in ray.
typing_files_dir = "python/ray/tests/typing_files/"
checking_typing_good = typing_files_dir + "check_typing_good.py"
checking_typing_bad = typing_files_dir + "check_typing_bad.py"
if os.path.exists(checking_typing_good):
shutil.copy(checking_typing_good, os.getcwd())
if os.path.exists(checking_typing_bad):
shutil.copy(checking_typing_bad, os.getcwd())
sys.exit(pytest.main(["-v", __file__]))

0 comments on commit 7dc097a

Please sign in to comment.