Skip to content

Commit a2d17c3

Browse files
pyansys-ci-botrlaghacbellot000
authored
Update generated code for DPF 242_description on master (#1457)
* update generated code * describe (cherry picked from commit 9b04d71) --------- Co-authored-by: rlagha <[email protected]> Co-authored-by: cbellot <[email protected]>
1 parent f29be59 commit a2d17c3

19 files changed

+207
-61
lines changed

src/ansys/dpf/core/core.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -598,7 +598,17 @@ def _description(self, dpf_entity_message):
598598
server=self._server(),
599599
)
600600
data.get_ownership()
601-
return self._api.data_processing_description_string(data=data)
601+
try:
602+
if server_meet_version("8.1", self._server()):
603+
size = integral_types.MutableUInt64(0)
604+
out = self._api.data_processing_description_string_with_size(data, size)
605+
if out is not None and not isinstance(out, str):
606+
return out.decode('utf-8')
607+
else:
608+
return self._api.data_processing_description_string(data=data)
609+
except Exception as e:
610+
warnings.warn(str(e.args))
611+
return ""
602612

603613
def _get_separator(self, path):
604614
s1 = len(path.split("\\"))

src/ansys/dpf/gate/data_processing_grpcapi.py

Lines changed: 38 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22
import re
33
import weakref
44

5+
import numpy as np
6+
57
from ansys.dpf.gate.generated import data_processing_abstract_api
6-
from ansys.dpf.gate import errors, object_handler, misc
8+
from ansys.dpf.gate import errors, object_handler, misc, grpc_stream_helpers
79

810

911
# -------------------------------------------------------------------------------
@@ -207,31 +209,42 @@ def data_processing_get_server_version_on_client(client, major, minor):
207209

208210
@staticmethod
209211
def data_processing_description_string(data):
210-
try:
211-
data_obj = data._internal_obj
212-
from ansys.grpc.dpf import base_pb2, collection_pb2
213-
request = base_pb2.DescribeRequest()
214-
if isinstance(data_obj.id, int):
215-
request.dpf_type_id = data_obj.id
216-
else:
217-
request.dpf_type_id = data_obj.id.id
218-
serv_to_test = data._server
219-
if not serv_to_test:
220-
return ""
221-
client = None
222-
if serv_to_test.has_client():
223-
client = serv_to_test.client
224-
else:
225-
return ""
226-
if isinstance(data_obj, collection_pb2.Collection):
227-
from ansys.dpf.gate import collection_grpcapi
228-
collection_grpcapi.CollectionGRPCAPI.init_collection_environment(data)
229-
response = collection_grpcapi._get_stub(data._server.client).Describe(request)
230-
else:
231-
response = _get_stub(client).Describe(request)
232-
return response.description
233-
except:
212+
data_obj = data._internal_obj
213+
from ansys.grpc.dpf import base_pb2, collection_pb2
214+
request = base_pb2.DescribeRequest()
215+
if isinstance(data_obj.id, int):
216+
request.dpf_type_id = data_obj.id
217+
else:
218+
request.dpf_type_id = data_obj.id.id
219+
serv_to_test = data._server
220+
if not serv_to_test:
234221
return ""
222+
client = None
223+
if serv_to_test.has_client():
224+
client = serv_to_test.client
225+
else:
226+
return ""
227+
if isinstance(data_obj, collection_pb2.Collection):
228+
from ansys.dpf.gate import collection_grpcapi
229+
collection_grpcapi.CollectionGRPCAPI.init_collection_environment(data)
230+
response = collection_grpcapi._get_stub(data._server.client).Describe(request)
231+
else:
232+
response = _get_stub(client).Describe(request)
233+
return response.description
234+
235+
@staticmethod
236+
def data_processing_description_string_with_size(data, size):
237+
from ansys.grpc.dpf import base_pb2
238+
request = base_pb2.DescribeRequest()
239+
if isinstance(data._internal_obj.id, int):
240+
request.dpf_type_id = data._internal_obj.id
241+
else:
242+
request.dpf_type_id = data._internal_obj.id.id
243+
service = _get_stub(data._server.client).DescribeStreamed(request)
244+
dtype = np.byte
245+
out = grpc_stream_helpers._data_get_chunk_(dtype, service, True, get_array=lambda chunk: chunk.array.array)
246+
size.val = out.size
247+
return bytes(out)
235248

236249
@staticmethod
237250
def data_processing_upload_file(client, file_path, to_server_file_path, use_tmp_dir):

src/ansys/dpf/gate/generated/any_abstract_api.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,3 +259,7 @@ def any_new_from_string_with_size_on_client(client, any, size):
259259
def any_new_from_double_on_client(client, any):
260260
raise NotImplementedError
261261

262+
@staticmethod
263+
def any_get_copy(id, client):
264+
raise NotImplementedError
265+

