-
Notifications
You must be signed in to change notification settings - Fork 22
chore: v1 implementation of beam stub #2444
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
Open
smereu
wants to merge
35
commits into
main
Choose a base branch
from
ci/v1_implementation_of_beam_stub
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+206
−13
Open
Changes from 30 commits
Commits
Show all changes
35 commits
Select commit
Hold shift + click to select a range
97eb31a
chore: update CHANGELOG for v0.9.0 (#1753)
pyansys-ci-bot 1547839
Merge branch 'main' of https://github.com/ansys/pyansys-geometry
smereu 5a48878
Merge branch 'main' of https://github.com/ansys/pyansys-geometry
smereu 4109456
Merge branch 'main' of https://github.com/ansys/pyansys-geometry
smereu e00316b
Merge branch 'main' of https://github.com/ansys/pyansys-geometry
smereu 1afa37a
Merge branch 'main' of https://github.com/ansys/pyansys-geometry
smereu 7c595bb
Merge branch 'main' of https://github.com/ansys/pyansys-geometry
smereu 6a23076
Merge branch 'main' of https://github.com/ansys/pyansys-geometry
smereu 62ca792
Merge branch 'main' of https://github.com/ansys/pyansys-geometry
smereu 40c19c1
Merge branch 'main' of https://github.com/ansys/pyansys-geometry
smereu 40a13e2
Merge branch 'main' of https://github.com/ansys/pyansys-geometry
smereu 269ec5b
Merge branch 'main' of https://github.com/ansys/pyansys-geometry
smereu 6217f4a
Merge branch 'main' of https://github.com/ansys/pyansys-geometry
smereu 7a728c4
Merge branch 'main' of https://github.com/ansys/pyansys-geometry
smereu 6c462de
Merge branch 'main' of https://github.com/ansys/pyansys-geometry
smereu 3611a99
Merge branch 'main' of https://github.com/ansys/pyansys-geometry
smereu c5a4e86
Merge branch 'main' of https://github.com/ansys/pyansys-geometry
smereu ecd7567
Merge branch 'main' of https://github.com/ansys/pyansys-geometry
smereu 8b628a2
Merge branch 'main' of https://github.com/ansys/pyansys-geometry
smereu f55daa8
Merge branch 'main' of https://github.com/ansys/pyansys-geometry
smereu 38324c1
Merge branch 'main' of https://github.com/ansys/pyansys-geometry
smereu 18f6686
Merge branch 'main' of https://github.com/ansys/pyansys-geometry
smereu 6147028
Merge branch 'main' of https://github.com/ansys/pyansys-geometry
smereu 85a9d0b
Merge branch 'main' of https://github.com/ansys/pyansys-geometry
smereu a3de5c0
Merge branch 'main' of https://github.com/ansys/pyansys-geometry
smereu df4f408
Merge branch 'main' of https://github.com/ansys/pyansys-geometry
smereu b76d58b
v1 implementation of beam.py
smereu 4631b58
clean-up
smereu d11f4eb
chore: adding changelog file 2444.maintenance.md [dependabot-skip]
pyansys-ci-bot 6ff1241
Merge branch 'ci/v1_implementation_of_beam_stub' of https://github.co…
smereu 7d79c12
Update src/ansys/geometry/core/_grpc/_services/v1/beams.py
smereu 5145e88
Update src/ansys/geometry/core/_grpc/_services/v1/beams.py
smereu d3d826e
Merge branch 'main' into ci/v1_implementation_of_beam_stub
smereu f27357e
Misc fixes from code review
smereu 9b66b73
Merge branch 'ci/v1_implementation_of_beam_stub' of https://github.co…
smereu 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 @@ | ||
| update CHANGELOG for v0.9.0 |
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 @@ | ||
| Chore: v1 implementation of beam stub |
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 |
|---|---|---|
|
|
@@ -26,6 +26,16 @@ | |
| from ansys.geometry.core.errors import protect_grpc | ||
|
|
||
| from ..base.beams import GRPCBeamsService | ||
| from ..base.conversions import to_distance | ||
| from .conversions import ( | ||
| build_grpc_id, | ||
| from_grpc_curve_to_curve, | ||
| from_grpc_frame_to_frame, | ||
| from_grpc_material_to_material, | ||
| from_grpc_point_to_point3d, | ||
| from_plane_to_grpc_plane, | ||
| from_point3d_to_grpc_point, | ||
| ) | ||
|
|
||
|
|
||
| class GRPCBeamsServiceV1(GRPCBeamsService): | ||
|
|
@@ -43,26 +53,184 @@ class GRPCBeamsServiceV1(GRPCBeamsService): | |
|
|
||
| @protect_grpc | ||
| def __init__(self, channel: grpc.Channel): # noqa: D102 | ||
| from ansys.api.discovery.v1.assignments.beams import BeamsStub | ||
| from ansys.api.discovery.v1.engineeringdata.beamprofiledata_pb2_grpc import ( | ||
| BeamProfileDataStub, | ||
| ) | ||
|
|
||
| self.stub = BeamsStub(channel) | ||
| self.beam_commands_stub = BeamProfileDataStub | ||
|
|
||
| @protect_grpc | ||
| def create_beam_segments(self, **kwargs) -> dict: # noqa: D102 | ||
| raise NotImplementedError | ||
| from ansys.api.discovery.v1.commonmessages_pb2 import Line | ||
| from ansys.api.discovery.v1.engineeringdata.beamprofiledata_pb2 import ( | ||
| CreateBeamProfileSegmentsRequest, | ||
| CreateBeamProfileSegmentsRequestData, | ||
| ) | ||
|
|
||
| # Create the gRPC Line objects | ||
| lines = [] | ||
| for segment in kwargs["segments"]: | ||
| lines.append( | ||
| Line( | ||
| start=from_point3d_to_grpc_point(segment[0]), | ||
| end=from_point3d_to_grpc_point(segment[1]), | ||
| ) | ||
| ) | ||
|
Comment on lines
75
to
85
Contributor
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. Not your fault - this is wrong in v0 too :(. Can you change both to use the from_line_to_grpc_line conversion? |
||
|
|
||
| # Create the request - assumes all inputs are valid and of the proper type | ||
| request = CreateBeamProfileSegmentsRequest( | ||
| request_data=[ | ||
| CreateBeamProfileSegmentsRequestData( | ||
| profile_id=kwargs["profile_id"], | ||
smereu marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| parent_id=build_grpc_id(kwargs["parent_id"]), | ||
| lines=lines, | ||
| ) | ||
| ] | ||
| ) | ||
|
|
||
| # Call the gRPC service | ||
| response = self.beam_commands_stub.CreateSegments(request) | ||
|
|
||
| # Return the response - formatted as a dictionary | ||
| return { | ||
| "beam_ids": [ | ||
| [beam.id for beam in response_data.beams_ids] | ||
| for response_data in response.response_data | ||
| ] | ||
| } | ||
|
|
||
| @protect_grpc | ||
| def create_descriptive_beam_segments(self, **kwargs) -> dict: # noqa: D102 | ||
| raise NotImplementedError | ||
| from ansys.api.discovery.v1.commonmessages_pb2 import Line | ||
| from ansys.api.discovery.v1.engineeringdata.beamprofiledata_pb2 import ( | ||
| CreateBeamProfileSegmentsRequest, | ||
| CreateBeamProfileSegmentsRequestData, | ||
| ) | ||
|
|
||
| from ansys.geometry.core.shapes.parameterization import Interval, ParamUV | ||
|
|
||
| # Create the gRPC Line objects | ||
| lines = [] | ||
| for segment in kwargs["segments"]: | ||
| lines.append( | ||
| Line( | ||
| start=from_point3d_to_grpc_point(segment[0]), | ||
| end=from_point3d_to_grpc_point(segment[1]), | ||
| ) | ||
| ) | ||
smereu marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| # Create the request - assumes all inputs are valid and of the proper type | ||
| request = CreateBeamProfileSegmentsRequest( | ||
| request_data=[ | ||
| CreateBeamProfileSegmentsRequestData( | ||
| profile_id=kwargs["profile_id"], | ||
smereu marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| parent_id=build_grpc_id(kwargs["parent_id"]), | ||
| lines=lines, | ||
| ) | ||
| ] | ||
| ) | ||
|
|
||
| # Call the gRPC service | ||
| response = self.beam_commands_stub.CreateDescriptiveSegments(request) | ||
|
|
||
| # Return the response - formatted as a dictionary | ||
| return { | ||
| "created_beams": [ | ||
| { | ||
| "cross_section": { | ||
| "section_anchor": beam.cross_section.section_anchor, | ||
| "section_angle": beam.cross_section.section_angle, | ||
| "section_frame": from_grpc_frame_to_frame(beam.cross_section.section_frame), | ||
| "section_profile": [ | ||
| [ | ||
| { | ||
| "geometry": from_grpc_curve_to_curve(curve.curve), | ||
| "start": from_grpc_point_to_point3d(curve.start), | ||
| "end": from_grpc_point_to_point3d(curve.end), | ||
| "interval": Interval(curve.interval_start, curve.interval_end), | ||
| "length": to_distance(curve.length).value, | ||
| } | ||
| for curve in curve_list.curves | ||
| ] | ||
| for curve_list in beam.cross_section.section_profile | ||
| ], | ||
| }, | ||
| "properties": { | ||
| "area": beam.properties.area, | ||
| "centroid": ParamUV(beam.properties.centroid_x, beam.properties.centroid_y), | ||
| "warping_constant": beam.properties.warping_constant, | ||
| "ixx": beam.properties.ixx, | ||
| "ixy": beam.properties.ixy, | ||
| "iyy": beam.properties.iyy, | ||
| "shear_center": ParamUV( | ||
| beam.properties.shear_center_x, beam.properties.shear_center_y | ||
| ), | ||
| "torsional_constant": beam.properties.torsional_constant, | ||
| }, | ||
| "id": beam.id.id, | ||
| "start": from_grpc_point_to_point3d(beam.shape.start), | ||
| "end": from_grpc_point_to_point3d(beam.shape.end), | ||
| "name": beam.name, | ||
| "is_deleted": beam.is_deleted, | ||
| "is_reversed": beam.is_reversed, | ||
| "is_rigid": beam.is_rigid, | ||
| "material": from_grpc_material_to_material(beam.material), | ||
| "shape": { | ||
| "geometry": from_grpc_curve_to_curve(beam.shape.curve), | ||
| "start": from_grpc_point_to_point3d(beam.shape.start), | ||
| "end": from_grpc_point_to_point3d(beam.shape.end), | ||
| "interval": Interval(beam.shape.interval_start, beam.shape.interval_end), | ||
| "length": to_distance(beam.shape.length).value, | ||
| }, | ||
| "beam_type": beam.type, | ||
| } | ||
| for response_data in response.response_data | ||
| for beam in response_data.beams | ||
| ], | ||
| } | ||
|
|
||
| @protect_grpc | ||
| def delete_beam(self, **kwargs) -> dict: # noqa: D102 | ||
| raise NotImplementedError | ||
| from ansys.api.discovery.v1.commonmessages_pb2 import MultipleEntitiesRequest | ||
|
|
||
| # Create the request - assumes all inputs are valid and of the proper type | ||
| request = MultipleEntitiesRequest(ids=[build_grpc_id(kwargs["beam_id"])]) | ||
|
|
||
| # Call the gRPC service | ||
| _ = self.beam_commands_stub.Delete(request) | ||
|
|
||
| # Return the response - formatted as a dictionary | ||
| return {} | ||
|
|
||
| @protect_grpc | ||
| def delete_beam_profile(self, **kwargs) -> dict: # noqa: D102 | ||
| raise NotImplementedError | ||
|
|
||
| @protect_grpc | ||
| def create_beam_circular_profile(self, **kwargs) -> dict: # noqa: D102 | ||
| raise NotImplementedError | ||
| def create_beam_circular_profile(self, **kwargs) -> dict: # noqa: D10 | ||
| from ansys.api.discovery.v1.engineeringdata.beamprofiledata_pb2 import ( | ||
| CreateBeamProfileCircularRequest, | ||
| CreateBeamProfileCircularRequestData, | ||
| ) | ||
|
|
||
| from .conversions import from_length_to_grpc_quantity | ||
|
|
||
| # Create the request - assumes all inputs are valid and of the proper type | ||
| request = CreateBeamProfileCircularRequest( | ||
| request_data=[ | ||
| CreateBeamProfileCircularRequestData( | ||
| origin=from_point3d_to_grpc_point(kwargs["center"]), | ||
| radius=from_length_to_grpc_quantity(kwargs["radius"]), | ||
| plane=from_plane_to_grpc_plane(kwargs["plane"]), | ||
| name=kwargs["name"], | ||
| ) | ||
| ] | ||
| ) | ||
|
|
||
| # Call the gRPC service | ||
| response = self.beam_commands_stub.CreateCircular(request) | ||
|
|
||
| # Return the response - formatted as a dictionary | ||
| # Note: response.ids is a repeated field, we return the first one | ||
| created_beam_entity = response.ids[0] | ||
| return {"id": created_beam_entity.id} | ||
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.