Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: using find_mapdl instead of find_ansys #3560

Merged
merged 4 commits into from
Nov 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/changelog.d/3560.added.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
refactor: using find_mapdl instead of find_ansys
2 changes: 1 addition & 1 deletion doc/source/api/launcher.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ library `ansys-tools-path <ansys_tools_path_>`_.
:toctree: _autosummary

change_default_ansys_path
find_ansys
find_mapdl
save_ansys_path
get_available_ansys_installations
2 changes: 1 addition & 1 deletion doc/source/getting_started/launcher.rst
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ to enter the path again. If you must change the default Ansys path
new_path = "C:\\Program Files\\ANSYS Inc\\v241\\ANSYS\\bin\\winx64\\ansys241.exe"
pymapdl.change_default_ansys_path(new_path)

For more information, see the :func:`change_default_ansys_path() <ansys.mapdl.core.change_default_ansys_path>` method and the :func:`find_ansys() <ansys.mapdl.core.find_ansys>` method.
For more information, see the :func:`change_default_ansys_path() <ansys.mapdl.core.change_default_ansys_path>` method and the :func:`find_mapdl() <ansys.mapdl.core.find_mapdl>` method.

Additionally, it is possible to specify the executable in each PyMAPDL script using the ``exec_file`` keyword argument.

