Skip to content

Commit

Permalink
Update generated code for DPF 242_description on master (#1457)
Browse files Browse the repository at this point in the history
* update generated code

* describe

(cherry picked from commit 9b04d71)

---------

Co-authored-by: rlagha <[email protected]>
Co-authored-by: cbellot <[email protected]>
  • Loading branch information
3 people authored Mar 8, 2024
1 parent f29be59 commit a2d17c3
Show file tree
Hide file tree
Showing 19 changed files with 207 additions and 61 deletions.
12 changes: 11 additions & 1 deletion src/ansys/dpf/core/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -598,7 +598,17 @@ def _description(self, dpf_entity_message):
server=self._server(),
)
data.get_ownership()
return self._api.data_processing_description_string(data=data)
try:
if server_meet_version("8.1", self._server()):
size = integral_types.MutableUInt64(0)
out = self._api.data_processing_description_string_with_size(data, size)
if out is not None and not isinstance(out, str):
return out.decode('utf-8')
else:
return self._api.data_processing_description_string(data=data)
except Exception as e:
warnings.warn(str(e.args))
return ""

def _get_separator(self, path):
s1 = len(path.split("\\"))
Expand Down
63 changes: 38 additions & 25 deletions src/ansys/dpf/gate/data_processing_grpcapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@
import re
import weakref

import numpy as np

from ansys.dpf.gate.generated import data_processing_abstract_api
from ansys.dpf.gate import errors, object_handler, misc
from ansys.dpf.gate import errors, object_handler, misc, grpc_stream_helpers


# -------------------------------------------------------------------------------
Expand Down Expand Up @@ -207,31 +209,42 @@ def data_processing_get_server_version_on_client(client, major, minor):

@staticmethod
def data_processing_description_string(data):
try:
data_obj = data._internal_obj
from ansys.grpc.dpf import base_pb2, collection_pb2
request = base_pb2.DescribeRequest()
if isinstance(data_obj.id, int):
request.dpf_type_id = data_obj.id
else:
request.dpf_type_id = data_obj.id.id
serv_to_test = data._server
if not serv_to_test:
return ""
client = None
if serv_to_test.has_client():
client = serv_to_test.client
else:
return ""
if isinstance(data_obj, collection_pb2.Collection):
from ansys.dpf.gate import collection_grpcapi
collection_grpcapi.CollectionGRPCAPI.init_collection_environment(data)
response = collection_grpcapi._get_stub(data._server.client).Describe(request)
else:
response = _get_stub(client).Describe(request)
return response.description
except:
data_obj = data._internal_obj
from ansys.grpc.dpf import base_pb2, collection_pb2
request = base_pb2.DescribeRequest()
if isinstance(data_obj.id, int):
request.dpf_type_id = data_obj.id
else:
request.dpf_type_id = data_obj.id.id
serv_to_test = data._server
if not serv_to_test:
return ""
client = None
if serv_to_test.has_client():
client = serv_to_test.client
else:
return ""
if isinstance(data_obj, collection_pb2.Collection):
from ansys.dpf.gate import collection_grpcapi
collection_grpcapi.CollectionGRPCAPI.init_collection_environment(data)
response = collection_grpcapi._get_stub(data._server.client).Describe(request)
else:
response = _get_stub(client).Describe(request)
return response.description

@staticmethod
def data_processing_description_string_with_size(data, size):
from ansys.grpc.dpf import base_pb2
request = base_pb2.DescribeRequest()
if isinstance(data._internal_obj.id, int):
request.dpf_type_id = data._internal_obj.id
else:
request.dpf_type_id = data._internal_obj.id.id
service = _get_stub(data._server.client).DescribeStreamed(request)
dtype = np.byte
out = grpc_stream_helpers._data_get_chunk_(dtype, service, True, get_array=lambda chunk: chunk.array.array)
size.val = out.size
return bytes(out)

@staticmethod
def data_processing_upload_file(client, file_path, to_server_file_path, use_tmp_dir):
Expand Down
4 changes: 4 additions & 0 deletions src/ansys/dpf/gate/generated/any_abstract_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,3 +259,7 @@ def any_new_from_string_with_size_on_client(client, any, size):
def any_new_from_double_on_client(client, any):
raise NotImplementedError

@staticmethod
def any_get_copy(id, client):
raise NotImplementedError

9 changes: 9 additions & 0 deletions src/ansys/dpf/gate/generated/any_capi.py
Original file line number Diff line number Diff line change
Expand Up @@ -581,3 +581,12 @@ def any_new_from_double_on_client(client, any):
raise errors.DPFServerException(sError.value)
return res

