Skip to content

[Serve] Move fcntl import in haproxy.py to function scope for Windows compat#60955

Merged
abrarsheikh merged 9 commits into
ray-project:masterfrom
eicherseiji:fix-haproxy-fcntl-windows
Feb 15, 2026
Merged

[Serve] Move fcntl import in haproxy.py to function scope for Windows compat#60955
abrarsheikh merged 9 commits into
ray-project:masterfrom
eicherseiji:fix-haproxy-fcntl-windows

Conversation

@eicherseiji

Copy link
Copy Markdown
Contributor

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

  • I've signed all my commits
  • 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 :(
… 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>
@eicherseiji eicherseiji added the go add ONLY when ready to merge, run all tests label Feb 11, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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>
@abrarsheikh abrarsheikh marked this pull request as ready for review February 11, 2026 02:38
@abrarsheikh abrarsheikh requested a review from a team as a code owner February 11, 2026 02:38
@gemini-code-assist

Copy link
Copy Markdown
Contributor

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

why does moving import here work?

@eicherseiji eicherseiji Feb 11, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Revisit Windows compatibility for fcntl

@eicherseiji

eicherseiji commented Feb 11, 2026

Copy link
Copy Markdown
Contributor Author
Signed-off-by: Seiji Eicher <seiji@anyscale.com>

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Comment thread .buildkite/windows.rayci.yml Outdated
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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

Fix in Cursor Fix in Web

@eicherseiji eicherseiji marked this pull request as draft February 11, 2026 03:15
@eicherseiji

Copy link
Copy Markdown
Contributor Author
@eicherseiji

Copy link
Copy Markdown
Contributor Author
@eicherseiji

Copy link
Copy Markdown
Contributor Author
@eicherseiji

Copy link
Copy Markdown
Contributor Author
@eicherseiji eicherseiji marked this pull request as ready for review February 15, 2026 03:04
@abrarsheikh abrarsheikh merged commit db045c4 into ray-project:master Feb 15, 2026
5 checks passed
ans9868 pushed a commit to ans9868/ray that referenced this pull request Feb 18, 2026
… 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>
Aydin-ab pushed a commit to kunling-anyscale/ray that referenced this pull request Feb 20, 2026
… 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>
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

2 participants