-
Notifications
You must be signed in to change notification settings - Fork 161
fix(BA-1380): Update Service.create()
to comply with validation schema
#4449
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
fix(BA-1380): Update Service.create()
to comply with validation schema
#4449
Conversation
…h `NewServiceRequestModel` schema
.fix.md -> 4449.fix.md Co-authored-by: octodog <mu001@lablup.com>
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.
Pull Request Overview
This PR aligns the Service.create()
and Service.try_start()
client SDK methods with the NewServiceRequestModel
schema by making key resource and configuration parameters required and enforcing explicit typing.
- Adjusted method signatures for
create
andtry_start
to requireresources
,resource_opts
,domain_name
,group_name
,scaling_group
as positional-only, and changedexpose_to_public
to be explicitlybool
. - Added a changelog entry for the
Service.create()
signature change.
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
File | Description |
---|---|
src/ai/backend/client/func/service.py | Updated create and try_start signatures to match the new request model parameters |
changes/.fix.md | Added entry noting the Service.create() signature update |
Comments suppressed due to low confidence (4)
src/ai/backend/client/func/service.py:118
- The docstring for
create
doesn't list the newly added parameters (resources
,resource_opts
,domain_name
,group_name
,scaling_group
, and updatedexpose_to_public
). Please update it to reflect the signature change.
"""
src/ai/backend/client/func/service.py:244
- The docstring for
try_start
is missing descriptions for the new required parameters; please add entries for each to match the updated signature.
Tries to start an inference session and terminates immediately.
src/ai/backend/client/func/service.py:93
- New required parameters (
resources
,resource_opts
, etc.) lack test coverage. Please add or update tests inai.backend.test
to validate these parameters for bothcreate
andtry_start
.
resources: Mapping[str, str | int],
src/ai/backend/client/func/service.py:92
- [nitpick] These five parameters are enforced as positional-only, which may decrease readability for SDK consumers. Consider making them keyword-only to improve clarity.
/,
changes/.fix.md
Outdated
@@ -0,0 +1 @@ | |||
Fixed client SDK method `Service.create()` signature to comply with `NewServiceRequestModel` schema |
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.
Update this changelog entry to also mention the try_start
signature changes for full coverage.
Fixed client SDK method `Service.create()` signature to comply with `NewServiceRequestModel` schema | |
Fixed client SDK method `Service.create()` signature to comply with `NewServiceRequestModel` schema. | |
Updated `try_start` method signature to align with the latest `TryStartRequestModel` schema. |
Copilot uses AI. Check for mistakes.
Service.create()
signature in client SDK to comply with NewServiceRequestModel
schemaService.create()
to comply with validation schema
/, | ||
resources: Mapping[str, str | int], | ||
resource_opts: Mapping[str, str | int], | ||
domain_name: str, | ||
group_name: str, | ||
scaling_group: str, |
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.
/ is required?
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.
Not mandatory.
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.
Then we just change the position and take it as a keyword argument as before.
resources: Optional[Mapping[str, str | int]] = None, | ||
resource_opts: Optional[Mapping[str, str | int]] = None, | ||
cluster_size: int = 1, | ||
cluster_mode: Literal["single-node", "multi-node"] = "single-node", | ||
domain_name: Optional[str] = None, | ||
group_name: Optional[str] = None, | ||
bootstrap_script: Optional[str] = None, | ||
tag: Optional[str] = None, | ||
architecture: Optional[str] = DEFAULT_IMAGE_ARCH, | ||
scaling_group: Optional[str] = None, | ||
owner_access_key: Optional[str] = None, | ||
model_definition_path: Optional[str] = None, | ||
expose_to_public=False, |
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.
Is it guaranteed that the arguments will come from the part?
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.
It would have never worked and raised exceptions without explicit setting arguments.
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.
I checked. the arguments are being passed using dictionary.
that part seems fine. 👍
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.
Pull Request Overview
Aligns the client SDK’s Service.create()
and Service.try_start()
methods with the NewServiceRequestModel
schema by making several parameters required and explicitly typing a boolean flag.
- Made
resources
,resource_opts
,domain_name
,group_name
, andscaling_group
required positional parameters - Changed
expose_to_public
to an explicitly typedbool
- Added a change log entry reflecting the updated
Service.create()
signature
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
File | Description |
---|---|
src/ai/backend/client/func/service.py | Updated create and try_start signatures to enforce required parameters and typed boolean flag |
changes/4449.fix.md | Added note about Service.create() signature fix |
Comments suppressed due to low confidence (4)
src/ai/backend/client/func/service.py:116
- The docstring for
create()
doesn’t list the newly required parameters (resources
,resource_opts
,domain_name
,group_name
,scaling_group
). Please update it to describe each parameter and its type.
"""
src/ai/backend/client/func/service.py:102
- The signature now enforces
resources
and other parameters as required; please add or update tests inai.backend.test
to cover valid calls and error cases when these parameters are omitted.
resources: Mapping[str, str | int],
src/ai/backend/client/func/service.py:99
- Making parameters previously optional now required is a breaking change. Consider documenting this in the release notes and bumping the major version to signal the API change.
async def create(
changes/4449.fix.md:1
- [nitpick] The change log filename (
4449.fix.md
) and references (fix(BA-1380): UpdateService.create()
to comply with validation schema #4449) don’t match the PR’s issue number (Inconsistent handling of nullable value forgroup_name
in service creation API #4417). Consider renaming the file or updating its header for consistency.
+Fixed client SDK method `Service.create()` signature to comply with `NewServiceRequestModel` schema
resources: Mapping[str, str | int], | ||
resource_opts: Mapping[str, str | int], | ||
cluster_size: int = 1, | ||
cluster_mode: Literal["single-node", "multi-node"] = "single-node", | ||
domain_name: Optional[str] = None, | ||
group_name: Optional[str] = None, | ||
domain_name: str, | ||
group_name: str, | ||
bootstrap_script: Optional[str] = None, | ||
tag: Optional[str] = None, | ||
architecture: Optional[str] = DEFAULT_IMAGE_ARCH, | ||
scaling_group: Optional[str] = None, | ||
scaling_group: str, |
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.
Isn’t it the case that once a parameter is given a default value, all following parameters must also have default values? @rapsealk
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.
Any parameter defined after *
must be specified using its name (i.e., as a keyword argument). The order of these keyword-only arguments in a function call doesn't matter, since they can't be passed positionally.
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.
Wouldn’t it be better to place keyword-only arguments without default values first for better readability and clarity. @rapsealk
…ema (#4449) Co-authored-by: octodog <mu001@lablup.com> Backported-from: main (25.8) Backported-to: 25.6 Backport-of: 4449
resolves #4417 (BA-1380)
This pull request updates the client SDK to align method signatures with the
NewServiceRequestModel
schema and introduces non-optional parameters for resource and configuration details in service-related methods. These changes ensure stricter compliance with expected input requirements and improve the clarity and reliability of the SDK.SDK Method Signature Updates:
changes/.fix.md
: Updated documentation to reflect that theService.create()
method signature now complies with theNewServiceRequestModel
schema.Parameter Adjustments in Service Methods:
src/ai/backend/client/func/service.py
:create
: Maderesources
,resource_opts
,domain_name
,group_name
, andscaling_group
required positional parameters. Changedexpose_to_public
from an implicit boolean to an explicitly typedbool
. [1] [2]try_start
: Applied the same parameter changes as increate
, ensuring consistency across service-related methods.Checklist: (if applicable)
ai.backend.test