src/ansys/dpf/gate/generated/any_capi.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -581,3 +581,12 @@ def any_new_from_double_on_client(client, any):
581581
raise errors.DPFServerException(sError.value)
582582
return res
583583

584+
@staticmethod
585+
def any_get_copy(id, client):
586+
errorSize = ctypes.c_int(0)
587+
sError = ctypes.c_wchar_p()
588+
res = capi.dll.Any_getCopy(utils.to_int32(id), client._internal_obj if client is not None else None, ctypes.byref(utils.to_int32(errorSize)), ctypes.byref(sError))
589+
if errorSize.value != 0:
590+
raise errors.DPFServerException(sError.value)
591+
return res
592+

src/ansys/dpf/gate/generated/capi.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,10 @@ def load_api(path):
268268
dll.Any_newFrom_Double_on_client.argtypes = (ctypes.c_void_p, ctypes.c_double, ctypes.POINTER(ctypes.c_int32), ctypes.POINTER(ctypes.c_wchar_p), )
269269
dll.Any_newFrom_Double_on_client.restype = ctypes.c_void_p
270270

271+
if hasattr(dll, "Any_getCopy"):
272+
dll.Any_getCopy.argtypes = (ctypes.c_int32, ctypes.c_void_p, ctypes.POINTER(ctypes.c_int32), ctypes.POINTER(ctypes.c_wchar_p), )
273+
dll.Any_getCopy.restype = ctypes.c_void_p
274+
271275
#-------------------------------------------------------------------------------
272276
# Client
273277
#-------------------------------------------------------------------------------
@@ -687,6 +691,10 @@ def load_api(path):
687691
dll.DataProcessing_descriptionString.argtypes = (ctypes.c_void_p, ctypes.POINTER(ctypes.c_int32), ctypes.POINTER(ctypes.c_wchar_p), )
688692
dll.DataProcessing_descriptionString.restype = ctypes.POINTER(ctypes.c_char)
689693

694+
if hasattr(dll, "DataProcessing_descriptionString_with_size"):
695+
dll.DataProcessing_descriptionString_with_size.argtypes = (ctypes.c_void_p, ctypes.POINTER(ctypes.c_uint64), ctypes.POINTER(ctypes.c_int32), ctypes.POINTER(ctypes.c_wchar_p), )
696+
dll.DataProcessing_descriptionString_with_size.restype = ctypes.POINTER(ctypes.c_char)
697+
690698
if hasattr(dll, "DataProcessing_deleteString"):
691699
dll.DataProcessing_deleteString.argtypes = (ctypes.POINTER(ctypes.c_char), ctypes.POINTER(ctypes.c_int32), ctypes.POINTER(ctypes.c_wchar_p), )
692700
dll.DataProcessing_deleteString.restype = None
@@ -2480,6 +2488,10 @@ def load_api(path):
24802488
dll.dpf_Operator_delete.argtypes = (ctypes.c_void_p, ctypes.POINTER(ctypes.c_int32), ctypes.POINTER(ctypes.c_wchar_p), )
24812489
dll.dpf_Operator_delete.restype = None
24822490

2491+
if hasattr(dll, "Operator_connect_DpfType"):
2492+
dll.Operator_connect_DpfType.argtypes = (ctypes.c_void_p, ctypes.c_int32, ctypes.c_void_p, ctypes.POINTER(ctypes.c_int32), ctypes.POINTER(ctypes.c_wchar_p), )
2493+
dll.Operator_connect_DpfType.restype = None
2494+
24832495
if hasattr(dll, "Operator_connect_int"):
24842496
dll.Operator_connect_int.argtypes = (ctypes.c_void_p, ctypes.c_int32, ctypes.c_int32, ctypes.POINTER(ctypes.c_int32), ctypes.POINTER(ctypes.c_wchar_p), )
24852497
dll.Operator_connect_int.restype = None
@@ -3979,6 +3991,10 @@ def load_api(path):
39793991
dll.GenericDataContainer_setPropertyAny.argtypes = (ctypes.c_void_p, ctypes.POINTER(ctypes.c_char), ctypes.c_void_p, ctypes.POINTER(ctypes.c_int32), ctypes.POINTER(ctypes.c_wchar_p), )
39803992
dll.GenericDataContainer_setPropertyAny.restype = None
39813993

3994+
if hasattr(dll, "GenericDataContainer_setPropertyDpfType"):
3995+
dll.GenericDataContainer_setPropertyDpfType.argtypes = (ctypes.c_void_p, ctypes.POINTER(ctypes.c_char), ctypes.c_void_p, ctypes.POINTER(ctypes.c_int32), ctypes.POINTER(ctypes.c_wchar_p), )
3996+
dll.GenericDataContainer_setPropertyDpfType.restype = None
3997+
39823998
if hasattr(dll, "GenericDataContainer_getPropertyTypes"):
39833999
dll.GenericDataContainer_getPropertyTypes.argtypes = (ctypes.c_void_p, ctypes.POINTER(ctypes.c_int32), ctypes.POINTER(ctypes.c_wchar_p), )
39844000
dll.GenericDataContainer_getPropertyTypes.restype = ctypes.c_void_p
@@ -4366,6 +4382,10 @@ def load_api(path):
43664382
dll.WorkFlow_write_to_text.argtypes = (ctypes.c_void_p, ctypes.POINTER(ctypes.c_int32), ctypes.POINTER(ctypes.c_wchar_p), )
43674383
dll.WorkFlow_write_to_text.restype = ctypes.POINTER(ctypes.c_char)
43684384

