ansys / pyfluent

Pythonic interface to Ansys Fluent
https://fluent.docs.pyansys.com
MIT License
276 stars 41 forks source link

Fluent exit doesn't work / hangs connected to pyworkbench launched process #2993

Closed a-abir closed 4 months ago

a-abir commented 4 months ago

πŸ” Before submitting the issue

🐞 Description of the bug

fluent.exit() only drops the connection; check_health() ==> "NOT_SERVING" not closed

_fluent.tui.closefluent() _fluent.executetui(command="/close-fluent") -- variants hangs the application

With fluent.tui.exit()

{
    "name": "AttributeError",
    "message": "'ValueError' object has no attribute 'details'",
    "stack": "---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
File c:\\Users\\Abria\\Documents\\Ansys\\Lib\\site-packages\\ansys\\fluent\\core\\services\\datamodel_tui.py:345, in TUIMenu.__getattribute__(self, name)
    342 path = self._path + [name]
    343 if PyMenu(
    344     self._service, self._version, self._mode, path
--> 345 ).get_child_names():
    346     return TUIMenu(self._service, self._version, self._mode, path)

File c:\\Users\\Abria\\Documents\\Ansys\\Lib\\site-packages\\ansys\\fluent\\core\\services\\datamodel_tui.py:218, in PyMenu.get_child_names(self, include_unavailable)
    215 attribute = DataModelProtoModule.Attribute.Name(
    216     DataModelProtoModule.Attribute.CHILD_NAMES
    217 ).lower()
--> 218 return self._service.get_attribute_value(
    219     self._path, attribute, include_unavailable
    220 )

File c:\\Users\\Abria\\Documents\\Ansys\\Lib\\site-packages\\ansys\\fluent\\core\\services\\datamodel_tui.py:145, in DatamodelService.get_attribute_value(self, path, attribute, include_unavailable)
    144     request.args[\"include_unavailable\"] = 1
--> 145 response = self._impl.get_attribute_value(request)
    146 return _convert_gvalue_to_value(response.value)

File c:\\Users\\Abria\\Documents\\Ansys\\Lib\\site-packages\\ansys\\fluent\\core\\services\\datamodel_tui.py:51, in DatamodelServiceImpl.get_attribute_value(self, request)
     50 \"\"\"GetAttributeValue RPC of DataModel service.\"\"\"
---> 51 return self._stub.GetAttributeValue(request, metadata=self._metadata)

File c:\\Users\\Abria\\Documents\\Ansys\\Lib\\site-packages\\grpc\\_interceptor.py:277, in _UnaryUnaryMultiCallable.__call__(self, request, timeout, metadata, credentials, wait_for_ready, compression)
    268 def __call__(
    269     self,
    270     request: Any,
   (...)
    275     compression: Optional[grpc.Compression] = None,
    276 ) -> Any:
--> 277     response, ignored_call = self._with_call(
    278         request,
    279         timeout=timeout,
    280         metadata=metadata,
    281         credentials=credentials,
    282         wait_for_ready=wait_for_ready,
    283         compression=compression,
    284     )
    285     return response

File c:\\Users\\Abria\\Documents\\Ansys\\Lib\\site-packages\\grpc\\_interceptor.py:329, in _UnaryUnaryMultiCallable._with_call(self, request, timeout, metadata, credentials, wait_for_ready, compression)
    327         return _FailureOutcome(exception, sys.exc_info()[2])
--> 329 call = self._interceptor.intercept_unary_unary(
    330     continuation, client_call_details, request
    331 )
    332 return call.result(), call

File c:\\Users\\Abria\\Documents\\Ansys\\Lib\\site-packages\\ansys\\fluent\\core\\services\\interceptors.py:122, in GrpcErrorInterceptor.intercept_unary_unary(self, continuation, client_call_details, request)
    121 \"\"\"Intercept unary-unary call for error state checking.\"\"\"
--> 122 return self._intercept_call(continuation, client_call_details, request)

File c:\\Users\\Abria\\Documents\\Ansys\\Lib\\site-packages\\ansys\\fluent\\core\\services\\interceptors.py:110, in GrpcErrorInterceptor._intercept_call(self, continuation, client_call_details, request)
    109 grpc_ex = response.exception()
--> 110 ex = RuntimeError(grpc_ex.details())
    111 ex.__context__ = grpc_ex

AttributeError: 'ValueError' object has no attribute 'details'

During handling of the above exception, another exception occurred:

AttributeError                            Traceback (most recent call last)
Cell In[56], line 3
      1 # fluent.tui.tui
      2 # print(fluent._fluent_connection.check_health())
----> 3 fluent.tui.exit()
      4 print(fluent._fluent_connection.check_health())

File c:\\Users\\Abria\\Documents\\Ansys\\Lib\\site-packages\\ansys\\fluent\\core\\services\\datamodel_tui.py:349, in TUIMenu.__getattribute__(self, name)
    347     return attr
    348 except AttributeError as ex:
--> 349     if name in dir(self):
    350         # for runtime submenus and commands which are not available during codegen
    351         path = self._path + [name]
    352         if PyMenu(
    353             self._service, self._version, self._mode, path
    354         ).get_child_names():

File c:\\Users\\Abria\\Documents\\Ansys\\Lib\\site-packages\\ansys\\fluent\\core\\services\\datamodel_tui.py:334, in TUIMenu.__dir__(self)
    329 def __dir__(self) -> list[str]:
    330     return [
    331         convert_tui_menu_to_func_name(x)
    332         for x in PyMenu(
    333             self._service, self._version, self._mode, self._path
--> 334         ).get_child_names()
    335     ]

File c:\\Users\\Abria\\Documents\\Ansys\\Lib\\site-packages\\ansys\\fluent\\core\\services\\datamodel_tui.py:218, in PyMenu.get_child_names(self, include_unavailable)
    203 \"\"\"Get the names of child menus.
    204 
    205 Parameters
   (...)
    213     Names of child menus.
    214 \"\"\"
    215 attribute = DataModelProtoModule.Attribute.Name(
    216     DataModelProtoModule.Attribute.CHILD_NAMES
    217 ).lower()
--> 218 return self._service.get_attribute_value(
    219     self._path, attribute, include_unavailable
    220 )

File c:\\Users\\Abria\\Documents\\Ansys\\Lib\\site-packages\\ansys\\fluent\\core\\services\\datamodel_tui.py:145, in DatamodelService.get_attribute_value(self, path, attribute, include_unavailable)
    143 if include_unavailable:
    144     request.args[\"include_unavailable\"] = 1
--> 145 response = self._impl.get_attribute_value(request)
    146 return _convert_gvalue_to_value(response.value)

File c:\\Users\\Abria\\Documents\\Ansys\\Lib\\site-packages\\ansys\\fluent\\core\\services\\datamodel_tui.py:51, in DatamodelServiceImpl.get_attribute_value(self, request)
     47 def get_attribute_value(
     48     self, request: DataModelProtoModule.GetAttributeValueRequest
     49 ) -> DataModelProtoModule.GetAttributeValueResponse:
     50     \"\"\"GetAttributeValue RPC of DataModel service.\"\"\"
---> 51     return self._stub.GetAttributeValue(request, metadata=self._metadata)

File c:\\Users\\Abria\\Documents\\Ansys\\Lib\\site-packages\\grpc\\_interceptor.py:277, in _UnaryUnaryMultiCallable.__call__(self, request, timeout, metadata, credentials, wait_for_ready, compression)
    268 def __call__(
    269     self,
    270     request: Any,
   (...)
    275     compression: Optional[grpc.Compression] = None,
    276 ) -> Any:
--> 277     response, ignored_call = self._with_call(
    278         request,
    279         timeout=timeout,
    280         metadata=metadata,
    281         credentials=credentials,
    282         wait_for_ready=wait_for_ready,
    283         compression=compression,
    284     )
    285     return response

File c:\\Users\\Abria\\Documents\\Ansys\\Lib\\site-packages\\grpc\\_interceptor.py:329, in _UnaryUnaryMultiCallable._with_call(self, request, timeout, metadata, credentials, wait_for_ready, compression)
    326     except Exception as exception:  # pylint:disable=broad-except
    327         return _FailureOutcome(exception, sys.exc_info()[2])
--> 329 call = self._interceptor.intercept_unary_unary(
    330     continuation, client_call_details, request
    331 )
    332 return call.result(), call

File c:\\Users\\Abria\\Documents\\Ansys\\Lib\\site-packages\\ansys\\fluent\\core\\services\\interceptors.py:122, in GrpcErrorInterceptor.intercept_unary_unary(self, continuation, client_call_details, request)
    115 def intercept_unary_unary(
    116     self,
    117     continuation: Any,
    118     client_call_details: grpc.ClientCallDetails,
    119     request: Any,
    120 ) -> Any:
    121     \"\"\"Intercept unary-unary call for error state checking.\"\"\"
--> 122     return self._intercept_call(continuation, client_call_details, request)

File c:\\Users\\Abria\\Documents\\Ansys\\Lib\\site-packages\\ansys\\fluent\\core\\services\\interceptors.py:110, in GrpcErrorInterceptor._intercept_call(self, continuation, client_call_details, request)
    108 if response.exception() is not None and response.code() != grpc.StatusCode.OK:
    109     grpc_ex = response.exception()
--> 110     ex = RuntimeError(grpc_ex.details())
    111     ex.__context__ = grpc_ex
    112     raise ex from None

AttributeError: 'ValueError' object has no attribute 'details'"
}

HOW DO I CLOSE OUT and keep generated results ???

πŸ“ Steps to reproduce

# ##ANOTHER BROKEN ISSUE WITH PYWORKBENCH !!!
# fluent_file_info = wb.start_fluent_server("FFF")
# print(fluent_file_info)
# fluent = pyfluent.connect_to_fluent(server_info_file_name=fluent_file_info)

system_name = "FFF"
server_info_file_name = wb.run_script_string("\n".join(
    ["import json",  
     f"server_info_file=LaunchFluentServerOnSystem(SystemName='{system_name}')", 
     "wb_script_result=json.dumps(server_info_file)"]))
server_file = Path(wb.workdir) / Path(server_info_file_name)
print(server_file)
fluent  = pyfluent.connect_to_fluent(server_info_file_name=server_file.absolute())
fluent.exit() # Nothing

fluent._fluent_connection.check_health() # "NOT_SERVING"
fluent.tui.exit() # Big error above
fluent.tui.close_fluent() # Application stopped responding 
fluent.execute_tui(command="/close-fluent") # # Application stopped responding 

Please let me know how to generate logs and I can provide

πŸ’» Which operating system are you using?

Windows

πŸ“€ Which ANSYS version are you using?

v241

🐍 Which Python version are you using?

3.11

πŸ“¦ Installed packages

about-time==4.2.1
alive-progress==3.1.5
ansys-api-fluent==0.3.24
ansys-api-mechanical==0.1.2
ansys-api-platform-instancemanagement==1.1.0
ansys-api-workbench==0.2.0
ansys-fluent-core==0.20.1
ansys-mechanical-core==0.10.11
ansys-mechanical-env==0.1.6
ansys-platform-instancemanagement==1.1.2
ansys-pythonnet==3.1.0rc3
ansys-tools-path==0.6.0
ansys-units==0.3.2
-e git+https://github.com/ansys/pyworkbench@55228e1fd06c64be4a9d97a8e1925e63f21b8a1a#egg=ansys_workbench_core
appdirs==1.4.4
asttokens==2.4.1
beartype==0.17.2
certifi==2024.6.2
cffi==1.16.0
charset-normalizer==3.3.2
click==8.1.7
clr-loader==0.2.6
colorama==0.4.6
comm==0.2.2
debugpy==1.8.1
decorator==5.1.1
docker==6.1.3
executing==2.0.1
grapheme==0.6.0
grpcio==1.64.1
grpcio-health-checking==1.62.2
idna==3.7
importlib_metadata==7.1.0
iniconfig==2.0.0
ipykernel==6.29.4
ipython==8.25.0
jedi==0.19.1
jupyter_client==8.6.2
jupyter_core==5.7.2
lxml==4.9.4
matplotlib-inline==0.1.7
nest-asyncio==1.6.0
numpy==1.26.4
packaging==24.1
pandas==1.5.3
parso==0.8.4
platformdirs==3.11.0
pluggy==1.5.0
prompt_toolkit==3.0.47
protobuf==4.21.6
psutil==5.9.8
pure-eval==0.2.2
pycparser==2.22
Pygments==2.18.0
pytest==8.2.2
python-dateutil==2.9.0.post0
pytz==2024.1
pywin32==306
PyYAML==6.0.1
pyzmq==26.0.3
requests==2.32.3
six==1.16.0
stack-data==0.6.3
tornado==6.4.1
tqdm==4.66.4
traitlets==5.14.3
typing_extensions==4.12.2
urllib3==2.2.2
wcwidth==0.2.13
websocket-client==1.8.0
WMI==1.5.1
zipp==3.19.2
a-abir commented 4 months ago

argument issue on connect, clean up on exit