@staticmethod
def any_get_copy(id, client):
errorSize = ctypes.c_int(0)
sError = ctypes.c_wchar_p()
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))
if errorSize.value != 0:
raise errors.DPFServerException(sError.value)
return res

20 changes: 20 additions & 0 deletions src/ansys/dpf/gate/generated/capi.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,10 @@ def load_api(path):
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), )
dll.Any_newFrom_Double_on_client.restype = ctypes.c_void_p

if hasattr(dll, "Any_getCopy"):
dll.Any_getCopy.argtypes = (ctypes.c_int32, ctypes.c_void_p, ctypes.POINTER(ctypes.c_int32), ctypes.POINTER(ctypes.c_wchar_p), )
dll.Any_getCopy.restype = ctypes.c_void_p

#-------------------------------------------------------------------------------
# Client
#-------------------------------------------------------------------------------
Expand Down Expand Up @@ -687,6 +691,10 @@ def load_api(path):
dll.DataProcessing_descriptionString.argtypes = (ctypes.c_void_p, ctypes.POINTER(ctypes.c_int32), ctypes.POINTER(ctypes.c_wchar_p), )
dll.DataProcessing_descriptionString.restype = ctypes.POINTER(ctypes.c_char)

if hasattr(dll, "DataProcessing_descriptionString_with_size"):
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), )
dll.DataProcessing_descriptionString_with_size.restype = ctypes.POINTER(ctypes.c_char)

if hasattr(dll, "DataProcessing_deleteString"):
dll.DataProcessing_deleteString.argtypes = (ctypes.POINTER(ctypes.c_char), ctypes.POINTER(ctypes.c_int32), ctypes.POINTER(ctypes.c_wchar_p), )
dll.DataProcessing_deleteString.restype = None
Expand Down Expand Up @@ -2480,6 +2488,10 @@ def load_api(path):
dll.dpf_Operator_delete.argtypes = (ctypes.c_void_p, ctypes.POINTER(ctypes.c_int32), ctypes.POINTER(ctypes.c_wchar_p), )
dll.dpf_Operator_delete.restype = None

if hasattr(dll, "Operator_connect_DpfType"):
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), )
dll.Operator_connect_DpfType.restype = None

if hasattr(dll, "Operator_connect_int"):
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), )
dll.Operator_connect_int.restype = None
Expand Down Expand Up @@ -3979,6 +3991,10 @@ def load_api(path):
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), )
dll.GenericDataContainer_setPropertyAny.restype = None

if hasattr(dll, "GenericDataContainer_setPropertyDpfType"):
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), )
dll.GenericDataContainer_setPropertyDpfType.restype = None

if hasattr(dll, "GenericDataContainer_getPropertyTypes"):
dll.GenericDataContainer_getPropertyTypes.argtypes = (ctypes.c_void_p, ctypes.POINTER(ctypes.c_int32), ctypes.POINTER(ctypes.c_wchar_p), )
dll.GenericDataContainer_getPropertyTypes.restype = ctypes.c_void_p
Expand Down Expand Up @@ -4366,6 +4382,10 @@ def load_api(path):
dll.WorkFlow_write_to_text.argtypes = (ctypes.c_void_p, ctypes.POINTER(ctypes.c_int32), ctypes.POINTER(ctypes.c_wchar_p), )
dll.WorkFlow_write_to_text.restype = ctypes.POINTER(ctypes.c_char)

if hasattr(dll, "WorkFlow_connect_DpfType"):
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), )
dll.WorkFlow_connect_DpfType.restype = None

if hasattr(dll, "WorkFlow_connect_int"):
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), )
dll.WorkFlow_connect_int.restype = None
Expand Down
4 changes: 4 additions & 0 deletions src/ansys/dpf/gate/generated/data_processing_abstract_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ def data_processing_unknown_has_given_hash(data, expected_type_hash):
def data_processing_description_string(data):
raise NotImplementedError

@staticmethod
def data_processing_description_string_with_size(data, size):
raise NotImplementedError

@staticmethod
def data_processing_delete_string(var1):
raise NotImplementedError
Expand Down
11 changes: 11 additions & 0 deletions src/ansys/dpf/gate/generated/data_processing_capi.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,17 @@ def data_processing_description_string(data):
capi.dll.DataProcessing_String_post_event(res, ctypes.byref(errorSize), ctypes.byref(sError))
return newres

