Skip to content

Commit 4dd4157

Browse files
new upload method using the new open rpc method
1 parent b6cd466 commit 4dd4157

File tree

1 file changed

+21
-5
lines changed
  • src/ansys/geometry/core/_grpc/_services/v1

1 file changed

+21
-5
lines changed

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

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,10 @@ class GRPCDesignsServiceV1(GRPCDesignsService): # pragma: no cover
4444
@protect_grpc
4545
def __init__(self, channel: grpc.Channel): # noqa: D102
4646
from ansys.api.discovery.v1.design.designdoc_pb2_grpc import DesignDocStub
47+
from ansys.api.discovery.v1.commands.file_pb2_grpc import FileStub
4748

48-
self.stub = DesignDocStub(channel)
49+
self.designs_stub = DesignDocStub(channel)
50+
self.file_stub = FileStub(channel)
4951

5052
@protect_grpc
5153
def open(self, **kwargs) -> dict: # noqa: D102
@@ -89,22 +91,36 @@ def get_active(self, **kwargs) -> dict: # noqa: D102
8991

9092
@protect_grpc
9193
def upload_file(self, **kwargs) -> dict: # noqa: D102
92-
raise NotImplementedError
94+
from ansys.api.discovery.v1.commands.file_pb2 import OpenRequest
95+
96+
# Create the request - assumes all inputs are valid and of the proper type
97+
request = OpenRequest(
98+
data=kwargs["data"],
99+
#file_name=kwargs["file_name"],
100+
#open=kwargs["open_file"],
101+
import_options=kwargs["import_options"].to_dict(),
102+
)
103+
104+
# Call the gRPC service
105+
response = self.file_stub.Open(request)
106+
107+
# Return the response - formatted as a dictionary
108+
return {"file_path": response.file_path}
93109

94110
@protect_grpc
95111
def upload_file_stream(self, **kwargs) -> dict: # noqa: D102
96-
from ansys.api.discovery.v1.commands_pb2 import UploadFileRequest
112+
from ansys.api.discovery.v1.commands.file_pb2 import OpenRequest
97113

98114
# Create the request - assumes all inputs are valid and of the proper type
99-
request = UploadFileRequest(
115+
request = OpenRequest(
100116
data=kwargs["data"],
101117
file_name=kwargs["file_name"],
102118
open=kwargs["open_file"],
103119
import_options=kwargs["import_options"].to_dict(),
104120
)
105121

106122
# Call the gRPC service
107-
response = self.commands_stub.UploadFile(request)
123+
response = self.file_stub.Open(request)
108124

109125
# Return the response - formatted as a dictionary
110126
return {"file_path": response.file_path}

0 commit comments

Comments
 (0)