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

Fix rpdb.py for windows and encoding failures, adjust tests #48117

Merged
merged 3 commits into from
Dec 10, 2024

Conversation

mattip
Copy link
Contributor

@mattip mattip commented Oct 21, 2024

Why are these changes needed?

Enables ray debug on windows. Fixes #44902. Fixes #37145. Also changes tests to work on windows.

Checks

  • I've signed off every commit(by using the -s flag, i.e., git commit -s) in this PR.
  • I've run scripts/format.sh to lint the changes in this PR.
  • I've included any doc changes needed for https://docs.ray.io/en/master/.
    • I've added any new APIs to the API Reference. For example, if I added a
      method in Tune, I've added it in doc/source/tune/api/ under the
      corresponding .rst file.
  • I've made sure the tests are passing. Note that there might be a few flaky tests, see the recent failures at https://flakey-tests.ray.io/
  • Testing Strategy
    • Unit tests
    • Release tests
    • This PR is not tested :(


p = PopenSpawn("ray debug", encoding="utf-8")
else:
p = pexpect.spawn("ray debug")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pexpect.spawn does not work on windows, pexpect.PopenSpawn does work on windows.

self._send = lambda data: connection.sendall(data.encode(fh.encoding))
self._send = lambda data: connection.sendall(
data.encode(fh.encoding, errors="replace")
)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The errors='replace' is needed since the debugger goes through sys.stdout, which on windows and python<3.15 will use a locale encoding. On my machine it is cp1252, which cannot represent the unicode character in test_ray_debugger_commands

# in tests, when using pexpect, the pipe makes
# the msvcrt.kbhit() trick fail. Assume we are waiting
# for stdin, since this will block waiting for input
ready_to_read.append(sys.stdin)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was annoying to debug. In the test, pexpect uses a PIPE to communicate over sys.stdin which does not work correctly with msvcrt.kbhit(). "Normal" ray debug use will not enter this clause, sys.stdin.isatty() will be True

@mattip
Copy link
Contributor Author

mattip commented Oct 29, 2024

cc @anyscalesam

@jcotant1 jcotant1 added core Issues that should be addressed in Ray Core and removed core Issues that should be addressed in Ray Core labels Nov 13, 2024
Signed-off-by: Matti Picus <matti.picus@gmail.com>
Signed-off-by: mattip <matti.picus@gmail.com>
@mattip
Copy link
Contributor Author

mattip commented Nov 28, 2024

I rebased this on master to clear the merge conflicts. cc @jjyao

@mattip
Copy link
Contributor Author

mattip commented Dec 10, 2024

Ping

@jjyao jjyao added the go add ONLY when ready to merge, run all tests label Dec 10, 2024
@jjyao jjyao merged commit a8f8c84 into ray-project:master Dec 10, 2024
5 checks passed
simonsays1980 pushed a commit to simonsays1980/ray that referenced this pull request Dec 12, 2024
ujjawal-khare pushed a commit to ujjawal-khare-27/ray that referenced this pull request Dec 17, 2024
…ay-project#48117)

Signed-off-by: Matti Picus <matti.picus@gmail.com>
Signed-off-by: ujjawal-khare <ujjawal.khare@dream11.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
go add ONLY when ready to merge, run all tests
Projects
None yet
3 participants