-
Notifications
You must be signed in to change notification settings - Fork 5.8k
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
[Serve] Optimize DeploymentDetails.deployment_route_prefix_not_set()
#46305
Merged
edoakes
merged 2 commits into
ray-project:master
from
JoshKarpel:optimize-deployment_route_prefix_not_set
Jun 28, 2024
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -947,10 +947,12 @@ class DeploymentDetails(BaseModel, extra=Extra.forbid, frozen=True): | |
def deployment_route_prefix_not_set(cls, v: DeploymentSchema): | ||
# Route prefix should not be set at the deployment level. Deployment-level route | ||
# prefix is outdated, there should be one route prefix per application | ||
if "route_prefix" in v.dict(exclude_unset=True): | ||
if ( | ||
"route_prefix" in v.__fields_set__ | ||
): # in Pydantic v2, this becomes `in v.model_fields_set` | ||
raise ValueError( | ||
"Unexpectedly found a deployment-level route_prefix in the " | ||
f'deployment_config for deployment "{cls.name}". The route_prefix in ' | ||
f'deployment_config for deployment "{v.name}". The route_prefix in ' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was an unrelated bug - I suspect that either no one has ever hit this block, or they just accepted the |
||
"deployment_config within DeploymentDetails should not be set; please " | ||
"set it at the application level." | ||
) | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to support both pydantic v1 and v2. Could you import
and also add support for pydantic 2?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I understand
ray/python/ray/_private/pydantic_compat.py
Lines 55 to 57 in 4ae8128
pydantic.v1
import to keep using the v1 API, so this call will be valid either way (I tested this code with Pydantic v2 installed and it worked as expected). But it would cause an issue when you switch to actually using Pydantic v2 models internally 🤔... maybe this field will be fully deprecated by then and this validator will be deleted before the migration happens? 😁
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yea this should be fine because it's only touching our internal models
user models can be pydantic v2