Skip to content

[core] Migrate wait_for_condition and async_wait_for_condition from _private to _common #53652

Merged
edoakes merged 8 commits intomasterfrom
53478-abrar-wait
Jun 10, 2025
Merged

[core] Migrate wait_for_condition and async_wait_for_condition from _private to _common #53652
edoakes merged 8 commits intomasterfrom
53478-abrar-wait

Conversation

@abrarsheikh
Copy link
Copy Markdown
Contributor

Fixes #53478

…private to _common

Signed-off-by: abrar <abrar@anyscale.com>
@abrarsheikh abrarsheikh added the go add ONLY when ready to merge, run all tests label Jun 9, 2025
Signed-off-by: abrar <abrar@anyscale.com>
Signed-off-by: abrar <abrar@anyscale.com>
Signed-off-by: abrar <abrar@anyscale.com>
@abrarsheikh abrarsheikh marked this pull request as ready for review June 9, 2025 16:34
Copilot AI review requested due to automatic review settings June 9, 2025 16:34
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR migrates the wait_for_condition and async_wait_for_condition functions from the _private module to the _common module to centralize test utility functions. Key changes include:

  • Updating various test files to import wait_for_condition from ray._common.test_utils instead of ray._private.test_utils.
  • Removing the local implementations of wait_for_condition and async_wait_for_condition from ray/_private/test_utils.py.
  • Adding tests in ray/_common/tests to verify the new implementations.

Reviewed Changes

Copilot reviewed 237 out of 237 changed files in this pull request and generated no comments.

Show a summary per file
File Description
python/ray/dashboard/modules/event/tests/test_export_task.py Changed import of wait_for_condition to common module.
python/ray/dashboard/modules/event/tests/test_event.py Updated import to common module and removed duplicate wait_for_condition import.
python/ray/dag/tests/test_output_node.py Updated import to common module for wait_for_condition.
python/ray/dag/tests/experimental/test_multi_node_dag.py Reordered imports to use common wait_for_condition.
python/ray/dag/tests/experimental/test_mocked_nccl_dag.py Updated import to common wait_for_condition.
python/ray/autoscaler/v2/tests/test_subscribers.py Updated import of wait_for_condition to common module.
python/ray/autoscaler/v2/tests/test_sdk.py Updated import of wait_for_condition to common module.
python/ray/autoscaler/v2/tests/test_node_provider.py Reordered imports for wait_for_condition migration.
python/ray/autoscaler/v2/tests/test_e2e.py Updated wait_for_condition import to common module.
python/ray/autoscaler/v2/tests/test_autoscaler.py Updated wait_for_condition import to common module.
python/ray/air/tests/test_errors.py Updated wait_for_condition import to common module.
python/ray/_private/test_utils.py Removed wait_for_condition and async_wait_for_condition functionality.
python/ray/_private/state_api_test_utils.py Updated import of test_utils to reference common module.
python/ray/_common/tests/test_wait_for_condition.py Added tests for both wait_for_condition and async_wait_for_condition.
python/ray/_common/tests/test_signal_semaphore_utils.py Updated wait_for_condition import to common module.
python/ray/_common/test_utils.py Added new implementations for wait_for_condition and async_wait_for_condition.
doc/source/serve/doc_code/http_guide/disconnects.py Updated wait_for_condition import to common module.
cpp/test_submit_cpp_job.py Updated wait_for_condition import to common module.
ci/lint/pydoclint-baseline.txt Updated baseline to reflect changes in wait_for_condition docstrings.

Copy link
Copy Markdown
Collaborator

@edoakes edoakes left a comment

Choose a reason for hiding this comment

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

Heroic 💪 thanks for the great test cases as well

@edoakes edoakes enabled auto-merge (squash) June 9, 2025 16:38
Signed-off-by: abrar <abrar@anyscale.com>
@github-actions github-actions bot disabled auto-merge June 9, 2025 16:42
abrarsheikh and others added 2 commits June 9, 2025 20:08
@edoakes edoakes enabled auto-merge (squash) June 10, 2025 00:26
@github-actions github-actions bot disabled auto-merge June 10, 2025 00:26
Copy link
Copy Markdown
Collaborator

@aslonnie aslonnie left a comment

Choose a reason for hiding this comment

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

this is a really big PR.. wonder if there are some ways to do the migration more incrementally.

also, some of the import orders look a bit off.

import ray
from ray._common.test_utils import SignalActor, Semaphore
from ray._private.test_utils import wait_for_condition
from ray._common.test_utils import wait_for_condition
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

these should be merged into a single line (if isort is enabled)?

import os
import sys

from ray._common.test_utils import wait_for_condition
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

why is this imported before torch and pytest?

@abrarsheikh
Copy link
Copy Markdown
Contributor Author

this is a really big PR.. wonder if there are some ways to do the migration more incrementally.

also, some of the import orders look a bit off.

We should take a separate AI to fix the isort logic.

