diff --git a/doc/changelog.d/3560.added.md b/doc/changelog.d/3560.added.md new file mode 100644 index 0000000000..a6b1dd48f1 --- /dev/null +++ b/doc/changelog.d/3560.added.md @@ -0,0 +1 @@ +refactor: using find_mapdl instead of find_ansys \ No newline at end of file diff --git a/doc/source/api/launcher.rst b/doc/source/api/launcher.rst index a81859920b..00b2978a76 100644 --- a/doc/source/api/launcher.rst +++ b/doc/source/api/launcher.rst @@ -27,6 +27,6 @@ library `ansys-tools-path `_. :toctree: _autosummary change_default_ansys_path - find_ansys + find_mapdl save_ansys_path get_available_ansys_installations diff --git a/doc/source/getting_started/launcher.rst b/doc/source/getting_started/launcher.rst index 8a02603668..46d56985d0 100644 --- a/doc/source/getting_started/launcher.rst +++ b/doc/source/getting_started/launcher.rst @@ -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() ` method and the :func:`find_ansys() ` method. +For more information, see the :func:`change_default_ansys_path() ` method and the :func:`find_mapdl() ` method. Additionally, it is possible to specify the executable in each PyMAPDL script using the ``exec_file`` keyword argument. diff --git a/src/ansys/mapdl/core/__init__.py b/src/ansys/mapdl/core/__init__.py index f014905845..172b961ac8 100644 --- a/src/ansys/mapdl/core/__init__.py +++ b/src/ansys/mapdl/core/__init__.py @@ -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, diff --git a/src/ansys/mapdl/core/launcher.py b/src/ansys/mapdl/core/launcher.py index 7ef1800363..170307d231 100644 --- a/src/ansys/mapdl/core/launcher.py +++ b/src/ansys/mapdl/core/launcher.py @@ -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) @@ -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(): diff --git a/tests/conftest.py b/tests/conftest.py index 4742b6326c..b1c1b6092a 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -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"): @@ -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) @@ -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( diff --git a/tests/test_launcher.py b/tests/test_launcher.py index 4633a3f029..eca73fb9a5 100644 --- a/tests/test_launcher.py +++ b/tests/test_launcher.py @@ -86,7 +86,7 @@ try: from ansys.tools.path import ( - find_ansys, + find_mapdl, get_available_ansys_installations, version_from_path, ) @@ -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: @@ -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) @@ -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 ) @@ -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 @@ -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) @@ -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 @@ -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 ) @@ -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."], @@ -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") @@ -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"] diff --git a/tests/test_pool.py b/tests/test_pool.py index 75c0900338..61d920144c 100644 --- a/tests/test_pool.py +++ b/tests/test_pool.py @@ -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")