[Serve] Move fcntl import in haproxy.py to function scope for Windows compat#60955
Conversation
… compat The top-level `import fcntl` in haproxy.py causes doctest collection to fail on Windows with `ModuleNotFoundError: No module named 'fcntl'`. fcntl is Unix-only and HAProxy is not supported on Windows, but the doctest target still collects this file. Moving the import to function scope (matching the pattern used by cluster_init.py) avoids the import error during collection. Fixes postmerge Windows test failure in //python/ray/serve:doctest. Signed-off-by: Seiji Eicher <seiji@anyscale.com>
There was a problem hiding this comment.
Code Review
This pull request moves the fcntl import in haproxy.py to be function-scoped. This is a good change to improve Windows compatibility, as fcntl is a Unix-only module. By importing it only within the function where it's used, it avoids ModuleNotFoundError during test collection on Windows. The change is correct, follows existing patterns in the repository, and effectively resolves the described issue. I have no further comments.
Signed-off-by: Seiji Eicher <seiji@anyscale.com>
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
| # This is important in test environments where multiple nodes may run | ||
| # on the same machine | ||
| with open(self.config_file_path, "w") as f: | ||
| import fcntl |
There was a problem hiding this comment.
why does moving import here work?
There was a problem hiding this comment.
I think doctest just needs to import the file to search for >>> tests. If we import fcntl lazily, we can avoid the ImportError, since haproxy.py anyway does not define any doctest. I am running the test to confirm
I can add a comment
There was a problem hiding this comment.
Revisit Windows compatibility for fcntl
|
Running test: https://buildkite.com/ray-project/premerge/builds/59968 |
Signed-off-by: Seiji Eicher <seiji@anyscale.com>
| commands: | ||
| - bash ci/ray_ci/windows/install_tools.sh | ||
| - bazel run //ci/ray_ci:test_in_docker -- //python/ray/serve/... serve | ||
| - bazel run //ci/ray_ci:test_in_docker -- //python/ray/serve:doctest serve |
There was a problem hiding this comment.
Windows serve CI job drops most test coverage
High Severity
The test target was narrowed from //python/ray/serve/... (all serve tests) to //python/ray/serve:doctest (only the doctest target). Previously this job ran all serve tests on Windows except those tagged no_windows or use_all_core_windows, with parallelism. Now only the single doctest target runs. The "enormous tests" job only covers use_all_core_windows-tagged tests, so all other non-doctest Windows serve tests are now entirely uncovered in CI. The PR author's comment about the build not picking up a test suggests this is unfinished.
This reverts commit 15a0226. Signed-off-by: Seiji Eicher <seiji@anyscale.com>
This reverts commit 529d104. Signed-off-by: Seiji Eicher <seiji@anyscale.com>
…seiji/ray into fix-haproxy-fcntl-windows
|
Third times the charm: https://buildkite.com/ray-project/postmerge/builds/16064 |
Windows |
… compat (ray-project#60955) ## Why are these changes needed? The top-level `import fcntl` in `haproxy.py` causes `//python/ray/serve:doctest` to fail on Windows with `ModuleNotFoundError: No module named 'fcntl'`. `fcntl` is Unix-only, and HAProxy is not supported on Windows, but the doctest target still collects this file during pytest collection. Moving the import to function scope matches the pattern used by other files in the repo (e.g. `cluster_init.py`) and avoids the import error during collection. Fixes postmerge Windows test failure: https://buildkite.com/ray-project/postmerge/builds/15965#019c49ac-39cf-4733-83d6-9703941281c1 ## Related issue number N/A ## Checks - [x] I've signed all my commits - [x] I've run `scripts/format.sh` to lint the changes in this PR. - [x] 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. - [x] 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 - [x] Unit tests - [ ] Release tests - [ ] This PR is not tested :( --------- Signed-off-by: Seiji Eicher <seiji@anyscale.com> Signed-off-by: Adel Nour <ans9868@nyu.edu>
… compat (ray-project#60955) ## Why are these changes needed? The top-level `import fcntl` in `haproxy.py` causes `//python/ray/serve:doctest` to fail on Windows with `ModuleNotFoundError: No module named 'fcntl'`. `fcntl` is Unix-only, and HAProxy is not supported on Windows, but the doctest target still collects this file during pytest collection. Moving the import to function scope matches the pattern used by other files in the repo (e.g. `cluster_init.py`) and avoids the import error during collection. Fixes postmerge Windows test failure: https://buildkite.com/ray-project/postmerge/builds/15965#019c49ac-39cf-4733-83d6-9703941281c1 ## Related issue number N/A ## Checks - [x] I've signed all my commits - [x] I've run `scripts/format.sh` to lint the changes in this PR. - [x] 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. - [x] 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 - [x] Unit tests - [ ] Release tests - [ ] This PR is not tested :( --------- Signed-off-by: Seiji Eicher <seiji@anyscale.com>



Why are these changes needed?
The top-level
import fcntlinhaproxy.pycauses//python/ray/serve:doctestto fail on Windows withModuleNotFoundError: No module named 'fcntl'.fcntlis Unix-only, and HAProxy is not supported on Windows, but the doctest target still collects this file during pytest collection.Moving the import to function scope matches the pattern used by other files in the repo (e.g.
cluster_init.py) and avoids the import error during collection.Fixes postmerge Windows test failure: https://buildkite.com/ray-project/postmerge/builds/15965#019c49ac-39cf-4733-83d6-9703941281c1
Related issue number
N/A
Checks
scripts/format.shto lint the changes in this PR.doc/source/tune/api/under the corresponding.rstfile.