My only issue with incremental rollouts is that it's not possible to restrict people from using the old callsite during migrations, hence I prefer to rip the band-aid off in one go.

@edoakes edoakes merged commit 42fa5af into master Jun 10, 2025
6 checks passed
@edoakes edoakes deleted the 53478-abrar-wait branch June 10, 2025 14:02
aslonnie pushed a commit that referenced this pull request Jun 10, 2025
follow up of #53652

Signed-off-by: abrar <abrar@anyscale.com>
elliot-barn pushed a commit that referenced this pull request Jun 18, 2025
…private to _common (#53652)

Fixes #53478

---------

Signed-off-by: abrar <abrar@anyscale.com>
Signed-off-by: Edward Oakes <ed.nmi.oakes@gmail.com>
Co-authored-by: Edward Oakes <ed.nmi.oakes@gmail.com>
Signed-off-by: elliot-barn <elliot.barnwell@anyscale.com>
elliot-barn pushed a commit that referenced this pull request Jun 18, 2025
follow up of #53652

Signed-off-by: abrar <abrar@anyscale.com>
Signed-off-by: elliot-barn <elliot.barnwell@anyscale.com>
elliot-barn pushed a commit that referenced this pull request Jul 2, 2025
…private to _common (#53652)

Fixes #53478

---------

Signed-off-by: abrar <abrar@anyscale.com>
Signed-off-by: Edward Oakes <ed.nmi.oakes@gmail.com>
Co-authored-by: Edward Oakes <ed.nmi.oakes@gmail.com>
Signed-off-by: elliot-barn <elliot.barnwell@anyscale.com>
elliot-barn pushed a commit that referenced this pull request Jul 2, 2025
follow up of #53652

Signed-off-by: abrar <abrar@anyscale.com>
Signed-off-by: elliot-barn <elliot.barnwell@anyscale.com>
edoakes pushed a commit that referenced this pull request Mar 12, 2026
…61363)

## Description

This PR continues the migration from `ray._private` to `ray._common` so
that Ray Serve (and other libraries) do not depend on internal private
APIs. It migrates `tls_utils` and logging constants out of `_private`
into `_common`, and updates all consumers (Serve, dashboard, client
server) to import from the new locations.

**Changes:**

1. **`ray._common.tls_utils`**  
- Moved `generate_self_signed_tls_certs()` from `_private.tls_utils`
into `_common.tls_utils` (it only depended on `_common.network_utils`).
   - `_private.tls_utils` re-exports it for backward compatibility.  
- **Serve:** `serve/tests/test_https_proxy.py` now imports from
`ray._common.tls_utils`.
- **Other consumers:** `_private/grpc_utils.py`,
`_private/test_utils.py`, `dashboard/agent.py`,
`util/client/server/proxier.py`, `util/client/server/server.py` updated.

2. **`ray._common.logging_constants`**  
- New module containing `LOGRECORD_STANDARD_ATTRS` (frozenset),
`LOGGER_FLATTEN_KEYS`, and `LogKey` enum — all moved from
`_private.ray_logging.constants`.
- `_private.ray_logging.constants` is deleted;
`_private.ray_logging.logging_config` now imports from `_common`.
- **Serve:** `serve/schema.py` now imports `LOGRECORD_STANDARD_ATTRS`
from `ray._common.logging_constants`.

3. **`ray._common.filters` / `ray._common.formatters`**  
- Updated internal imports to use `ray._common.logging_constants`
instead of `ray._private.ray_logging.constants`.

**Tests:**  
- New `ray/_common/tests/test_logging_constants.py` — tests the full
`LOGRECORD_STANDARD_ATTRS` frozenset, all `LogKey` enum members, and
`LOGGER_FLATTEN_KEYS`.
- New `ray/_common/tests/test_tls_utils.py` — tests
`generate_self_signed_tls_certs`.
- Lint: ruff check and format pass on all changed files.

## Related issues

Fixes #53478 (partial: migrates Serve-side imports for `tls_utils` and
logging constants; remaining items like `runtime_env_uri` and
`worker_compat` can be done in follow-up PRs).

## Additional information

- **Backward compatibility:** Existing code that imports
`generate_self_signed_tls_certs` from `_private.tls_utils` continues to
work via re-export. `_private.ray_logging.constants` is removed since
all consumers have been updated.
- **Scope:** Some Serve files still use `ray._private.worker.*` as
attribute access (e.g. `global_worker`, `_global_node`) without a direct
import; migrating those would require exposing them via `_common` and is
left for a separate PR.
- Sample PRs referenced in the issue: #53457 (signal/semaphore to
_common), #53652 (wait_for_condition to _common).

---------

Signed-off-by: mkdev11 <MkDev11@users.noreply.github.com>
Co-authored-by: mkdev11 <MkDev11@users.noreply.github.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

Development

Successfully merging this pull request may close these issues.

[core|serve] Migrate shared utilities from ray._private to ray._common

4 participants