Skip to content

[Core] add deprecation warning for pydantic v1#59703

Merged
edoakes merged 5 commits intomasterfrom
58876-abrar-pydantic
Jan 7, 2026
Merged

[Core] add deprecation warning for pydantic v1#59703
edoakes merged 5 commits intomasterfrom
58876-abrar-pydantic

Conversation

@abrarsheikh
Copy link
Contributor

related to #58876

❯ python -c "
import ray
# Temporarily patch to test the warning shows
from ray._common import pydantic_compat
original = pydantic_compat.IS_PYDANTIC_2
pydantic_compat.IS_PYDANTIC_2 = False  # Simulate Pydantic v1

ray.init()
ray.shutdown()

pydantic_compat.IS_PYDANTIC_2 = original
"
2025-12-26 22:33:01,387 INFO worker.py:1811 -- Connecting to existing Ray cluster at address: 172.31.7.228:6379...
2025-12-26 22:33:01,407 INFO worker.py:1991 -- Connected to Ray cluster. View the dashboard at 127.0.0.1:8265 
/home/ubuntu/ray/python/ray/_private/worker.py:2039: FutureWarning: Tip: In future versions of Ray, Ray will no longer override accelerator visible devices env var if num_gpus=0 or num_gpus=None (default). To enable this behavior and turn off this error message, set RAY_ACCEL_ENV_VAR_OVERRIDE_ON_ZERO=0
  warnings.warn(
/home/ubuntu/ray/python/ray/_private/worker.py:2050: FutureWarning: Pydantic v1 is deprecated and will no longer be supported in Ray 2.56. Please upgrade to Pydantic v2 by running `pip install -U pydantic`. See https://github.com/ray-project/ray/issues/58876 for more details.
  warnings.warn(
 ~/ray │ on 58876-abrar-pydantic *91       
"

Signed-off-by: abrar <abrar@anyscale.com>
@abrarsheikh abrarsheikh requested a review from a team as a code owner December 26, 2025 22:33
@abrarsheikh abrarsheikh added the go add ONLY when ready to merge, run all tests label Dec 26, 2025
Copy link
Contributor

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

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 adds a deprecation warning for Pydantic v1, which is displayed during ray.init(). The implementation is correct, using log_once to show the warning only once. The warning message is clear, providing users with instructions to upgrade and a link to the relevant issue for more details. The change is well-placed and follows the existing coding style of the file. Overall, this is a solid and helpful improvement.

Signed-off-by: abrar <abrar@anyscale.com>
@abrarsheikh abrarsheikh requested review from a team as code owners December 26, 2025 22:39
@ray-gardener ray-gardener bot added the core Issues that should be addressed in Ray Core label Dec 27, 2025
Signed-off-by: abrar <abrar@anyscale.com>
@edoakes edoakes merged commit e86ccbc into master Jan 7, 2026
6 checks passed
@edoakes edoakes deleted the 58876-abrar-pydantic branch January 7, 2026 15:53
AYou0207 pushed a commit to AYou0207/ray that referenced this pull request Jan 13, 2026
related to ray-project#58876

```bash
❯ python -c "
import ray
# Temporarily patch to test the warning shows
from ray._common import pydantic_compat
original = pydantic_compat.IS_PYDANTIC_2
pydantic_compat.IS_PYDANTIC_2 = False  # Simulate Pydantic v1

ray.init()
ray.shutdown()

pydantic_compat.IS_PYDANTIC_2 = original
"
2025-12-26 22:33:01,387 INFO worker.py:1811 -- Connecting to existing Ray cluster at address: 172.31.7.228:6379...
2025-12-26 22:33:01,407 INFO worker.py:1991 -- Connected to Ray cluster. View the dashboard at 127.0.0.1:8265
/home/ubuntu/ray/python/ray/_private/worker.py:2039: FutureWarning: Tip: In future versions of Ray, Ray will no longer override accelerator visible devices env var if num_gpus=0 or num_gpus=None (default). To enable this behavior and turn off this error message, set RAY_ACCEL_ENV_VAR_OVERRIDE_ON_ZERO=0
  warnings.warn(
/home/ubuntu/ray/python/ray/_private/worker.py:2050: FutureWarning: Pydantic v1 is deprecated and will no longer be supported in Ray 2.56. Please upgrade to Pydantic v2 by running `pip install -U pydantic`. See ray-project#58876 for more details.
  warnings.warn(
 ~/ray │ on 58876-abrar-pydantic *91
"
```

---------

Signed-off-by: abrar <abrar@anyscale.com>
Signed-off-by: jasonwrwang <jasonwrwang@tencent.com>
lee1258561 pushed a commit to pinterest/ray that referenced this pull request Feb 3, 2026
related to ray-project#58876

```bash
❯ python -c "
import ray
# Temporarily patch to test the warning shows
from ray._common import pydantic_compat
original = pydantic_compat.IS_PYDANTIC_2
pydantic_compat.IS_PYDANTIC_2 = False  # Simulate Pydantic v1

ray.init()
ray.shutdown()

pydantic_compat.IS_PYDANTIC_2 = original
"
2025-12-26 22:33:01,387 INFO worker.py:1811 -- Connecting to existing Ray cluster at address: 172.31.7.228:6379...
2025-12-26 22:33:01,407 INFO worker.py:1991 -- Connected to Ray cluster. View the dashboard at 127.0.0.1:8265 
/home/ubuntu/ray/python/ray/_private/worker.py:2039: FutureWarning: Tip: In future versions of Ray, Ray will no longer override accelerator visible devices env var if num_gpus=0 or num_gpus=None (default). To enable this behavior and turn off this error message, set RAY_ACCEL_ENV_VAR_OVERRIDE_ON_ZERO=0
  warnings.warn(
/home/ubuntu/ray/python/ray/_private/worker.py:2050: FutureWarning: Pydantic v1 is deprecated and will no longer be supported in Ray 2.56. Please upgrade to Pydantic v2 by running `pip install -U pydantic`. See ray-project#58876 for more details.
  warnings.warn(
 ~/ray │ on 58876-abrar-pydantic *91       
"
```

---------

Signed-off-by: abrar <abrar@anyscale.com>
ryanaoleary pushed a commit to ryanaoleary/ray that referenced this pull request Feb 3, 2026
related to ray-project#58876

```bash
❯ python -c "
import ray
# Temporarily patch to test the warning shows
from ray._common import pydantic_compat
original = pydantic_compat.IS_PYDANTIC_2
pydantic_compat.IS_PYDANTIC_2 = False  # Simulate Pydantic v1

ray.init()
ray.shutdown()

pydantic_compat.IS_PYDANTIC_2 = original
"
2025-12-26 22:33:01,387 INFO worker.py:1811 -- Connecting to existing Ray cluster at address: 172.31.7.228:6379...
2025-12-26 22:33:01,407 INFO worker.py:1991 -- Connected to Ray cluster. View the dashboard at 127.0.0.1:8265 
/home/ubuntu/ray/python/ray/_private/worker.py:2039: FutureWarning: Tip: In future versions of Ray, Ray will no longer override accelerator visible devices env var if num_gpus=0 or num_gpus=None (default). To enable this behavior and turn off this error message, set RAY_ACCEL_ENV_VAR_OVERRIDE_ON_ZERO=0
  warnings.warn(
/home/ubuntu/ray/python/ray/_private/worker.py:2050: FutureWarning: Pydantic v1 is deprecated and will no longer be supported in Ray 2.56. Please upgrade to Pydantic v2 by running `pip install -U pydantic`. See ray-project#58876 for more details.
  warnings.warn(
 ~/ray │ on 58876-abrar-pydantic *91       
"
```

---------

Signed-off-by: abrar <abrar@anyscale.com>
peterxcli pushed a commit to peterxcli/ray that referenced this pull request Feb 25, 2026
related to ray-project#58876

```bash
❯ python -c "
import ray
# Temporarily patch to test the warning shows
from ray._common import pydantic_compat
original = pydantic_compat.IS_PYDANTIC_2
pydantic_compat.IS_PYDANTIC_2 = False  # Simulate Pydantic v1

ray.init()
ray.shutdown()

pydantic_compat.IS_PYDANTIC_2 = original
"
2025-12-26 22:33:01,387 INFO worker.py:1811 -- Connecting to existing Ray cluster at address: 172.31.7.228:6379...
2025-12-26 22:33:01,407 INFO worker.py:1991 -- Connected to Ray cluster. View the dashboard at 127.0.0.1:8265
/home/ubuntu/ray/python/ray/_private/worker.py:2039: FutureWarning: Tip: In future versions of Ray, Ray will no longer override accelerator visible devices env var if num_gpus=0 or num_gpus=None (default). To enable this behavior and turn off this error message, set RAY_ACCEL_ENV_VAR_OVERRIDE_ON_ZERO=0
  warnings.warn(
/home/ubuntu/ray/python/ray/_private/worker.py:2050: FutureWarning: Pydantic v1 is deprecated and will no longer be supported in Ray 2.56. Please upgrade to Pydantic v2 by running `pip install -U pydantic`. See ray-project#58876 for more details.
  warnings.warn(
 ~/ray │ on 58876-abrar-pydantic *91
"
```

---------

Signed-off-by: abrar <abrar@anyscale.com>
Signed-off-by: peterxcli <peterxcli@gmail.com>
peterxcli pushed a commit to peterxcli/ray that referenced this pull request Feb 25, 2026
related to ray-project#58876

```bash
❯ python -c "
import ray
# Temporarily patch to test the warning shows
from ray._common import pydantic_compat
original = pydantic_compat.IS_PYDANTIC_2
pydantic_compat.IS_PYDANTIC_2 = False  # Simulate Pydantic v1

ray.init()
ray.shutdown()

pydantic_compat.IS_PYDANTIC_2 = original
"
2025-12-26 22:33:01,387 INFO worker.py:1811 -- Connecting to existing Ray cluster at address: 172.31.7.228:6379...
2025-12-26 22:33:01,407 INFO worker.py:1991 -- Connected to Ray cluster. View the dashboard at 127.0.0.1:8265
/home/ubuntu/ray/python/ray/_private/worker.py:2039: FutureWarning: Tip: In future versions of Ray, Ray will no longer override accelerator visible devices env var if num_gpus=0 or num_gpus=None (default). To enable this behavior and turn off this error message, set RAY_ACCEL_ENV_VAR_OVERRIDE_ON_ZERO=0
  warnings.warn(
/home/ubuntu/ray/python/ray/_private/worker.py:2050: FutureWarning: Pydantic v1 is deprecated and will no longer be supported in Ray 2.56. Please upgrade to Pydantic v2 by running `pip install -U pydantic`. See ray-project#58876 for more details.
  warnings.warn(
 ~/ray │ on 58876-abrar-pydantic *91
"
```

---------

Signed-off-by: abrar <abrar@anyscale.com>
Signed-off-by: peterxcli <peterxcli@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core Issues that should be addressed in Ray Core go add ONLY when ready to merge, run all tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants