Skip to content

Commit 40b5941

Browse files
Merge branch 'feat/grpc-common-layer-refactoring' of https://github.com/ansys/pyansys-geometry into feat/grpc-common-layer-refactoring
2 parents 41e790a + df56e2c commit 40b5941

File tree

8 files changed

+136
-71
lines changed

8 files changed

+136
-71
lines changed

.pre-commit-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ exclude: "tests/integration/files"
77
repos:
88

99
- repo: https://github.com/astral-sh/ruff-pre-commit
10-
rev: v0.11.4
10+
rev: v0.11.5
1111
hooks:
1212
- id: ruff
1313
- id: ruff-format
@@ -35,7 +35,7 @@ repos:
3535

3636
# this validates our github workflow files
3737
- repo: https://github.com/python-jsonschema/check-jsonschema
38-
rev: 0.32.1
38+
rev: 0.33.0
3939
hooks:
4040
- id: check-github-workflows
4141

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pre-commit automatic update

doc/changelog.d/1912.added.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
repair tools refactoring

src/ansys/geometry/core/_grpc/_services/_service.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,7 @@ def named_selection(self) -> GRPCNamedSelectionService:
182182
def repair_tools(self) -> GRPCRepairToolsService:
183183
if not self._repair_tools:
184184
from .v0.repair_tools import GRPCRepairToolsServiceV0
185+
185186
# TODO: Add V1 later
186187
self._repair_tools = GRPCRepairToolsServiceV0(self.channel)
187188
return self._repair_tools

src/ansys/geometry/core/_grpc/_services/base/repair_tools.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,6 @@
2626
import grpc
2727

2828

29-
from abc import ABC, abstractmethod
30-
import grpc
31-
3229
class GRPCRepairToolsService(ABC):
3330
def __init__(self, channel: grpc.Channel):
3431
pass

src/ansys/geometry/core/_grpc/_services/v0/repair_tools.py

Lines changed: 36 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,15 @@
2626
geometry issues, such as split edges, extra edges, duplicate faces, and more.
2727
"""
2828

29-
from abc import ABC, abstractmethod
29+
from google.protobuf.wrappers_pb2 import BoolValue, DoubleValue
3030
import grpc
31-
from ..base.repair_tools import GRPCRepairToolsService
31+
3232
from ansys.geometry.core.errors import protect_grpc
33-
from google.protobuf.wrappers_pb2 import BoolValue, DoubleValue
3433

34+
from ..base.repair_tools import GRPCRepairToolsService
3535

3636

3737
class GRPCRepairToolsServiceV0(GRPCRepairToolsService):
38-
3938
@protect_grpc
4039
def __init__(self, channel: grpc.Channel):
4140
from ansys.api.geometry.v0.repairtools_pb2_grpc import RepairToolsStub
@@ -44,9 +43,8 @@ def __init__(self, channel: grpc.Channel):
4443

4544
@protect_grpc
4645
def find_split_edges(self, **kwargs):
47-
4846
from ansys.api.geometry.v0.repairtools_pb2 import FindSplitEdgesRequest
49-
47+
5048
request = FindSplitEdgesRequest(
5149
bodies_or_faces=kwargs["bodies_or_faces"],
5250
angle=kwargs["angle"],
@@ -57,86 +55,101 @@ def find_split_edges(self, **kwargs):
5755
@protect_grpc
5856
def find_extra_edges(self, **kwargs):
5957
from ansys.api.geometry.v0.repairtools_pb2 import FindExtraEdgesRequest
58+
6059
request = FindExtraEdgesRequest(selection=kwargs["selection"])
6160
return self.stub.FindExtraEdges(request)
6261

6362
@protect_grpc
6463
def find_inexact_edges(self, **kwargs):
6564
from ansys.api.geometry.v0.repairtools_pb2 import FindInexactEdgesRequest
65+
6666
request = FindInexactEdgesRequest(selection=kwargs["selection"])
67-
return self.stub.FindInexactEdges(request)
68-
69-
67+
return self.stub.FindInexactEdges(request)
68+
7069
@protect_grpc
7170
def find_short_edges(self, **kwargs):
7271
from ansys.api.geometry.v0.repairtools_pb2 import FindShortEdgesRequest
72+
7373
request = FindShortEdgesRequest(
7474
selection=kwargs["selection"],
7575
max_edge_length=DoubleValue(value=kwargs["length"]),
7676
)
7777
return self.stub.FindShortEdges(request)
78-
78+
7979
@protect_grpc
8080
def find_duplicate_faces(self, **kwargs):
8181
from ansys.api.geometry.v0.repairtools_pb2 import FindDuplicateFacesRequest
82+
8283
request = FindDuplicateFacesRequest(faces=kwargs["faces"])
8384
return self.stub.FindDuplicateFaces(request)
8485

85-
8686
@protect_grpc
8787
def find_missing_faces(self, **kwargs):
8888
from ansys.api.geometry.v0.repairtools_pb2 import FindMissingFacesRequest
89+
8990
request = FindMissingFacesRequest(faces=kwargs["faces"])
90-
return self.stub.FindMissingFaces(request)
91+
return self.stub.FindMissingFaces(request)
9192

9293
@protect_grpc
9394
def find_small_faces(self, **kwargs):
9495
from ansys.api.geometry.v0.repairtools_pb2 import FindSmallFacesRequest
96+
9597
request = FindSmallFacesRequest(selection=kwargs["selection"])
9698
return self.stub.FindSmallFaces(request)
97-
99+
98100
@protect_grpc
99101
def find_stitch_faces(self, **kwargs):
100102
from ansys.api.geometry.v0.repairtools_pb2 import FindStitchFacesRequest
103+
101104
request = FindStitchFacesRequest(faces=kwargs["faces"])
102105
return self.stub.FindStitchFaces(request)
103-
106+
104107
@protect_grpc
105108
def find_simplify(self, **kwargs):
106109
from ansys.api.geometry.v0.repairtools_pb2 import FindAdjustSimplifyRequest
110+
107111
request = FindAdjustSimplifyRequest(selection=kwargs["selection"])
108112
return self.stub.FindAdjustSimplify(request)
109-
113+
110114
@protect_grpc
111115
def find_and_fix_simplify(self, **kwargs):
112116
from ansys.api.geometry.v0.repairtools_pb2 import FindAdjustSimplifyRequest
117+
113118
request = FindAdjustSimplifyRequest(
114119
selection=kwargs["selection"],
115120
comprehensive=kwargs["comprehensive_result"],
116121
)
117-
return self.stub.FindAndSimplify(request)
118-
122+
return self.stub.FindAndSimplify(request)
123+
119124
@protect_grpc
120125
def inspect_geometry(self, **kwargs):
121126
from ansys.api.geometry.v0.repairtools_pb2 import InspectGeometryRequest
127+
122128
request = InspectGeometryRequest(bodies=kwargs.get("bodies", []))
123129
return self.stub.InspectGeometry(request)
124-
130+
125131
@protect_grpc
126132
def repair_geometry(self, **kwargs):
127133
from ansys.api.geometry.v0.repairtools_pb2 import RepairGeometryRequest
134+
128135
request = RepairGeometryRequest(bodies=kwargs.get("bodies", []))
129136
return self.stub.RepairGeometry(request)
130-
137+
131138
@protect_grpc
132139
def find_interferences(self, **kwargs):
133140
from ansys.api.geometry.v0.repairtools_pb2 import FindInterferenceRequest
141+
134142
request = FindInterferenceRequest(
135143
bodies=kwargs["bodies"],
136144
cut_smaller_body=BoolValue(value=kwargs["cut_smaller_body"]),
137145
)
138-
return self.stub.FindInterference(request)
146+
return self.stub.FindInterference(request)
147+
148+
def find_and_fix_short_edges(self, **kwargs):
149+
raise NotImplementedError
150+
151+
def find_and_fix_extra_edges(self, **kwargs):
152+
raise NotImplementedError
139153

140-
def find_and_fix_short_edges(self, **kwargs): raise NotImplementedError
141-
def find_and_fix_extra_edges(self, **kwargs): raise NotImplementedError
142-
def find_and_fix_split_edges(self, **kwargs): raise NotImplementedError
154+
def find_and_fix_split_edges(self, **kwargs):
155+
raise NotImplementedError

src/ansys/geometry/core/_grpc/_services/v1/repair_tools.py

Lines changed: 49 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,14 @@
2121
# SOFTWARE.
2222
"""Module containing the repair tools service implementation (abstraction layer)."""
2323

24-
from abc import ABC, abstractmethod
24+
from abc import ABC
2525

2626
import grpc
2727

2828

2929
class GRPCRepairToolsServiceV1(ABC):
3030
"""Repair tools service for gRPC communication with the Geometry server.
31+
3132
Parameters
3233
----------
3334
channel : grpc.Channel
@@ -38,19 +39,50 @@ def __init__(self, channel: grpc.Channel):
3839
"""Initialize the MeasurementToolsService class."""
3940
pass # pragma: no cover
4041