@staticmethod
def data_processing_description_string_with_size(data, size):
errorSize = ctypes.c_int(0)
sError = ctypes.c_wchar_p()
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))
if errorSize.value != 0:
raise errors.DPFServerException(sError.value)
newres = ctypes.string_at(res, size.val.value)
capi.dll.DataProcessing_String_post_event(res, ctypes.byref(errorSize), ctypes.byref(sError))
return newres

@staticmethod
def data_processing_delete_string(var1):
errorSize = ctypes.c_int(0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ def generic_data_container_get_property_any(container, name):
def generic_data_container_set_property_any(container, name, any):
raise NotImplementedError

@staticmethod
def generic_data_container_set_property_dpf_type(container, name, any):
raise NotImplementedError

@staticmethod
def generic_data_container_get_property_types(container):
raise NotImplementedError
Expand Down
9 changes: 9 additions & 0 deletions src/ansys/dpf/gate/generated/generic_data_container_capi.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,15 @@ def generic_data_container_set_property_any(container, name, any):
raise errors.DPFServerException(sError.value)
return res

@staticmethod
def generic_data_container_set_property_dpf_type(container, name, any):
errorSize = ctypes.c_int(0)
sError = ctypes.c_wchar_p()
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))
if errorSize.value != 0:
raise errors.DPFServerException(sError.value)
return res

@staticmethod
def generic_data_container_get_property_types(container):
errorSize = ctypes.c_int(0)
Expand Down
4 changes: 4 additions & 0 deletions src/ansys/dpf/gate/generated/operator_abstract_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ def dpf_operator_by_name(operatorName):
def dpf_operator_delete(op):
raise NotImplementedError

@staticmethod
def operator_connect_dpf_type(op, iPin, value):
raise NotImplementedError

@staticmethod
def operator_connect_int(op, iPin, value):
raise NotImplementedError
Expand Down
9 changes: 9 additions & 0 deletions src/ansys/dpf/gate/generated/operator_capi.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,15 @@ def dpf_operator_delete(op):
raise errors.DPFServerException(sError.value)
return res

@staticmethod
def operator_connect_dpf_type(op, iPin, value):
errorSize = ctypes.c_int(0)
sError = ctypes.c_wchar_p()
res = capi.dll.Operator_connect_DpfType(op._internal_obj if op is not None else None, utils.to_int32(iPin), value._internal_obj if value is not None else None, ctypes.byref(utils.to_int32(errorSize)), ctypes.byref(sError))
if errorSize.value != 0:
raise errors.DPFServerException(sError.value)
return res

@staticmethod
def operator_connect_int(op, iPin, value):
errorSize = ctypes.c_int(0)
Expand Down
4 changes: 4 additions & 0 deletions src/ansys/dpf/gate/generated/workflow_abstract_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,10 @@ def work_flow_load_swf_utf8(wf, file_name):
def work_flow_write_to_text(wf):
raise NotImplementedError

@staticmethod
def work_flow_connect_dpf_type(wf, pin_name, value):
raise NotImplementedError

@staticmethod
def work_flow_connect_int(wf, pin_name, value):
raise NotImplementedError
Expand Down
9 changes: 9 additions & 0 deletions src/ansys/dpf/gate/generated/workflow_capi.py
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,15 @@ def work_flow_write_to_text(wf):
capi.dll.DataProcessing_String_post_event(res, ctypes.byref(errorSize), ctypes.byref(sError))
return newres

@staticmethod
def work_flow_connect_dpf_type(wf, pin_name, value):
errorSize = ctypes.c_int(0)
sError = ctypes.c_wchar_p()
res = capi.dll.WorkFlow_connect_DpfType(wf._internal_obj if wf is not None else None, utils.to_char_ptr(pin_name), value._internal_obj if value is not None else None, ctypes.byref(utils.to_int32(errorSize)), ctypes.byref(sError))
if errorSize.value != 0:
raise errors.DPFServerException(sError.value)
return res

@staticmethod
def work_flow_connect_int(wf, pin_name, value):
errorSize = ctypes.c_int(0)
Expand Down
Binary file modified src/ansys/dpf/gatebin/Ans.Dpf.GrpcClient.dll
Binary file not shown.
Binary file modified src/ansys/dpf/gatebin/DPFClientAPI.dll
Binary file not shown.
Binary file modified src/ansys/dpf/gatebin/libAns.Dpf.GrpcClient.so
Binary file not shown.
Binary file modified src/ansys/dpf/gatebin/libDPFClientAPI.so
Binary file not shown.
Loading

0 comments on commit a2d17c3

Please sign in to comment.