ansys / pyworkbench

PyWorkbench
http://workbench.docs.pyansys.com/
MIT License
2 stars 1 forks source link

Unable to connect to Fluent Server: server file not found #97

Closed a-abir closed 5 days ago

a-abir commented 3 months ago

šŸ” Before submitting the issue

šŸž Description of the bug

Server file not found for Fluent.

{
    "name": "FileNotFoundError",
    "message": "[Errno 2] No such file or directory: 'C:\\\\Users\\\\User\\\\AppData\\\\Local\\\\Temp\\\\pyfluent.server'",
    "stack": "---------------------------------------------------------------------------
FileNotFoundError                         Traceback (most recent call last)
Cell In[6], line 3
      1 fluent_file_info = wb.start_fluent_server(\"FFF\")
      2 print(fluent_file_info)
----> 3 fluent = pyfluent.connect_to_fluent(server_info_file_name=fluent_file_info)
      6 # system_name = \"FFF\"
      7 # server_info_file_name = wb.run_script_string(\"\
\".join(
      8 #     [\"import json\",  
   (...)
     13 # print(server_file)
     14 # fluent  = pyfluent.connect_to_fluent(server_info_file_name=server_file.absolute() )

File c:\\Users\\User\\Ansys\\Lib\\site-packages\\ansys\\fluent\\core\\launcher\\launcher.py:356, in connect_to_fluent(ip, port, cleanup_on_exit, start_transcript, server_info_file_name, password, start_watchdog)
    305 def connect_to_fluent(
    306     ip: Optional[str] = None,
    307     port: Optional[int] = None,
   (...)
    312     start_watchdog: Optional[bool] = None,
    313 ) -> Union[Meshing, PureMeshing, Solver, SolverIcing]:
    314     \"\"\"Connect to an existing Fluent server instance.
    315 
    316     Parameters
   (...)
    354         Session object.
    355     \"\"\"
--> 356     ip, port, password = _get_server_info(server_info_file_name, ip, port, password)
    357     fluent_connection = FluentConnection(
    358         ip=ip,
    359         port=port,
   (...)
    362         start_transcript=start_transcript,
    363     )
    364     new_session = _get_running_session_mode(fluent_connection)

File c:\\Users\\User\\Ansys\\Lib\\site-packages\\ansys\\fluent\\core\\launcher\\server_info.py:42, in _get_server_info(server_info_file_name, ip, port, password)
     40 else:
     41     if server_info_file_name:
---> 42         ip, port, password = _parse_server_info_file(server_info_file_name)
     43     ip = ip or os.getenv(\"PYFLUENT_FLUENT_IP\", \"127.0.0.1\")
     44     port = port or os.getenv(\"PYFLUENT_FLUENT_PORT\")

File c:\\Users\\User\\Ansys\\Lib\\site-packages\\ansys\\fluent\\core\\session.py:38, in _parse_server_info_file(file_name)
     37 def _parse_server_info_file(file_name: str):
---> 38     with open(file_name, encoding=\"utf-8\") as f:
     39         lines = f.readlines()
     40     ip_and_port = lines[0].strip().split(\":\")

FileNotFoundError: [Errno 2] No such file or directory: 'C:\\\\Users\\\\User\\\\AppData\\\\Local\\\\Temp\\\\pyfluent.server'"
}

It seems we're deleting the local copy and returning it ?? in launcher pyworkbench/src/ansys/workbench/core /workbench_client.py def start_fluent_server(self, system_name): """Start the PyFluent server for the given system in the Workbench project. ... """ ) _local_copy = os.path.join(self.workdir, server_info_file_name) if os.path.exists(local_copy): os.remove(localcopy) self.download_file(server_info_file_name, show_progress=False) return local_copy

šŸ“ Steps to reproduce

basic code

import ansys.fluent.core as pyfluent from pathlib import Path from ansys.workbench.core import launch_workbench

wb_script_file = Path("./modules/wbScript.txt") # system with fluent setup wb = launch_workbench(release="241") wb.run_script_file(wb_script_file.absolute())

fluent_file_info = wb.start_fluent_server("FFF") print(fluent_file_info) fluent = pyfluent.connect_to_fluent(server_info_file_name=fluent_file_info)

šŸ’» Which operating system are you using?

Windows

šŸ“€ Which ANSYS version are you using?

v241

šŸ Which Python version are you using?

3.12

šŸ“¦ Installed packages

about-time==4.2.1
aiohttp==3.9.5
aiosignal==1.3.1
alive-progress==3.1.5
ansys-api-dbu==0.3.3
ansys-api-fluent==0.3.24
ansys-api-geometry==0.4.4
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-geometry-core==0.6.3
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-tools-visualization-interface==0.2.6
ansys-units==0.3.2
ansys-workbench-core==0.4.0
appdirs==1.4.4
asttokens==2.4.1
attrs==23.2.0
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
contourpy==1.2.1
cycler==0.12.1
debugpy==1.8.1
decorator==5.1.1
docker==6.1.3
executing==2.0.1
flexcache==0.3
flexparser==0.3.1
fonttools==4.53.0
frozenlist==1.4.1
grapheme==0.6.0
grpcio==1.64.1
grpcio-health-checking==1.62.2
idna==3.7
importlib_metadata==7.1.0
ipykernel==6.29.4
ipython==8.25.0
jedi==0.19.1
jupyter_client==8.6.2
jupyter_core==5.7.2
kiwisolver==1.4.5
lxml==4.9.4
matplotlib==3.9.0
matplotlib-inline==0.1.7
more-itertools==10.3.0
msgpack==1.0.8
multidict==6.0.5
nest-asyncio==1.6.0
numpy==1.26.4
numpy-stl==3.1.1
packaging==24.1
pandas==1.5.3
parso==0.8.4
pillow==10.3.0
Pint==0.24
platformdirs==3.11.0
pooch==1.8.2
prompt_toolkit==3.0.47
protobuf==4.25.3
psutil==5.9.8
pure-eval==0.2.2
pycparser==2.22
Pygments==2.18.0
pyparsing==3.1.2
python-dateutil==2.9.0.post0
python-utils==3.8.2
pytz==2024.1
pyvista==0.43.10
pywin32==306
PyYAML==6.0.1
pyzmq==26.0.3
requests==2.32.3
scipy==1.13.1
scooby==0.10.0
semver==3.0.2
six==1.16.0
stack-data==0.6.3
tornado==6.4.1
tqdm==4.66.4
traitlets==5.14.3
trame==3.6.2
trame-client==3.1.0
trame-server==3.0.1
trame-vtk==2.8.9
trame-vuetify==2.6.0
typing_extensions==4.12.2
tzdata==2024.1
urllib3==2.2.2
vtk==9.3.0
wcwidth==0.2.13
websocket-client==1.8.0
websockets==12.0
WMI==1.5.1
wslink==2.0.5
yarl==1.9.4
zipp==3.19.2
franknli commented 1 month ago

Server's workdir should NOT be the same as client's workdir.