Expand Down
2 changes: 1 addition & 1 deletion src/ansys/mapdl/core/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@
if _HAS_ATP:
from ansys.tools.path.path import (
change_default_ansys_path,
find_ansys,
find_mapdl,
get_ansys_path,
get_available_ansys_installations,
save_ansys_path,
Expand Down
4 changes: 2 additions & 2 deletions src/ansys/mapdl/core/launcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
import ansys.platform.instancemanagement as pypim

if _HAS_ATP:
from ansys.tools.path import find_ansys, get_ansys_path
from ansys.tools.path import find_mapdl, get_ansys_path
from ansys.tools.path import version_from_path as _version_from_path

@wraps(_version_from_path)
Expand Down Expand Up @@ -801,7 +801,7 @@ def get_default_ansys():
>>> get_default_ansys()
(/usr/ansys_inc/v211/ansys/bin/ansys211, 21.1)
"""
return find_ansys(supported_versions=SUPPORTED_ANSYS_VERSIONS)
return find_mapdl(supported_versions=SUPPORTED_ANSYS_VERSIONS)


def get_default_ansys_path():
Expand Down
7 changes: 4 additions & 3 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ def requires_dependency(dependency: str):
################

if has_dependency("ansys-tools-package"):
from ansys.tools.path import get_available_ansys_installations
from ansys.tools.path import find_mapdl, get_available_ansys_installations


if has_dependency("pyvista"):
Expand Down Expand Up @@ -316,7 +316,8 @@ def short_test_summary(self):
)


@pytest.mark.trylast
# @pytest.mark.trylast
@pytest.hookimpl(trylast=True)
def pytest_configure(config):
vanilla_reporter = config.pluginmanager.getplugin("terminalreporter")
my_reporter = MyReporter(config)
Expand Down Expand Up @@ -564,7 +565,7 @@ def mapdl_console(request):
for version in ansys_base_paths:
version = abs(version)
if version < 211:
console_path = find_ansys(str(version))[0]
console_path = find_mapdl(str(version))[0]

if console_path is None:
raise MapdlRuntimeError(
Expand Down
34 changes: 17 additions & 17 deletions tests/test_launcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@

try:
from ansys.tools.path import (
find_ansys,
find_mapdl,
get_available_ansys_installations,
version_from_path,
)
Expand All @@ -95,7 +95,7 @@

installed_mapdl_versions = list(get_available_ansys_installations().keys())
try:
V150_EXEC = find_ansys("150")[0]
V150_EXEC = find_mapdl("150")[0]
except ValueError:
V150_EXEC = ""
except:
Expand Down Expand Up @@ -182,10 +182,10 @@ def test_catch_version_from_path():
@requires("ansys-tools-path")
@requires("local")
@requires("linux")
def test_find_ansys_linux():
def test_find_mapdl_linux():
# assuming ansys is installed, should be able to find it on linux
# without env var
bin_file, ver = pymapdl.launcher.find_ansys()
bin_file, ver = pymapdl.launcher.find_mapdl()
assert os.path.isfile(bin_file)
assert isinstance(ver, float)

Expand All @@ -194,7 +194,7 @@ def test_find_ansys_linux():
@requires("local")
def test_invalid_mode(mapdl):
with pytest.raises(ValueError):
exec_file = find_ansys(installed_mapdl_versions[0])[0]
exec_file = find_mapdl(installed_mapdl_versions[0])[0]
pymapdl.launch_mapdl(
exec_file, port=mapdl.port + 1, mode="notamode", start_timeout=start_timeout
)
Expand All @@ -204,7 +204,7 @@ def test_invalid_mode(mapdl):
@requires("local")
@pytest.mark.skipif(not os.path.isfile(V150_EXEC), reason="Requires v150")
def test_old_version(mapdl):
exec_file = find_ansys("150")[0]
exec_file = find_mapdl("150")[0]
with pytest.raises(ValueError):
pymapdl.launch_mapdl(
exec_file, port=mapdl.port + 1, mode="console", start_timeout=start_timeout
Expand All @@ -216,7 +216,7 @@ def test_old_version(mapdl):
@requires("linux")
@requires("console")
def test_failed_console():
exec_file = find_ansys(installed_mapdl_versions[0])[0]
exec_file = find_mapdl(installed_mapdl_versions[0])[0]
with pytest.raises(ValueError):
pymapdl.launch_mapdl(exec_file, mode="console", start_timeout=start_timeout)

Expand All @@ -227,7 +227,7 @@ def test_failed_console():
@requires("linux")
@pytest.mark.parametrize("version", installed_mapdl_versions)
def test_launch_console(version):
exec_file = find_ansys(version)[0]
exec_file = find_mapdl(version)[0]
mapdl = pymapdl.launch_mapdl(exec_file, mode="console", start_timeout=start_timeout)
assert mapdl.version == int(version) / 10

Expand All @@ -237,7 +237,7 @@ def test_launch_console(version):
@requires("ansys-tools-path")
@pytest.mark.parametrize("license_name", LICENSES)
def test_license_type_keyword_names(mapdl, monkeypatch, license_name):
exec_file = find_ansys()[0]
exec_file = find_mapdl()[0]
args = launch_mapdl(
exec_file=exec_file, license_type=license_name, _debug_no_launch=True
)
Expand Down Expand Up @@ -345,7 +345,7 @@ def test_env_injection():
[None, False, "Working directory is NOT in the pytest directory."],
[True, None, "There is a result file, and WDIR is a temp dir."],
pytest.param(
True, True, "Both options (`True`) is not allowed.", marks=pytest.mark.fail
True, True, "Both options (`True`) is not allowed.", marks=pytest.mark.xfail
),
[True, False, "There is a result file, and WDIR is in a temp dir."],
[False, None, "There is NOT a result file, and WDIR is in a temp dir."],
Expand Down Expand Up @@ -448,21 +448,21 @@ def test__verify_version_latest():

@requires("ansys-tools-path")
@requires("local")
def test_find_ansys(mapdl):
assert find_ansys() is not None
def test_find_mapdl(mapdl):
assert find_mapdl() is not None

# Checking ints
version = int(mapdl.version * 10)
assert find_ansys(version=version) is not None
assert find_mapdl(version=version) is not None

# Checking floats
with pytest.raises(ValueError):
find_ansys(version=22.2)
find_mapdl(version=22.2)

assert find_ansys(version=mapdl.version) is not None
assert find_mapdl(version=mapdl.version) is not None

with pytest.raises(ValueError):
assert find_ansys(version="11")
assert find_mapdl(version="11")


@requires("local")
Expand Down Expand Up @@ -822,7 +822,7 @@ def test_launcher_start_instance(monkeypatch, start_instance):
if "PYMAPDL_START_INSTANCE" in os.environ:
monkeypatch.delenv("PYMAPDL_START_INSTANCE")
options = launch_mapdl(
exec_file=find_ansys()[0], start_instance=start_instance, _debug_no_launch=True
exec_file=find_mapdl()[0], start_instance=start_instance, _debug_no_launch=True
)
assert start_instance == options["start_instance"]

Expand Down
4 changes: 2 additions & 2 deletions tests/test_pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@
from conftest import ON_LOCAL, ON_STUDENT, has_dependency

if has_dependency("ansys-tools-path"):
from ansys.tools.path import find_ansys
from ansys.tools.path import find_mapdl

EXEC_FILE = find_ansys()[0]
EXEC_FILE = find_mapdl()[0]

else:
EXEC_FILE = os.environ.get("PYMAPDL_MAPDL_EXEC")
Expand Down
Loading