Skip to content

Commit

Permalink
Fix parsing of ansys_path version in start_local_server (#1388)
Browse files Browse the repository at this point in the history
* Stop throwing silently when DPF version of ansys_path is not understood, and parse folder name when dpf_standalone

Signed-off-by: paul.profizi <[email protected]>

* Fix case of ansys_path being a Path and not a str

Signed-off-by: paul.profizi <[email protected]>

* Add DPFServerPathFormatError

Signed-off-by: paul.profizi <[email protected]>

* Move the ansys_path format checks to core\misc.py\get_ansys_path

Signed-off-by: paul.profizi <[email protected]>

* Fix regex patterns compilation

Signed-off-by: paul.profizi <[email protected]>

* Update BaseServer.info

Signed-off-by: paul.profizi <[email protected]>

* Update test_launcher.py tests

Signed-off-by: paul.profizi <[email protected]>

* Revert "Update test_launcher.py tests"

This reverts commit cf360fb.

* Revert "Add DPFServerPathFormatError"

This reverts commit 0961981.

* Revert back to only testing minimal version if ansys_path ends in vXYZ

Signed-off-by: paul.profizi <[email protected]>

---------

Signed-off-by: paul.profizi <[email protected]>
  • Loading branch information
PProfizi authored Jan 30, 2024
1 parent ff6d0f3 commit 6bddcba
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 12 deletions.
16 changes: 16 additions & 0 deletions src/ansys/dpf/core/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@
import platform
import glob
import os
import re

import packaging.version
import pkg_resources
import importlib
from pkgutil import iter_modules
from ansys.dpf.core import errors
from ansys.dpf.gate._version import __ansys_version__
from ansys.dpf.gate import load_api

Expand Down Expand Up @@ -97,6 +99,20 @@ def get_ansys_path(ansys_path=None):
'- when starting the server with "start_local_server(ansys_path=*/vXXX)"\n'
'- or by setting it by default with the environment variable "ANSYS_DPF_PATH"'
)
# parse the version to an int and check for supported
ansys_folder_name = str(ansys_path).split(os.sep)[-1]
reobj_vXYZ = re.compile(
"^v[0123456789]{3}$"
)
if reobj_vXYZ.match(ansys_folder_name):
# vXYZ Unified Install folder
ver = int(str(ansys_path)[-3:])
else:
ver = 222
if ver < 211:
raise errors.InvalidANSYSVersionError(f"Ansys v{ver} does not support DPF")
if ver == 211 and is_ubuntu():
raise OSError("DPF on v211 does not support Ubuntu")
return ansys_path


Expand Down
9 changes: 0 additions & 9 deletions src/ansys/dpf/core/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,15 +190,6 @@ def start_local_server(
use_pypim = use_pypim_by_default and is_pypim_configured()
if not use_docker and not use_pypim:
ansys_path = get_ansys_path(ansys_path)
# parse the version to an int and check for supported
try:
ver = int(str(ansys_path)[-3:])
if ver < 211:
raise errors.InvalidANSYSVersionError(f"Ansys v{ver} does not support DPF")
if ver == 211 and is_ubuntu():
raise OSError("DPF on v211 does not support Ubuntu")
except ValueError:
pass

# avoid using any ports in use from existing servers
used_ports = []
Expand Down
8 changes: 5 additions & 3 deletions src/ansys/dpf/core/server_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -427,10 +427,12 @@ def info(self):
-------
info : dictionary
Dictionary with server information, including ``"server_ip"``,
``"server_port"``, ``"server_process_id"``, and
``"server_version"`` keys.
``"server_port"``, ``"server_process_id"``, ``"server_version"`` , ``"os"``
and ``"path"`` keys.
"""
return self._base_service.server_info
server_info = self._base_service.server_info
server_info["path"] = self.ansys_path
return server_info

def _del_session(self):
if self._session_instance:
Expand Down

0 comments on commit 6bddcba

Please sign in to comment.