-
Notifications
You must be signed in to change notification settings - Fork 22
feat: grpc driving dimensions stub implementation #1921
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
Merged
jacobrkerstetter
merged 13 commits into
main
from
feat/driving_dimensions_stub_relocation
Apr 23, 2025
Merged
Changes from 10 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
1f53705
migrated driving dimensions stub to new location
jacobrkerstetter 59998cc
chore: auto fixes from pre-commit hooks
pre-commit-ci[bot] 1463df8
chore: adding changelog file 1921.added.md [dependabot-skip]
pyansys-ci-bot 2426ff3
remove unnecessary protect grpc decorators
jacobrkerstetter 69957c8
Merge branch 'feat/driving_dimensions_stub_relocation' of https://git…
jacobrkerstetter 5f9b9d8
chore: auto fixes from pre-commit hooks
pre-commit-ci[bot] be0d945
Merge branch 'main' into feat/driving_dimensions_stub_relocation
RobPasMue a28047a
Merge branch 'main' of https://github.com/ansys/pyansys-geometry into…
jacobrkerstetter ae0c781
fixing comments on PR
jacobrkerstetter c03ab5a
Merge branch 'feat/driving_dimensions_stub_relocation' of https://git…
jacobrkerstetter 6064a38
typechecking error fix
jacobrkerstetter 47ecb8f
Apply suggestions from code review
RobPasMue 298859c
chore: auto fixes from pre-commit hooks
pre-commit-ci[bot] 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 hidden or 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 |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| grpc driving dimensions stub implementation |
This file contains hidden or 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
50 changes: 50 additions & 0 deletions
50
src/ansys/geometry/core/_grpc/_services/base/driving_dimensions.py
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| # Copyright (C) 2023 - 2025 ANSYS, Inc. and/or its affiliates. | ||
| # SPDX-License-Identifier: MIT | ||
| # | ||
| # | ||
| # Permission is hereby granted, free of charge, to any person obtaining a copy | ||
| # of this software and associated documentation files (the "Software"), to deal | ||
| # in the Software without restriction, including without limitation the rights | ||
| # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
| # copies of the Software, and to permit persons to whom the Software is | ||
| # furnished to do so, subject to the following conditions: | ||
| # | ||
| # The above copyright notice and this permission notice shall be included in all | ||
| # copies or substantial portions of the Software. | ||
| # | ||
| # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
| # SOFTWARE. | ||
| """Module containing the Driving Dimension service implementation (abstraction layer).""" | ||
|
|
||
| from abc import ABC, abstractmethod | ||
|
|
||
| import grpc | ||
|
|
||
|
|
||
| class GRPCDrivingDimensionsService(ABC): | ||
| """Driving Dimension service for gRPC communication with the Geometry server. | ||
|
|
||
| Parameters | ||
| ---------- | ||
| channel : grpc.Channel | ||
| The gRPC channel to the server. | ||
| """ | ||
|
|
||
| def __init__(self, channel: grpc.Channel): | ||
| """Initialize the DrivingDimensionsServiceBase class.""" | ||
| pass # pragma: no cover | ||
|
|
||
| @abstractmethod | ||
| def get_all_parameters(self, **kwargs) -> dict: | ||
| """Get driving dimensions.""" | ||
| pass # pragma: no cover | ||
|
|
||
| @abstractmethod | ||
| def set_parameter(self, **kwargs) -> dict: | ||
| """Set driving dimensions.""" | ||
| pass # pragma: no cover |
This file contains hidden or 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
89 changes: 89 additions & 0 deletions
89
src/ansys/geometry/core/_grpc/_services/v0/driving_dimensions.py
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,89 @@ | ||
| # Copyright (C) 2023 - 2025 ANSYS, Inc. and/or its affiliates. | ||
| # SPDX-License-Identifier: MIT | ||
| # | ||
| # | ||
| # Permission is hereby granted, free of charge, to any person obtaining a copy | ||
| # of this software and associated documentation files (the "Software"), to deal | ||
| # in the Software without restriction, including without limitation the rights | ||
| # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
| # copies of the Software, and to permit persons to whom the Software is | ||
| # furnished to do so, subject to the following conditions: | ||
| # | ||
| # The above copyright notice and this permission notice shall be included in all | ||
| # copies or substantial portions of the Software. | ||
| # | ||
| # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
| # SOFTWARE. | ||
| """Module containing the Driving Dimension service implementation for v0.""" | ||
|
|
||
| import grpc | ||
|
|
||
| from ansys.geometry.core.errors import protect_grpc | ||
|
|
||
| from ..base.driving_dimensions import GRPCDrivingDimensionsService | ||
|
|
||
|
|
||
| class GRPCDrivingDimensionsServiceV0(GRPCDrivingDimensionsService): | ||
| """Driving Dimension service for gRPC communication with the Geometry server. | ||
|
|
||
| This class provides methods to interact with the Geometry server's | ||
| driving dimension service. It is specifically designed for the v0 version of the | ||
| Geometry API. | ||
|
|
||
| Parameters | ||
| ---------- | ||
| channel : grpc.Channel | ||
| The gRPC channel to the server. | ||
| """ | ||
|
|
||
| @protect_grpc | ||
| def __init__(self, channel: grpc.Channel): # noqa: D102 | ||
| from ansys.api.dbu.v0.drivingdimensions_pb2_grpc import DrivingDimensionsStub | ||
|
|
||
| self.stub = DrivingDimensionsStub(channel) | ||
|
|
||
| @protect_grpc | ||
| def get_all_parameters(self, **kwargs) -> dict: # noqa: D102 | ||
| from ansys.api.dbu.v0.drivingdimensions_pb2 import GetAllRequest | ||
|
|
||
| from .conversions import from_grpc_driving_dimension_to_driving_dimension | ||
|
|
||
| # Call the gRPC service | ||
| response = self.stub.GetAll(GetAllRequest()) | ||
|
|
||
| # Return the response - formatted as a dictionary | ||
| return { | ||
| "parameters": [ | ||
| from_grpc_driving_dimension_to_driving_dimension(param) | ||
| for param in response.driving_dimensions | ||
| ], | ||
| } | ||
|
|
||
| @protect_grpc | ||
| def set_parameter(self, **kwargs) -> dict: # noqa: D102 | ||
| from ansys.api.dbu.v0.drivingdimensions_pb2 import UpdateRequest | ||
|
|
||
| from .conversions import ( | ||
| from_driving_dimension_to_grpc_driving_dimension, | ||
| from_grpc_update_status_to_parameter_update_status, | ||
| ) | ||
|
|
||
| # Create the request - assumes all inputs are valid and of the proper type | ||
| request = UpdateRequest( | ||
| driving_dimension=from_driving_dimension_to_grpc_driving_dimension( | ||
| kwargs["driving_dimension"] | ||
| ), | ||
| ) | ||
|
|
||
| # Call the gRPC service | ||
| response = self.stub.UpdateParameter(request) | ||
|
|
||
| # Return the response - formatted as a dictionary | ||
| return { | ||
| "status": from_grpc_update_status_to_parameter_update_status(response.status), | ||
| } |
56 changes: 56 additions & 0 deletions
56
src/ansys/geometry/core/_grpc/_services/v1/driving_dimensions.py
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| # Copyright (C) 2023 - 2025 ANSYS, Inc. and/or its affiliates. | ||
| # SPDX-License-Identifier: MIT | ||
| # | ||
| # | ||
| # Permission is hereby granted, free of charge, to any person obtaining a copy | ||
| # of this software and associated documentation files (the "Software"), to deal | ||
| # in the Software without restriction, including without limitation the rights | ||
| # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
| # copies of the Software, and to permit persons to whom the Software is | ||
| # furnished to do so, subject to the following conditions: | ||
| # | ||
| # The above copyright notice and this permission notice shall be included in all | ||
| # copies or substantial portions of the Software. | ||
| # | ||
| # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
| # SOFTWARE. | ||
| """Module containing the Driving Dimension service implementation for v1.""" | ||
|
|
||
| import grpc | ||
|
|
||
| from ansys.geometry.core.errors import protect_grpc | ||
|
|
||
| from ..base.driving_dimensions import GRPCDrivingDimensionsService | ||
|
|
||
|
|
||
| class GRPCDrivingDimensionsServiceV1(GRPCDrivingDimensionsService): | ||
| """Driving Dimensions service for gRPC communication with the Geometry server. | ||
|
|
||
| This class provides methods to interact with the Geometry server's | ||
| Driving Dimensions service. It is specifically designed for the v1 version | ||
| of the Geometry API. | ||
|
|
||
| Parameters | ||
| ---------- | ||
| channel : grpc.Channel | ||
| The gRPC channel to the server. | ||
| """ | ||
|
|
||
| @protect_grpc | ||
| def __init__(self, channel: grpc.Channel): # noqa: D102 | ||
| from ansys.api.geometry.v1.drivingdimensions_pb2_grpc import DrivingDimensionsStub | ||
|
|
||
| self.stub = DrivingDimensionsStub(channel) | ||
|
|
||
| @protect_grpc | ||
| def get_all_parameters(self, **kwargs) -> dict: # noqa: D102 | ||
| raise NotImplementedError | ||
|
|
||
| @protect_grpc | ||
| def set_parameter(self, **kwargs) -> dict: # noqa: D102 | ||
| raise NotImplementedError |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.