41-
def find_split_edges(self, **kwargs): raise NotImplementedError
42-
def find_extra_edges(self, **kwargs): raise NotImplementedError
43-
def find_inexact_edges(self, **kwargs): raise NotImplementedError
44-
def find_short_edges(self, **kwargs): raise NotImplementedError
45-
def find_duplicate_faces(self, **kwargs): raise NotImplementedError
46-
def find_missing_faces(self, **kwargs): raise NotImplementedError
47-
def find_small_faces(self, **kwargs): raise NotImplementedError
48-
def find_stitch_faces(self, **kwargs): raise NotImplementedError
49-
def find_simplify(self, **kwargs): raise NotImplementedError
50-
def find_interferences(self, **kwargs): raise NotImplementedError
51-
def find_and_fix_short_edges(self, **kwargs): raise NotImplementedError
52-
def find_and_fix_extra_edges(self, **kwargs): raise NotImplementedError
53-
def find_and_fix_split_edges(self, **kwargs): raise NotImplementedError
54-
def find_and_fix_simplify(self, **kwargs): raise NotImplementedError
55-
def inspect_geometry(self, **kwargs): raise NotImplementedError
56-
def repair_geometry(self, **kwargs): raise NotImplementedError
42+
def find_split_edges(self, **kwargs):
43+
raise NotImplementedError
44+
45+
def find_extra_edges(self, **kwargs):
46+
raise NotImplementedError
47+
48+
def find_inexact_edges(self, **kwargs):
49+
raise NotImplementedError
50+
51+
def find_short_edges(self, **kwargs):
52+
raise NotImplementedError
53+
54+
def find_duplicate_faces(self, **kwargs):
55+
raise NotImplementedError
56+
57+
def find_missing_faces(self, **kwargs):
58+
raise NotImplementedError
59+
60+
def find_small_faces(self, **kwargs):
61+
raise NotImplementedError
62+
63+
def find_stitch_faces(self, **kwargs):
64+
raise NotImplementedError
65+
66+
def find_simplify(self, **kwargs):
67+
raise NotImplementedError
68+
69+
def find_interferences(self, **kwargs):
70+
raise NotImplementedError
71+
72+
def find_and_fix_short_edges(self, **kwargs):
73+
raise NotImplementedError
74+
75+
def find_and_fix_extra_edges(self, **kwargs):
76+
raise NotImplementedError
77+
78+
def find_and_fix_split_edges(self, **kwargs):
79+
raise NotImplementedError
80+
81+
def find_and_fix_simplify(self, **kwargs):
82+
raise NotImplementedError
83+
84+
def inspect_geometry(self, **kwargs):
85+
raise NotImplementedError
86+
87+
def repair_geometry(self, **kwargs):
88+
raise NotImplementedError

0 commit comments

Comments
 (0)