Skip to content

Commit 381b751

Browse files
refactor: remove unused and outdated method (#1035)
Co-authored-by: pyansys-ci-bot <[email protected]>
1 parent 83f4e73 commit 381b751

File tree

3 files changed

+2
-133
lines changed

3 files changed

+2
-133
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
remove unused and outdated method

src/ansys/health/heart/settings/settings.py

Lines changed: 1 addition & 107 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2121
# SOFTWARE.
2222

23-
"""Module that defines some classes for settings."""
23+
"""Module that defines classes that hold settings relevant for PyAnsys-Heart."""
2424

2525
import copy
2626
from dataclasses import asdict, dataclass, field
@@ -1071,112 +1071,6 @@ def _modify_from_global_settings(self):
10711071
self.num_cpus = int(os.getenv("PYANSYS_HEART_NUM_CPU", self.num_cpus))
10721072
return
10731073

1074-
# TODO: @mhoeijm update to ensure compatibility with new LS-DYNA/Ansys versions
1075-
def _set_env_variables(self):
1076-
r"""Try to set environment variables for MPI run using Ansys installation root directories.
1077-
1078-
Notes
1079-
-----
1080-
This is based on lsdynaintelvar.bat and lsdynamsvar.bat in
1081-
ANSYS Inc\v231\ansys\bin\winx64\lsprepost48\LS-Run 1.0
1082-
and requires you to install the MPI libraries with the Ansys installer.
1083-
"""
1084-
# get latest installed Ansys version
1085-
env_variables = list(os.environ.keys())
1086-
ansys_env_roots = sorted([k for k in env_variables if "AWP_ROOT" in k])
1087-
ansys_env_roots.reverse()
1088-
1089-
if self.platform == "windows":
1090-
platform = "winx64"
1091-
elif self.platform == "linux":
1092-
platform = "linx64"
1093-
1094-
if self.dynatype in "intelmpi":
1095-
intel_cmp_rev = "2019.5.281"
1096-
intel_mkl_rev = "2020.0.166"
1097-
intel_mpi_rev = "2018.3.210"
1098-
1099-
if os.getenv("MPI_ROOT"):
1100-
LOGGER.warning(
1101-
"MPI_ROOT already defined. Not trying to automatically set MPI env variables."
1102-
)
1103-
return
1104-
1105-
for root in ansys_env_roots:
1106-
mpi_root = os.path.join(
1107-
os.getenv(root),
1108-
"commonfiles",
1109-
"MPI",
1110-
"Intel",
1111-
intel_mpi_rev,
1112-
platform,
1113-
)
1114-
mpi_path = os.path.join(mpi_root, "bin")
1115-
mkl_path = os.path.join(os.getenv(root), "tp", "IntelMKL", intel_mkl_rev, platform)
1116-
cmp_path = os.path.join(
1117-
os.getenv(root), "tp", "IntelCompiler", intel_cmp_rev, platform
1118-
)
1119-
for p in [mpi_root, mpi_path, mkl_path, cmp_path]:
1120-
if not os.path.isdir(p):
1121-
LOGGER.debug("Failed to set env variables with %s " % root)
1122-
continue
1123-
1124-
LOGGER.info("Setting MPI environment variable MPI_ROOT to %s" % mpi_root)
1125-
LOGGER.info("Adding %s to PATH" % [mpi_path, mkl_path, cmp_path])
1126-
1127-
os.environ["MPI_ROOT"] = mpi_root
1128-
os.environ["PATH"] = (
1129-
";".join([mpi_path, mkl_path, cmp_path]) + ";" + os.environ["PATH"]
1130-
)
1131-
os.environ["I_MPI_AUTH_METHOD"] = "delegate"
1132-
os.environ["KMP_AFFINITY"] = "verbose"
1133-
break
1134-
1135-
elif self.dynatype == "msmpi" and self.platform == "windows":
1136-
intel_cmp_rev = "2019.5.281"
1137-
intel_mkl_rev = "2020.0.166"
1138-
ms_mpi_rev = "10.1.12498.18"
1139-
1140-
if os.getenv("MPI_ROOT"):
1141-
LOGGER.warning(
1142-
"MPI_ROOT already defined. Not trying to automatically set MPI env variables."
1143-
)
1144-
return
1145-
1146-
for root in ansys_env_roots:
1147-
mpi_root = os.path.join(
1148-
os.getenv(root),
1149-
"commonfiles",
1150-
"MPI",
1151-
"Microsoft",
1152-
ms_mpi_rev,
1153-
platform,
1154-
)
1155-
mpi_path = os.path.join(mpi_root, "bin")
1156-
mkl_path = os.path.join(os.getenv(root), "tp", "IntelMKL", intel_mkl_rev, platform)
1157-
cmp_path = os.path.join(
1158-
os.getenv(root), "tp", "IntelCompiler", intel_cmp_rev, platform
1159-
)
1160-
for p in [mpi_root, mpi_path, mkl_path, cmp_path]:
1161-
if not os.path.isdir(p):
1162-
LOGGER.debug("Failed to set env variables with %s " % root)
1163-
continue
1164-
1165-
LOGGER.info("Setting MPI environment variable MPI_ROOT to %s" % mpi_root)
1166-
LOGGER.info("Adding %s to PATH" % [mpi_path, mkl_path, cmp_path])
1167-
1168-
os.environ["MPI_ROOT"] = mpi_root
1169-
os.environ["PATH"] = (
1170-
";".join([mpi_path, mkl_path, cmp_path]) + ";" + os.environ["PATH"]
1171-
)
1172-
break
1173-
1174-
elif self.dynatype == "platformmpi":
1175-
LOGGER.error("Automatically setting env variables for platform mpi not implemented yet")
1176-
return
1177-
1178-
return
1179-
11801074
def __repr__(self):
11811075
"""Represent self as string."""
11821076
return yaml.dump(vars(self), allow_unicode=True, default_flow_style=False)

tests/heart/settings/test_dyna_settings.py

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -284,32 +284,6 @@ def test_get_dyna_commands_004(dynatype, platform):
284284
assert commands == expected
285285

286286

287-
@pytest.mark.parametrize(
288-
"dynatype,expect_mpi_root", (["intelmpi", True], ["msmpi", True], ["platformmpi", False])
289-
)
290-
@pytest.mark.xfail(is_gh_action, reason="No Ansys installation expected on Github runner.")
291-
def test_set_env_variables(dynatype, expect_mpi_root):
292-
"""Test setting environment variables."""
293-
294-
import os
295-
296-
if os.getenv("MPI_ROOT"):
297-
del os.environ["MPI_ROOT"]
298-
299-
settings = DynaSettings(
300-
lsdyna_path="my-dyna-path.exe",
301-
dynatype=dynatype,
302-
num_cpus=2,
303-
platform="windows",
304-
)
305-
settings._set_env_variables()
306-
307-
if expect_mpi_root:
308-
assert os.getenv("MPI_ROOT")
309-
310-
pass
311-
312-
313287
def test_modify_settings_from_env_variables(monkeypatch):
314288
"""Test to ensure proper override from environment variables."""
315289
settings = DynaSettings(lsdyna_path="my-dyna-path.exe", dynatype="intelmpi", num_cpus=2)

0 commit comments

Comments
 (0)