Skip to content

Commit 0b2a046

Browse files
authored
Improve ImportWarning in check_ansys_grpc_dpf_version (#208)
Update ImportWarning in check_ansys_grpc_dpf_version to give better indications.
1 parent 9287c5a commit 0b2a046

File tree

1 file changed

+21
-6
lines changed

1 file changed

+21
-6
lines changed

ansys/dpf/core/server.py

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -660,7 +660,8 @@ def read_stderr():
660660
pass
661661
errstr = "\n".join(errors)
662662
if "Only one usage of each socket address" in errstr:
663-
raise errors.InvalidPortError(f"Port {port} in use")
663+
from ansys.dpf.core.errors import InvalidPortError
664+
raise InvalidPortError(f"Port {port} in use")
664665
raise RuntimeError(errstr)
665666

666667
if len(docker_id) > 0:
@@ -685,11 +686,25 @@ def check_ansys_grpc_dpf_version(server, timeout=10.):
685686
server_version = server.version
686687
right_grpc_module_version = server_to_ansys_grpc_dpf_version.get(server_version, None)
687688
if right_grpc_module_version and right_grpc_module_version != grpc_module_version:
688-
raise ImportWarning(f"2022R1 Ansys unified install is available. "
689-
f"To use DPF server from Ansys "
690-
f"{server_to_ansys_version.get(server_version, 'Unknown')}"
691-
f" (dpf.SERVER.version=='{server_version}'), "
692-
f"install version {right_grpc_module_version} of ansys-grpc-dpf"
689+
compatibility_link = (f"https://dpfdocs.pyansys.com/getting_started/"
690+
f"index.html#client-server-compatibility")
691+
raise ImportWarning(f"An incompatibility has been detected between the DPF server version "
692+
f"({server_version} "
693+
f"from Ansys {server_to_ansys_version.get(server_version, 'Unknown')})"
694+
f" and the ansys-grpc-dpf version installed ({grpc_module_version})."
695+
f" Please consider using the latest DPF server available in the "
696+
f"2022R1 Ansys unified install.\n"
697+
f"To follow the compatibility guidelines given in "
698+
f"{compatibility_link} while still using DPF server {server_version}, "
699+
f"please install version {right_grpc_module_version} of ansys-grpc-dpf"
693700
f" with the command: \n"
694701
f" pip install ansys-grpc-dpf=={right_grpc_module_version}"
695702
)
703+
# raise ImportWarning(f"2022R1 Ansys unified install is available. "
704+
# f"To use DPF server from Ansys "
705+
# f"{server_to_ansys_version.get(server_version, 'Unknown')}"
706+
# f" (dpf.SERVER.version=='{server_version}'), "
707+
# f"install version {right_grpc_module_version} of ansys-grpc-dpf"
708+
# f" with the command: \n"
709+
# f" pip install ansys-grpc-dpf=={right_grpc_module_version}"
710+
# )

0 commit comments

Comments
 (0)