4385+
if hasattr(dll, "WorkFlow_connect_DpfType"):
4386+
dll.WorkFlow_connect_DpfType.argtypes = (ctypes.c_void_p, ctypes.POINTER(ctypes.c_char), ctypes.c_void_p, ctypes.POINTER(ctypes.c_int32), ctypes.POINTER(ctypes.c_wchar_p), )
4387+
dll.WorkFlow_connect_DpfType.restype = None
4388+
43694389
if hasattr(dll, "WorkFlow_connect_int"):
43704390
dll.WorkFlow_connect_int.argtypes = (ctypes.c_void_p, ctypes.POINTER(ctypes.c_char), ctypes.c_int32, ctypes.POINTER(ctypes.c_int32), ctypes.POINTER(ctypes.c_wchar_p), )
43714391
dll.WorkFlow_connect_int.restype = None

src/ansys/dpf/gate/generated/data_processing_abstract_api.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,10 @@ def data_processing_unknown_has_given_hash(data, expected_type_hash):
7171
def data_processing_description_string(data):
7272
raise NotImplementedError
7373

74+
@staticmethod
75+
def data_processing_description_string_with_size(data, size):
76+
raise NotImplementedError
77+
7478
@staticmethod
7579
def data_processing_delete_string(var1):
7680
raise NotImplementedError

src/ansys/dpf/gate/generated/data_processing_capi.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,17 @@ def data_processing_description_string(data):
145145
capi.dll.DataProcessing_String_post_event(res, ctypes.byref(errorSize), ctypes.byref(sError))
146146
return newres
147147

148+
@staticmethod
149+
def data_processing_description_string_with_size(data, size):
150+
errorSize = ctypes.c_int(0)
151+
sError = ctypes.c_wchar_p()
152+
res = capi.dll.DataProcessing_descriptionString_with_size(data._internal_obj if data is not None else None, utils.to_uint64_ptr(size), ctypes.byref(utils.to_int32(errorSize)), ctypes.byref(sError))
153+
if errorSize.value != 0:
154+
raise errors.DPFServerException(sError.value)
155+
newres = ctypes.string_at(res, size.val.value)
156+
capi.dll.DataProcessing_String_post_event(res, ctypes.byref(errorSize), ctypes.byref(sError))
157+
return newres
158+
148159
@staticmethod
149160
def data_processing_delete_string(var1):
150161
errorSize = ctypes.c_int(0)

src/ansys/dpf/gate/generated/generic_data_container_abstract_api.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ def generic_data_container_get_property_any(container, name):
2323
def generic_data_container_set_property_any(container, name, any):
2424
raise NotImplementedError
2525

26+
@staticmethod
27+
def generic_data_container_set_property_dpf_type(container, name, any):
28+
raise NotImplementedError
29+
2630
@staticmethod
2731
def generic_data_container_get_property_types(container):
2832
raise NotImplementedError

src/ansys/dpf/gate/generated/generic_data_container_capi.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,15 @@ def generic_data_container_set_property_any(container, name, any):
4444
raise errors.DPFServerException(sError.value)
4545
return res
4646

47+
@staticmethod
48+
def generic_data_container_set_property_dpf_type(container, name, any):
49+
errorSize = ctypes.c_int(0)
50+
sError = ctypes.c_wchar_p()
51+
res = capi.dll.GenericDataContainer_setPropertyDpfType(container._internal_obj if container is not None else None, utils.to_char_ptr(name), any._internal_obj if any is not None else None, ctypes.byref(utils.to_int32(errorSize)), ctypes.byref(sError))
52+
if errorSize.value != 0:
53+
raise errors.DPFServerException(sError.value)
54+
return res
55+
4756
@staticmethod
4857
def generic_data_container_get_property_types(container):
4958
errorSize = ctypes.c_int(0)

src/ansys/dpf/gate/generated/operator_abstract_api.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@ def dpf_operator_by_name(operatorName):
5555
def dpf_operator_delete(op):
5656
raise NotImplementedError
5757

58+
@staticmethod
59+
def operator_connect_dpf_type(op, iPin, value):
60+
raise NotImplementedError
61+
5862
@staticmethod
5963
def operator_connect_int(op, iPin, value):
6064
raise NotImplementedError

0 commit comments

Comments
 (0)