From f30edfb3aaf6afc6f10080fafa9c50bcfb9a9557 Mon Sep 17 00:00:00 2001 From: Harshal Pohekar Date: Wed, 29 May 2024 12:45:38 +0530 Subject: [PATCH 01/31] fix: Update host_mount_path and examples download path --- src/ansys/fluent/core/__init__.py | 2 ++ src/ansys/fluent/core/examples/downloads.py | 6 +++--- src/ansys/fluent/core/launcher/fluent_container.py | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/ansys/fluent/core/__init__.py b/src/ansys/fluent/core/__init__.py index 0b320f05512..5709409aab8 100644 --- a/src/ansys/fluent/core/__init__.py +++ b/src/ansys/fluent/core/__init__.py @@ -71,6 +71,8 @@ def version_info() -> str: ) EXAMPLES_PATH = os.path.join(USER_DATA_PATH, "examples") +PYFLUENT_WORKING_DIR = Path(os.getcwd().split("src")[0]).resolve() + # Set this to False to stop automatically inferring and setting REMOTING_SERVER_ADDRESS INFER_REMOTING_IP = True diff --git a/src/ansys/fluent/core/examples/downloads.py b/src/ansys/fluent/core/examples/downloads.py index c0a2abc960b..68964a77a09 100644 --- a/src/ansys/fluent/core/examples/downloads.py +++ b/src/ansys/fluent/core/examples/downloads.py @@ -39,7 +39,7 @@ def delete_downloads(): def _decompress(file_name: str) -> None: """Decompress zipped file.""" zip_ref = zipfile.ZipFile(file_name, "r") - zip_ref.extractall(pyfluent.EXAMPLES_PATH) + zip_ref.extractall(pyfluent.PYFLUENT_WORKING_DIR) return zip_ref.close() @@ -62,7 +62,7 @@ def _retrieve_file( """Download specified file from specified URL.""" file_name = os.path.basename(file_name) if save_path is None: - save_path = pyfluent.EXAMPLES_PATH + save_path = pyfluent.PYFLUENT_WORKING_DIR else: save_path = os.path.abspath(save_path) local_path = os.path.join(save_path, file_name) @@ -196,7 +196,7 @@ def path(file_name: str): """ if os.path.isabs(file_name): return file_name - file_path = Path(pyfluent.EXAMPLES_PATH) / file_name + file_path = Path(pyfluent.PYFLUENT_WORKING_DIR) / file_name if file_path.is_file(): return str(file_path) else: diff --git a/src/ansys/fluent/core/launcher/fluent_container.py b/src/ansys/fluent/core/launcher/fluent_container.py index 26fddea6c82..b47145f53fb 100644 --- a/src/ansys/fluent/core/launcher/fluent_container.py +++ b/src/ansys/fluent/core/launcher/fluent_container.py @@ -186,7 +186,7 @@ def configure_container_dict( if file_transfer_service: host_mount_path = pyfluent.USER_DATA_PATH else: - host_mount_path = pyfluent.EXAMPLES_PATH + host_mount_path = pyfluent.PYFLUENT_WORKING_DIR elif "volumes" in container_dict: logger.warning( "'volumes' keyword specified in 'container_dict', but " From 289b2a8d7ec121f6d6f8cdea188881002507cac2 Mon Sep 17 00:00:00 2001 From: Harshal Pohekar Date: Wed, 29 May 2024 12:59:51 +0530 Subject: [PATCH 02/31] show mapped path using logging --- src/ansys/fluent/core/launcher/fluent_container.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/ansys/fluent/core/launcher/fluent_container.py b/src/ansys/fluent/core/launcher/fluent_container.py index b47145f53fb..da36b29807c 100644 --- a/src/ansys/fluent/core/launcher/fluent_container.py +++ b/src/ansys/fluent/core/launcher/fluent_container.py @@ -228,6 +228,9 @@ def configure_container_dict( host_mount_path = volumes_string.replace(":" + container_mount_path, "") logger.debug(f"host_mount_path: {host_mount_path}") logger.debug(f"container_mount_path: {container_mount_path}") + logger.info( + f"PyFluent workdir: Fluent workdir {host_mount_path}:{container_mount_path}" + ) if "ports" not in container_dict: if not port: From 7afa297f297b43502652b81cc792817f0704c6ed Mon Sep 17 00:00:00 2001 From: Harshal Pohekar Date: Wed, 29 May 2024 13:34:52 +0530 Subject: [PATCH 03/31] update working dir --- src/ansys/fluent/core/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ansys/fluent/core/__init__.py b/src/ansys/fluent/core/__init__.py index 5709409aab8..cf523eed44a 100644 --- a/src/ansys/fluent/core/__init__.py +++ b/src/ansys/fluent/core/__init__.py @@ -71,7 +71,7 @@ def version_info() -> str: ) EXAMPLES_PATH = os.path.join(USER_DATA_PATH, "examples") -PYFLUENT_WORKING_DIR = Path(os.getcwd().split("src")[0]).resolve() +PYFLUENT_WORKING_DIR = Path(__file__.split("src")[0]).resolve() # Set this to False to stop automatically inferring and setting REMOTING_SERVER_ADDRESS INFER_REMOTING_IP = True From 1d1bde16fd2770e38204c889df88f4dfd40f32a2 Mon Sep 17 00:00:00 2001 From: Harshal Pohekar <106588300+hpohekar@users.noreply.github.com> Date: Wed, 29 May 2024 18:10:18 +0530 Subject: [PATCH 04/31] Update src/ansys/fluent/core/launcher/fluent_container.py Co-authored-by: Raphael Luciano --- src/ansys/fluent/core/launcher/fluent_container.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ansys/fluent/core/launcher/fluent_container.py b/src/ansys/fluent/core/launcher/fluent_container.py index da36b29807c..ae7d2a9c845 100644 --- a/src/ansys/fluent/core/launcher/fluent_container.py +++ b/src/ansys/fluent/core/launcher/fluent_container.py @@ -228,8 +228,8 @@ def configure_container_dict( host_mount_path = volumes_string.replace(":" + container_mount_path, "") logger.debug(f"host_mount_path: {host_mount_path}") logger.debug(f"container_mount_path: {container_mount_path}") - logger.info( - f"PyFluent workdir: Fluent workdir {host_mount_path}:{container_mount_path}" + logger.warning( + f"Starting Fluent container mounted to {host_mount_path}, with this path available as {container_mount_path} for the Fluent session running inside the container." ) if "ports" not in container_dict: From 0625cf0abf061e82f11451c0b1f2bd4aee653f80 Mon Sep 17 00:00:00 2001 From: Harshal Pohekar Date: Wed, 29 May 2024 19:09:05 +0530 Subject: [PATCH 05/31] use os.getcwd() --- src/ansys/fluent/core/__init__.py | 2 -- src/ansys/fluent/core/examples/downloads.py | 6 +++--- src/ansys/fluent/core/launcher/fluent_container.py | 6 +++++- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/ansys/fluent/core/__init__.py b/src/ansys/fluent/core/__init__.py index cf523eed44a..0b320f05512 100644 --- a/src/ansys/fluent/core/__init__.py +++ b/src/ansys/fluent/core/__init__.py @@ -71,8 +71,6 @@ def version_info() -> str: ) EXAMPLES_PATH = os.path.join(USER_DATA_PATH, "examples") -PYFLUENT_WORKING_DIR = Path(__file__.split("src")[0]).resolve() - # Set this to False to stop automatically inferring and setting REMOTING_SERVER_ADDRESS INFER_REMOTING_IP = True diff --git a/src/ansys/fluent/core/examples/downloads.py b/src/ansys/fluent/core/examples/downloads.py index 68964a77a09..073d114b817 100644 --- a/src/ansys/fluent/core/examples/downloads.py +++ b/src/ansys/fluent/core/examples/downloads.py @@ -39,7 +39,7 @@ def delete_downloads(): def _decompress(file_name: str) -> None: """Decompress zipped file.""" zip_ref = zipfile.ZipFile(file_name, "r") - zip_ref.extractall(pyfluent.PYFLUENT_WORKING_DIR) + zip_ref.extractall(os.getcwd()) return zip_ref.close() @@ -62,7 +62,7 @@ def _retrieve_file( """Download specified file from specified URL.""" file_name = os.path.basename(file_name) if save_path is None: - save_path = pyfluent.PYFLUENT_WORKING_DIR + save_path = os.getcwd() else: save_path = os.path.abspath(save_path) local_path = os.path.join(save_path, file_name) @@ -196,7 +196,7 @@ def path(file_name: str): """ if os.path.isabs(file_name): return file_name - file_path = Path(pyfluent.PYFLUENT_WORKING_DIR) / file_name + file_path = Path(os.getcwd()) / file_name if file_path.is_file(): return str(file_path) else: diff --git a/src/ansys/fluent/core/launcher/fluent_container.py b/src/ansys/fluent/core/launcher/fluent_container.py index da36b29807c..4d12617bd19 100644 --- a/src/ansys/fluent/core/launcher/fluent_container.py +++ b/src/ansys/fluent/core/launcher/fluent_container.py @@ -186,7 +186,7 @@ def configure_container_dict( if file_transfer_service: host_mount_path = pyfluent.USER_DATA_PATH else: - host_mount_path = pyfluent.PYFLUENT_WORKING_DIR + host_mount_path = os.getcwd() elif "volumes" in container_dict: logger.warning( "'volumes' keyword specified in 'container_dict', but " @@ -417,3 +417,7 @@ def start_fluent_container( finally: if remove_server_info_file and host_server_info_file.exists(): host_server_info_file.unlink() + + +if __name__ == "__main__": + print(os.getcwd()) From 7cb469cb0d631762a9bbbcbcb80fa1b9e91ca907 Mon Sep 17 00:00:00 2001 From: Harshal Pohekar Date: Wed, 29 May 2024 19:11:33 +0530 Subject: [PATCH 06/31] remove __name__ --- src/ansys/fluent/core/launcher/fluent_container.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/ansys/fluent/core/launcher/fluent_container.py b/src/ansys/fluent/core/launcher/fluent_container.py index c014f7a516a..ee07daa3cdf 100644 --- a/src/ansys/fluent/core/launcher/fluent_container.py +++ b/src/ansys/fluent/core/launcher/fluent_container.py @@ -417,7 +417,3 @@ def start_fluent_container( finally: if remove_server_info_file and host_server_info_file.exists(): host_server_info_file.unlink() - - -if __name__ == "__main__": - print(os.getcwd()) From b54363f070634abc349e39236f8b9ab18f618eda Mon Sep 17 00:00:00 2001 From: Harshal Pohekar Date: Wed, 29 May 2024 20:48:12 +0530 Subject: [PATCH 07/31] replace pyfluent.EXAMPLES_PATH with os.getcwd() --- src/ansys/fluent/core/systemcoupling.py | 5 ++--- src/ansys/fluent/core/utils/data_transfer.py | 3 +-- tests/parametric/test_parametric_workflow.py | 4 ++-- tests/test_session.py | 4 ++-- tests/test_solvermode/test_general.py | 4 +--- tests/test_topy.py | 12 ++++++------ 6 files changed, 14 insertions(+), 18 deletions(-) diff --git a/src/ansys/fluent/core/systemcoupling.py b/src/ansys/fluent/core/systemcoupling.py index e8117f92b6d..a5c9b80bde9 100644 --- a/src/ansys/fluent/core/systemcoupling.py +++ b/src/ansys/fluent/core/systemcoupling.py @@ -5,7 +5,6 @@ from typing import List import xml.etree.ElementTree as XmlET -import ansys.fluent.core as pyfluent from ansys.fluent.core.utils.fluent_version import FluentVersion @@ -97,9 +96,9 @@ def get_scp_string() -> str: elif self._solver.connection_properties.inside_container: # Right now, the way that PyFluent containers and tests are set up, # the local Fluent container working directory will correspond to - # pyfluent.EXAMPLES_PATH in the host, so that is where the SCP file + # os.getcwd() in the host, so that is where the SCP file # will be written. - examples_path_scp = os.path.join(pyfluent.EXAMPLES_PATH, scp_file_name) + examples_path_scp = os.path.join(os.getcwd(), scp_file_name) if os.path.exists(examples_path_scp): scp_file_name = examples_path_scp diff --git a/src/ansys/fluent/core/utils/data_transfer.py b/src/ansys/fluent/core/utils/data_transfer.py index e490ee0b5f9..e5fde5ecab1 100644 --- a/src/ansys/fluent/core/utils/data_transfer.py +++ b/src/ansys/fluent/core/utils/data_transfer.py @@ -6,7 +6,6 @@ from pathlib import Path, PurePosixPath from typing import Optional -import ansys.fluent.core as pyfluent from ansys.fluent.core.launcher.fluent_container import DEFAULT_CONTAINER_MOUNT_PATH from ansys.fluent.core.utils.execution import asynchronous @@ -93,7 +92,7 @@ def transfer_case( """ inside_container = source_instance.connection_properties.inside_container if not workdir: - workdir = Path(pyfluent.EXAMPLES_PATH) + workdir = Path(os.getcwd()) else: workdir = Path(workdir) if inside_container: diff --git a/tests/parametric/test_parametric_workflow.py b/tests/parametric/test_parametric_workflow.py index bc33c99c30a..cb711e49f50 100644 --- a/tests/parametric/test_parametric_workflow.py +++ b/tests/parametric/test_parametric_workflow.py @@ -20,8 +20,8 @@ def pytest_approx(expected): @pytest.mark.fluent_version("latest") def test_parametric_workflow(): # parent path needs to exist for mkdtemp - Path(pyfluent.EXAMPLES_PATH).mkdir(parents=True, exist_ok=True) - tmp_save_path = tempfile.mkdtemp(dir=pyfluent.EXAMPLES_PATH) + Path(os.getcwd()).mkdir(parents=True, exist_ok=True) + tmp_save_path = tempfile.mkdtemp(dir=os.getcwd()) if pyfluent.USE_FILE_TRANSFER_SERVICE: file_transfer_service = RemoteFileTransferStrategy( host_mount_path=tmp_save_path diff --git a/tests/test_session.py b/tests/test_session.py index 5c2f16ff18e..955a4998176 100644 --- a/tests/test_session.py +++ b/tests/test_session.py @@ -292,7 +292,7 @@ def test_journal_creation(file_format, new_mesh_session): fd, file_name = tempfile.mkstemp( suffix=f"-{os.getpid()}.{file_format}", prefix="pyfluent-", - dir=str(pyfluent.EXAMPLES_PATH), + dir=str(os.getcwd()), ) os.close(fd) @@ -321,7 +321,7 @@ def test_start_transcript_file_write(new_mesh_session): fd, file_name = tempfile.mkstemp( suffix=f"-{os.getpid()}.trn", prefix="pyfluent-", - dir=str(pyfluent.EXAMPLES_PATH), + dir=str(os.getcwd()), ) os.close(fd) diff --git a/tests/test_solvermode/test_general.py b/tests/test_solvermode/test_general.py index 6f9caae7dcb..803320a46fa 100644 --- a/tests/test_solvermode/test_general.py +++ b/tests/test_solvermode/test_general.py @@ -3,8 +3,6 @@ import pytest -import ansys.fluent.core as pyfluent - @pytest.mark.settings_only @pytest.mark.fluent_version("latest") @@ -12,7 +10,7 @@ def test_solver_import_mixingelbow(load_mixing_elbow_settings_only): solver_session = load_mixing_elbow_settings_only assert solver_session.settings.is_active() assert solver_session.health_check.is_serving - file_name = Path(pyfluent.EXAMPLES_PATH) / "jou_test_general.py" + file_name = Path(os.getcwd()) / "jou_test_general.py" solver_session.journal.start(file_name.as_posix()) ### assert solver_session.setup.models.energy.enabled() diff --git a/tests/test_topy.py b/tests/test_topy.py index 505d86a0c45..53b97d7dea2 100644 --- a/tests/test_topy.py +++ b/tests/test_topy.py @@ -9,7 +9,7 @@ @pytest.mark.skip(reason="Unable to read generated python journal from fluent.") def test_single_jou(): - file_name = os.path.join(pyfluent.EXAMPLES_PATH, "jou1.jou") + file_name = os.path.join(os.getcwd(), "jou1.jou") with open(file_name, "w") as journal: journal.write('(display "from jou1.jou")') @@ -43,7 +43,7 @@ def test_single_jou(): @pytest.mark.skip(reason="Unable to read generated python journal from fluent.") def test_single_scm(): - file_name = os.path.join(pyfluent.EXAMPLES_PATH, "jou1.scm") + file_name = os.path.join(os.getcwd(), "jou1.scm") with open(file_name, "w") as journal: journal.write('(display "from jou1.scm")') @@ -77,8 +77,8 @@ def test_single_scm(): @pytest.mark.skip(reason="Unable to read generated python journal from fluent.") def test_2_jou(): - file_name_1 = os.path.join(pyfluent.EXAMPLES_PATH, "jou1.jou") - file_name_2 = os.path.join(pyfluent.EXAMPLES_PATH, "jou2.jou") + file_name_1 = os.path.join(os.getcwd(), "jou1.jou") + file_name_2 = os.path.join(os.getcwd(), "jou2.jou") with open(file_name_1, "w") as journal: journal.write('(display "from jou1.jou")') @@ -129,8 +129,8 @@ def test_2_jou(): @pytest.mark.skip(reason="Unable to read generated python journal from fluent.") def test_2_scm(): - file_name_1 = os.path.join(pyfluent.EXAMPLES_PATH, "jou1.scm") - file_name_2 = os.path.join(pyfluent.EXAMPLES_PATH, "jou2.scm") + file_name_1 = os.path.join(os.getcwd(), "jou1.scm") + file_name_2 = os.path.join(os.getcwd(), "jou2.scm") with open(file_name_1, "w") as journal: journal.write('(display "from jou1.scm")') From 5f5aa6c6c48b0b2b0424148dd735a376dabd0b1f Mon Sep 17 00:00:00 2001 From: Harshal Pohekar Date: Wed, 29 May 2024 20:52:19 +0530 Subject: [PATCH 08/31] replace EXAMPLES_PATH with os.getcwd() --- tests/test_tests_util.py | 11 +++++------ tests/util/__init__.py | 6 ++---- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/tests/test_tests_util.py b/tests/test_tests_util.py index 64e3a75615e..286caf04cdd 100644 --- a/tests/test_tests_util.py +++ b/tests/test_tests_util.py @@ -3,7 +3,6 @@ import pytest -from ansys.fluent.core import EXAMPLES_PATH from tests.util import rename_downloaded_file @@ -13,11 +12,11 @@ ) def test_rename_downloaded_file(ext, a, b, c, d): try: - file_path = Path(EXAMPLES_PATH) / f"{a}{ext}" + file_path = Path(os.getcwd()) / f"{a}{ext}" file_path.touch() file_path = str(file_path) new_file_path = rename_downloaded_file(file_path, "_1") - assert new_file_path == str(Path(EXAMPLES_PATH) / f"{a}_1{ext}") + assert new_file_path == str(Path(os.getcwd()) / f"{a}_1{ext}") except Exception: raise finally: @@ -25,16 +24,16 @@ def test_rename_downloaded_file(ext, a, b, c, d): try: file_path = f"{b}{ext}" - (Path(EXAMPLES_PATH) / file_path).touch() + (Path(os.getcwd()) / file_path).touch() new_file_path = rename_downloaded_file(file_path, "_1") assert new_file_path == f"{b}_1{ext}" except Exception: raise finally: - (Path(EXAMPLES_PATH) / new_file_path).unlink(missing_ok=True) + (Path(os.getcwd()) / new_file_path).unlink(missing_ok=True) try: - dir_path = Path(EXAMPLES_PATH) / c + dir_path = Path(os.getcwd()) / c dir_path.mkdir() file_path = dir_path / f"{d}{ext}" file_path.touch() diff --git a/tests/util/__init__.py b/tests/util/__init__.py index 2a95cf4894f..04ae890fc8f 100644 --- a/tests/util/__init__.py +++ b/tests/util/__init__.py @@ -1,7 +1,5 @@ from pathlib import Path -from ansys.fluent.core import EXAMPLES_PATH - def rename_downloaded_file(file_path: str, suffix: str) -> str: """Rename downloaded file by appending a suffix to the file name. @@ -29,8 +27,8 @@ def rename_downloaded_file(file_path: str, suffix: str) -> str: orig_path.rename(new_path) return str(new_path) else: - orig_abs_path = Path(EXAMPLES_PATH) / orig_path - abs_path = Path(EXAMPLES_PATH) / file_path + orig_abs_path = Path(os.getcwd()) / orig_path + abs_path = Path(os.getcwd()) / file_path new_stem = f"{file_path.stem}{suffix}" new_path = abs_path.with_stem(new_stem) new_path = new_path.with_suffix(ext) From 3b7cfe4d54ae567d6eb50b8484d63744e2717d7d Mon Sep 17 00:00:00 2001 From: Harshal Pohekar Date: Wed, 29 May 2024 21:01:17 +0530 Subject: [PATCH 09/31] update test_file_transfer_service.py --- tests/test_file_transfer_service.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tests/test_file_transfer_service.py b/tests/test_file_transfer_service.py index e8cde1e7998..25a483b17d7 100644 --- a/tests/test_file_transfer_service.py +++ b/tests/test_file_transfer_service.py @@ -26,9 +26,7 @@ def file_downloaded_to_the_client(file_name: str) -> bool: ------- Whether file exists. """ - full_file_name = pathlib.Path( - "/home/runner/.local/share/ansys_fluent_core/examples" - ) / os.path.basename(file_name) + full_file_name = pathlib.Path(os.getcwd()) / os.path.basename(file_name) return full_file_name.is_file() From 16e6f7ccb1d4b5e55474006748024794d16603c5 Mon Sep 17 00:00:00 2001 From: Harshal Pohekar Date: Wed, 29 May 2024 21:05:23 +0530 Subject: [PATCH 10/31] update __init__.py --- src/ansys/fluent/core/__init__.py | 1 - 1 file changed, 1 deletion(-) diff --git a/src/ansys/fluent/core/__init__.py b/src/ansys/fluent/core/__init__.py index 0b320f05512..471d3929ab4 100644 --- a/src/ansys/fluent/core/__init__.py +++ b/src/ansys/fluent/core/__init__.py @@ -69,7 +69,6 @@ def version_info() -> str: USER_DATA_PATH = platformdirs.user_data_dir( appname="ansys_fluent_core", appauthor="Ansys" ) -EXAMPLES_PATH = os.path.join(USER_DATA_PATH, "examples") # Set this to False to stop automatically inferring and setting REMOTING_SERVER_ADDRESS INFER_REMOTING_IP = True From 982e02edf1f3bba34319aa6b1c1e9816b373d521 Mon Sep 17 00:00:00 2001 From: Harshal Pohekar Date: Wed, 29 May 2024 22:21:12 +0530 Subject: [PATCH 11/31] test fix --- tests/test_tests_util.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/test_tests_util.py b/tests/test_tests_util.py index 286caf04cdd..999ca93541b 100644 --- a/tests/test_tests_util.py +++ b/tests/test_tests_util.py @@ -1,3 +1,4 @@ +import os from pathlib import Path import shutil From 4b295d86c128e7854724eb6706a3de7a1e71cdfe Mon Sep 17 00:00:00 2001 From: Harshal Pohekar Date: Thu, 30 May 2024 10:06:04 +0530 Subject: [PATCH 12/31] test fix 1 --- tests/util/__init__.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/util/__init__.py b/tests/util/__init__.py index 04ae890fc8f..f3c9fe5c648 100644 --- a/tests/util/__init__.py +++ b/tests/util/__init__.py @@ -1,3 +1,4 @@ +import os from pathlib import Path From 1e41bfa5bad779652073a678b4b6301e4da83281 Mon Sep 17 00:00:00 2001 From: Harshal Pohekar Date: Fri, 31 May 2024 13:07:30 +0530 Subject: [PATCH 13/31] system coupling fix --- src/ansys/fluent/core/systemcoupling.py | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/ansys/fluent/core/systemcoupling.py b/src/ansys/fluent/core/systemcoupling.py index a5c9b80bde9..e28916e127f 100644 --- a/src/ansys/fluent/core/systemcoupling.py +++ b/src/ansys/fluent/core/systemcoupling.py @@ -93,14 +93,6 @@ def get_scp_string() -> str: # download the file locally in case Fluent is remote # assume file transfer service is configured - download the file self._solver.download(scp_file_name) - elif self._solver.connection_properties.inside_container: - # Right now, the way that PyFluent containers and tests are set up, - # the local Fluent container working directory will correspond to - # os.getcwd() in the host, so that is where the SCP file - # will be written. - examples_path_scp = os.path.join(os.getcwd(), scp_file_name) - if os.path.exists(examples_path_scp): - scp_file_name = examples_path_scp assert os.path.exists( scp_file_name From ac434aa72eec6aaa489f48c2458599f33ab5f7ac Mon Sep 17 00:00:00 2001 From: Harshal Pohekar Date: Fri, 31 May 2024 13:51:29 +0530 Subject: [PATCH 14/31] Revert "system coupling fix" This reverts commit 1e41bfa5bad779652073a678b4b6301e4da83281. --- src/ansys/fluent/core/systemcoupling.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/ansys/fluent/core/systemcoupling.py b/src/ansys/fluent/core/systemcoupling.py index e28916e127f..a5c9b80bde9 100644 --- a/src/ansys/fluent/core/systemcoupling.py +++ b/src/ansys/fluent/core/systemcoupling.py @@ -93,6 +93,14 @@ def get_scp_string() -> str: # download the file locally in case Fluent is remote # assume file transfer service is configured - download the file self._solver.download(scp_file_name) + elif self._solver.connection_properties.inside_container: + # Right now, the way that PyFluent containers and tests are set up, + # the local Fluent container working directory will correspond to + # os.getcwd() in the host, so that is where the SCP file + # will be written. + examples_path_scp = os.path.join(os.getcwd(), scp_file_name) + if os.path.exists(examples_path_scp): + scp_file_name = examples_path_scp assert os.path.exists( scp_file_name From 862c9d52d32fe704487f5dc5900d76eb554c62bb Mon Sep 17 00:00:00 2001 From: Harshal Pohekar Date: Fri, 31 May 2024 13:52:06 +0530 Subject: [PATCH 15/31] Revert "test fix 1" This reverts commit 4b295d86c128e7854724eb6706a3de7a1e71cdfe. --- tests/util/__init__.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/util/__init__.py b/tests/util/__init__.py index f3c9fe5c648..04ae890fc8f 100644 --- a/tests/util/__init__.py +++ b/tests/util/__init__.py @@ -1,4 +1,3 @@ -import os from pathlib import Path From d687def06712903eec3d0b51692fc0de3ed207bd Mon Sep 17 00:00:00 2001 From: Harshal Pohekar Date: Fri, 31 May 2024 13:52:30 +0530 Subject: [PATCH 16/31] Revert "test fix" This reverts commit 982e02edf1f3bba34319aa6b1c1e9816b373d521. --- tests/test_tests_util.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/test_tests_util.py b/tests/test_tests_util.py index 999ca93541b..286caf04cdd 100644 --- a/tests/test_tests_util.py +++ b/tests/test_tests_util.py @@ -1,4 +1,3 @@ -import os from pathlib import Path import shutil From 55a58e820d87ad80ad40bf96524c6c8d5cde8996 Mon Sep 17 00:00:00 2001 From: Harshal Pohekar Date: Fri, 31 May 2024 13:53:07 +0530 Subject: [PATCH 17/31] Revert "update __init__.py" This reverts commit 16e6f7ccb1d4b5e55474006748024794d16603c5. --- src/ansys/fluent/core/__init__.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/ansys/fluent/core/__init__.py b/src/ansys/fluent/core/__init__.py index 471d3929ab4..0b320f05512 100644 --- a/src/ansys/fluent/core/__init__.py +++ b/src/ansys/fluent/core/__init__.py @@ -69,6 +69,7 @@ def version_info() -> str: USER_DATA_PATH = platformdirs.user_data_dir( appname="ansys_fluent_core", appauthor="Ansys" ) +EXAMPLES_PATH = os.path.join(USER_DATA_PATH, "examples") # Set this to False to stop automatically inferring and setting REMOTING_SERVER_ADDRESS INFER_REMOTING_IP = True From 985fbcb426a0b016ec2e78bf582ffcb31bc43ceb Mon Sep 17 00:00:00 2001 From: Harshal Pohekar Date: Fri, 31 May 2024 13:53:36 +0530 Subject: [PATCH 18/31] Revert "update test_file_transfer_service.py" This reverts commit 3b7cfe4d54ae567d6eb50b8484d63744e2717d7d. --- tests/test_file_transfer_service.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/test_file_transfer_service.py b/tests/test_file_transfer_service.py index 25a483b17d7..e8cde1e7998 100644 --- a/tests/test_file_transfer_service.py +++ b/tests/test_file_transfer_service.py @@ -26,7 +26,9 @@ def file_downloaded_to_the_client(file_name: str) -> bool: ------- Whether file exists. """ - full_file_name = pathlib.Path(os.getcwd()) / os.path.basename(file_name) + full_file_name = pathlib.Path( + "/home/runner/.local/share/ansys_fluent_core/examples" + ) / os.path.basename(file_name) return full_file_name.is_file() From 75ff17ed6264ef5920153649ec184903691f618f Mon Sep 17 00:00:00 2001 From: Harshal Pohekar Date: Fri, 31 May 2024 13:54:07 +0530 Subject: [PATCH 19/31] Revert "replace EXAMPLES_PATH with os.getcwd()" This reverts commit 5f5aa6c6c48b0b2b0424148dd735a376dabd0b1f. --- tests/test_tests_util.py | 11 ++++++----- tests/util/__init__.py | 6 ++++-- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/tests/test_tests_util.py b/tests/test_tests_util.py index 286caf04cdd..64e3a75615e 100644 --- a/tests/test_tests_util.py +++ b/tests/test_tests_util.py @@ -3,6 +3,7 @@ import pytest +from ansys.fluent.core import EXAMPLES_PATH from tests.util import rename_downloaded_file @@ -12,11 +13,11 @@ ) def test_rename_downloaded_file(ext, a, b, c, d): try: - file_path = Path(os.getcwd()) / f"{a}{ext}" + file_path = Path(EXAMPLES_PATH) / f"{a}{ext}" file_path.touch() file_path = str(file_path) new_file_path = rename_downloaded_file(file_path, "_1") - assert new_file_path == str(Path(os.getcwd()) / f"{a}_1{ext}") + assert new_file_path == str(Path(EXAMPLES_PATH) / f"{a}_1{ext}") except Exception: raise finally: @@ -24,16 +25,16 @@ def test_rename_downloaded_file(ext, a, b, c, d): try: file_path = f"{b}{ext}" - (Path(os.getcwd()) / file_path).touch() + (Path(EXAMPLES_PATH) / file_path).touch() new_file_path = rename_downloaded_file(file_path, "_1") assert new_file_path == f"{b}_1{ext}" except Exception: raise finally: - (Path(os.getcwd()) / new_file_path).unlink(missing_ok=True) + (Path(EXAMPLES_PATH) / new_file_path).unlink(missing_ok=True) try: - dir_path = Path(os.getcwd()) / c + dir_path = Path(EXAMPLES_PATH) / c dir_path.mkdir() file_path = dir_path / f"{d}{ext}" file_path.touch() diff --git a/tests/util/__init__.py b/tests/util/__init__.py index 04ae890fc8f..2a95cf4894f 100644 --- a/tests/util/__init__.py +++ b/tests/util/__init__.py @@ -1,5 +1,7 @@ from pathlib import Path +from ansys.fluent.core import EXAMPLES_PATH + def rename_downloaded_file(file_path: str, suffix: str) -> str: """Rename downloaded file by appending a suffix to the file name. @@ -27,8 +29,8 @@ def rename_downloaded_file(file_path: str, suffix: str) -> str: orig_path.rename(new_path) return str(new_path) else: - orig_abs_path = Path(os.getcwd()) / orig_path - abs_path = Path(os.getcwd()) / file_path + orig_abs_path = Path(EXAMPLES_PATH) / orig_path + abs_path = Path(EXAMPLES_PATH) / file_path new_stem = f"{file_path.stem}{suffix}" new_path = abs_path.with_stem(new_stem) new_path = new_path.with_suffix(ext) From 5d9a2fc852d247ef86f6c412368931ffd2085a26 Mon Sep 17 00:00:00 2001 From: Harshal Pohekar Date: Fri, 31 May 2024 13:54:56 +0530 Subject: [PATCH 20/31] Revert "replace pyfluent.EXAMPLES_PATH with os.getcwd()" This reverts commit b54363f070634abc349e39236f8b9ab18f618eda. --- src/ansys/fluent/core/systemcoupling.py | 5 +++-- src/ansys/fluent/core/utils/data_transfer.py | 3 ++- tests/parametric/test_parametric_workflow.py | 4 ++-- tests/test_session.py | 4 ++-- tests/test_solvermode/test_general.py | 4 +++- tests/test_topy.py | 12 ++++++------ 6 files changed, 18 insertions(+), 14 deletions(-) diff --git a/src/ansys/fluent/core/systemcoupling.py b/src/ansys/fluent/core/systemcoupling.py index a5c9b80bde9..e8117f92b6d 100644 --- a/src/ansys/fluent/core/systemcoupling.py +++ b/src/ansys/fluent/core/systemcoupling.py @@ -5,6 +5,7 @@ from typing import List import xml.etree.ElementTree as XmlET +import ansys.fluent.core as pyfluent from ansys.fluent.core.utils.fluent_version import FluentVersion @@ -96,9 +97,9 @@ def get_scp_string() -> str: elif self._solver.connection_properties.inside_container: # Right now, the way that PyFluent containers and tests are set up, # the local Fluent container working directory will correspond to - # os.getcwd() in the host, so that is where the SCP file + # pyfluent.EXAMPLES_PATH in the host, so that is where the SCP file # will be written. - examples_path_scp = os.path.join(os.getcwd(), scp_file_name) + examples_path_scp = os.path.join(pyfluent.EXAMPLES_PATH, scp_file_name) if os.path.exists(examples_path_scp): scp_file_name = examples_path_scp diff --git a/src/ansys/fluent/core/utils/data_transfer.py b/src/ansys/fluent/core/utils/data_transfer.py index e5fde5ecab1..e490ee0b5f9 100644 --- a/src/ansys/fluent/core/utils/data_transfer.py +++ b/src/ansys/fluent/core/utils/data_transfer.py @@ -6,6 +6,7 @@ from pathlib import Path, PurePosixPath from typing import Optional +import ansys.fluent.core as pyfluent from ansys.fluent.core.launcher.fluent_container import DEFAULT_CONTAINER_MOUNT_PATH from ansys.fluent.core.utils.execution import asynchronous @@ -92,7 +93,7 @@ def transfer_case( """ inside_container = source_instance.connection_properties.inside_container if not workdir: - workdir = Path(os.getcwd()) + workdir = Path(pyfluent.EXAMPLES_PATH) else: workdir = Path(workdir) if inside_container: diff --git a/tests/parametric/test_parametric_workflow.py b/tests/parametric/test_parametric_workflow.py index cb711e49f50..bc33c99c30a 100644 --- a/tests/parametric/test_parametric_workflow.py +++ b/tests/parametric/test_parametric_workflow.py @@ -20,8 +20,8 @@ def pytest_approx(expected): @pytest.mark.fluent_version("latest") def test_parametric_workflow(): # parent path needs to exist for mkdtemp - Path(os.getcwd()).mkdir(parents=True, exist_ok=True) - tmp_save_path = tempfile.mkdtemp(dir=os.getcwd()) + Path(pyfluent.EXAMPLES_PATH).mkdir(parents=True, exist_ok=True) + tmp_save_path = tempfile.mkdtemp(dir=pyfluent.EXAMPLES_PATH) if pyfluent.USE_FILE_TRANSFER_SERVICE: file_transfer_service = RemoteFileTransferStrategy( host_mount_path=tmp_save_path diff --git a/tests/test_session.py b/tests/test_session.py index 955a4998176..5c2f16ff18e 100644 --- a/tests/test_session.py +++ b/tests/test_session.py @@ -292,7 +292,7 @@ def test_journal_creation(file_format, new_mesh_session): fd, file_name = tempfile.mkstemp( suffix=f"-{os.getpid()}.{file_format}", prefix="pyfluent-", - dir=str(os.getcwd()), + dir=str(pyfluent.EXAMPLES_PATH), ) os.close(fd) @@ -321,7 +321,7 @@ def test_start_transcript_file_write(new_mesh_session): fd, file_name = tempfile.mkstemp( suffix=f"-{os.getpid()}.trn", prefix="pyfluent-", - dir=str(os.getcwd()), + dir=str(pyfluent.EXAMPLES_PATH), ) os.close(fd) diff --git a/tests/test_solvermode/test_general.py b/tests/test_solvermode/test_general.py index 803320a46fa..6f9caae7dcb 100644 --- a/tests/test_solvermode/test_general.py +++ b/tests/test_solvermode/test_general.py @@ -3,6 +3,8 @@ import pytest +import ansys.fluent.core as pyfluent + @pytest.mark.settings_only @pytest.mark.fluent_version("latest") @@ -10,7 +12,7 @@ def test_solver_import_mixingelbow(load_mixing_elbow_settings_only): solver_session = load_mixing_elbow_settings_only assert solver_session.settings.is_active() assert solver_session.health_check.is_serving - file_name = Path(os.getcwd()) / "jou_test_general.py" + file_name = Path(pyfluent.EXAMPLES_PATH) / "jou_test_general.py" solver_session.journal.start(file_name.as_posix()) ### assert solver_session.setup.models.energy.enabled() diff --git a/tests/test_topy.py b/tests/test_topy.py index 53b97d7dea2..505d86a0c45 100644 --- a/tests/test_topy.py +++ b/tests/test_topy.py @@ -9,7 +9,7 @@ @pytest.mark.skip(reason="Unable to read generated python journal from fluent.") def test_single_jou(): - file_name = os.path.join(os.getcwd(), "jou1.jou") + file_name = os.path.join(pyfluent.EXAMPLES_PATH, "jou1.jou") with open(file_name, "w") as journal: journal.write('(display "from jou1.jou")') @@ -43,7 +43,7 @@ def test_single_jou(): @pytest.mark.skip(reason="Unable to read generated python journal from fluent.") def test_single_scm(): - file_name = os.path.join(os.getcwd(), "jou1.scm") + file_name = os.path.join(pyfluent.EXAMPLES_PATH, "jou1.scm") with open(file_name, "w") as journal: journal.write('(display "from jou1.scm")') @@ -77,8 +77,8 @@ def test_single_scm(): @pytest.mark.skip(reason="Unable to read generated python journal from fluent.") def test_2_jou(): - file_name_1 = os.path.join(os.getcwd(), "jou1.jou") - file_name_2 = os.path.join(os.getcwd(), "jou2.jou") + file_name_1 = os.path.join(pyfluent.EXAMPLES_PATH, "jou1.jou") + file_name_2 = os.path.join(pyfluent.EXAMPLES_PATH, "jou2.jou") with open(file_name_1, "w") as journal: journal.write('(display "from jou1.jou")') @@ -129,8 +129,8 @@ def test_2_jou(): @pytest.mark.skip(reason="Unable to read generated python journal from fluent.") def test_2_scm(): - file_name_1 = os.path.join(os.getcwd(), "jou1.scm") - file_name_2 = os.path.join(os.getcwd(), "jou2.scm") + file_name_1 = os.path.join(pyfluent.EXAMPLES_PATH, "jou1.scm") + file_name_2 = os.path.join(pyfluent.EXAMPLES_PATH, "jou2.scm") with open(file_name_1, "w") as journal: journal.write('(display "from jou1.scm")') From 2534bf65bd821cffa8fb69d9a490ecc2c07d3503 Mon Sep 17 00:00:00 2001 From: Harshal Pohekar Date: Fri, 31 May 2024 13:57:23 +0530 Subject: [PATCH 21/31] remove download_file changes --- src/ansys/fluent/core/examples/downloads.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ansys/fluent/core/examples/downloads.py b/src/ansys/fluent/core/examples/downloads.py index 073d114b817..c0a2abc960b 100644 --- a/src/ansys/fluent/core/examples/downloads.py +++ b/src/ansys/fluent/core/examples/downloads.py @@ -39,7 +39,7 @@ def delete_downloads(): def _decompress(file_name: str) -> None: """Decompress zipped file.""" zip_ref = zipfile.ZipFile(file_name, "r") - zip_ref.extractall(os.getcwd()) + zip_ref.extractall(pyfluent.EXAMPLES_PATH) return zip_ref.close() @@ -62,7 +62,7 @@ def _retrieve_file( """Download specified file from specified URL.""" file_name = os.path.basename(file_name) if save_path is None: - save_path = os.getcwd() + save_path = pyfluent.EXAMPLES_PATH else: save_path = os.path.abspath(save_path) local_path = os.path.join(save_path, file_name) @@ -196,7 +196,7 @@ def path(file_name: str): """ if os.path.isabs(file_name): return file_name - file_path = Path(os.getcwd()) / file_name + file_path = Path(pyfluent.EXAMPLES_PATH) / file_name if file_path.is_file(): return str(file_path) else: From 59436cb3f90954384ada9577d3e010ec10cd0c9e Mon Sep 17 00:00:00 2001 From: Harshal Pohekar Date: Fri, 31 May 2024 14:49:42 +0530 Subject: [PATCH 22/31] configure host_mount_path --- src/ansys/fluent/core/launcher/fluent_container.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/ansys/fluent/core/launcher/fluent_container.py b/src/ansys/fluent/core/launcher/fluent_container.py index ee07daa3cdf..95e738e0f2c 100644 --- a/src/ansys/fluent/core/launcher/fluent_container.py +++ b/src/ansys/fluent/core/launcher/fluent_container.py @@ -186,7 +186,11 @@ def configure_container_dict( if file_transfer_service: host_mount_path = pyfluent.USER_DATA_PATH else: - host_mount_path = os.getcwd() + host_mount_path = ( + pyfluent.EXAMPLES_PATH + if os.getenv("LOGNAME") == "ansys" + else os.getcwd() + ) elif "volumes" in container_dict: logger.warning( "'volumes' keyword specified in 'container_dict', but " From 13ebba3a1e2e319f42dd413efed6459bc19ec0a7 Mon Sep 17 00:00:00 2001 From: Harshal Pohekar Date: Fri, 31 May 2024 15:57:34 +0530 Subject: [PATCH 23/31] add test to check warning --- tests/test_launcher.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tests/test_launcher.py b/tests/test_launcher.py index cf6bd5b9f29..c18c4c73bd6 100644 --- a/tests/test_launcher.py +++ b/tests/test_launcher.py @@ -1,3 +1,4 @@ +import os from pathlib import Path import platform @@ -450,3 +451,14 @@ def get_processor_count(solver): # https://github.com/ansys/pyfluent/issues/2624 # with pyfluent.launch_fluent(additional_arguments="-t2") as solver: # assert get_processor_count(solver) == 2 + + +def test_container_warning_host_mount_path(caplog): + if check_docker_support(): + solver = pyfluent.launch_fluent() + assert ( + "this path available as /mnt/pyfluent for the Fluent session running inside the container." + in caplog.text + ) + assert pyfluent.EXAMPLES_PATH in caplog.txt + assert os.getcwd() not in caplog.text From 809b758ccc69a5cbd9fe2bd5360941fa20204b88 Mon Sep 17 00:00:00 2001 From: Harshal Pohekar Date: Fri, 31 May 2024 16:00:05 +0530 Subject: [PATCH 24/31] add test to check warning 1 --- tests/test_launcher.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_launcher.py b/tests/test_launcher.py index c18c4c73bd6..a9be186051b 100644 --- a/tests/test_launcher.py +++ b/tests/test_launcher.py @@ -453,7 +453,7 @@ def get_processor_count(solver): # assert get_processor_count(solver) == 2 -def test_container_warning_host_mount_path(caplog): +def test_container_warning_for_host_mount_path(caplog): if check_docker_support(): solver = pyfluent.launch_fluent() assert ( From 186cd62e77fdb6d6ff84cafde79ec8f7aaa81eb4 Mon Sep 17 00:00:00 2001 From: Harshal Pohekar Date: Fri, 31 May 2024 16:01:20 +0530 Subject: [PATCH 25/31] add test to check warning 2 --- tests/test_launcher.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_launcher.py b/tests/test_launcher.py index a9be186051b..c442e47d749 100644 --- a/tests/test_launcher.py +++ b/tests/test_launcher.py @@ -460,5 +460,5 @@ def test_container_warning_for_host_mount_path(caplog): "this path available as /mnt/pyfluent for the Fluent session running inside the container." in caplog.text ) - assert pyfluent.EXAMPLES_PATH in caplog.txt + assert pyfluent.EXAMPLES_PATH in caplog.text assert os.getcwd() not in caplog.text From 50a24a9ad10c3e758c06e20b916366ad91832f44 Mon Sep 17 00:00:00 2001 From: Harshal Pohekar Date: Mon, 3 Jun 2024 10:21:26 +0530 Subject: [PATCH 26/31] add module level variable --- src/ansys/fluent/core/__init__.py | 4 +++- src/ansys/fluent/core/launcher/fluent_container.py | 6 +----- tests/conftest.py | 2 ++ tests/test_launcher.py | 14 +++++++------- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/ansys/fluent/core/__init__.py b/src/ansys/fluent/core/__init__.py index 0b320f05512..f7574822c26 100644 --- a/src/ansys/fluent/core/__init__.py +++ b/src/ansys/fluent/core/__init__.py @@ -69,7 +69,9 @@ def version_info() -> str: USER_DATA_PATH = platformdirs.user_data_dir( appname="ansys_fluent_core", appauthor="Ansys" ) -EXAMPLES_PATH = os.path.join(USER_DATA_PATH, "examples") +EXAMPLES_PATH = os.getcwd() + +PYFLUENT_CONTAINER_MOUNT_PATH = os.path.join(USER_DATA_PATH, "examples") # Set this to False to stop automatically inferring and setting REMOTING_SERVER_ADDRESS INFER_REMOTING_IP = True diff --git a/src/ansys/fluent/core/launcher/fluent_container.py b/src/ansys/fluent/core/launcher/fluent_container.py index 95e738e0f2c..8add4a6348d 100644 --- a/src/ansys/fluent/core/launcher/fluent_container.py +++ b/src/ansys/fluent/core/launcher/fluent_container.py @@ -186,11 +186,7 @@ def configure_container_dict( if file_transfer_service: host_mount_path = pyfluent.USER_DATA_PATH else: - host_mount_path = ( - pyfluent.EXAMPLES_PATH - if os.getenv("LOGNAME") == "ansys" - else os.getcwd() - ) + host_mount_path = pyfluent.EXAMPLES_PATH elif "volumes" in container_dict: logger.warning( "'volumes' keyword specified in 'container_dict', but " diff --git a/tests/conftest.py b/tests/conftest.py index 57d09bcb9a0..1f5e2ae4c00 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -7,6 +7,7 @@ from packaging.version import Version import pytest +import ansys.fluent.core as pyfluent from ansys.fluent.core.utils.fluent_version import FluentVersion _fluent_release_version = FluentVersion.current_release().value @@ -74,6 +75,7 @@ def run_before_each_test( monkeypatch: pytest.MonkeyPatch, request: pytest.FixtureRequest ) -> None: monkeypatch.setenv("PYFLUENT_TEST_NAME", request.node.name) + pyfluent.EXAMPLES_PATH = pyfluent.PYFLUENT_CONTAINER_MOUNT_PATH class Helpers: diff --git a/tests/test_launcher.py b/tests/test_launcher.py index c442e47d749..21809a49052 100644 --- a/tests/test_launcher.py +++ b/tests/test_launcher.py @@ -454,11 +454,11 @@ def get_processor_count(solver): def test_container_warning_for_host_mount_path(caplog): + container_dict = { + "host_mount_path": os.getcwd(), + "container_mount_path": "/mnt/pyfluent/tests", + } if check_docker_support(): - solver = pyfluent.launch_fluent() - assert ( - "this path available as /mnt/pyfluent for the Fluent session running inside the container." - in caplog.text - ) - assert pyfluent.EXAMPLES_PATH in caplog.text - assert os.getcwd() not in caplog.text + solver = pyfluent.launch_fluent(container_dict=container_dict) + assert container_dict["host_mount_path"] in caplog.text + assert container_dict["container_mount_path"] in caplog.text From e4f576f225a06132943c783e575554afae212f0a Mon Sep 17 00:00:00 2001 From: Harshal Pohekar <106588300+hpohekar@users.noreply.github.com> Date: Mon, 3 Jun 2024 23:19:27 +0530 Subject: [PATCH 27/31] Update tests/conftest.py Co-authored-by: Raphael Luciano --- tests/conftest.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/conftest.py b/tests/conftest.py index 1f5e2ae4c00..bb2f730530d 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -75,7 +75,7 @@ def run_before_each_test( monkeypatch: pytest.MonkeyPatch, request: pytest.FixtureRequest ) -> None: monkeypatch.setenv("PYFLUENT_TEST_NAME", request.node.name) - pyfluent.EXAMPLES_PATH = pyfluent.PYFLUENT_CONTAINER_MOUNT_PATH + pyfluent.CONTAINER_MOUNT_PATH = pyfluent.EXAMPLES_PATH class Helpers: From d447415fe32880ad496482a846776900d6e1682d Mon Sep 17 00:00:00 2001 From: Harshal Pohekar Date: Mon, 3 Jun 2024 23:22:31 +0530 Subject: [PATCH 28/31] rename variable --- src/ansys/fluent/core/launcher/fluent_container.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ansys/fluent/core/launcher/fluent_container.py b/src/ansys/fluent/core/launcher/fluent_container.py index 8add4a6348d..b8023720524 100644 --- a/src/ansys/fluent/core/launcher/fluent_container.py +++ b/src/ansys/fluent/core/launcher/fluent_container.py @@ -186,7 +186,7 @@ def configure_container_dict( if file_transfer_service: host_mount_path = pyfluent.USER_DATA_PATH else: - host_mount_path = pyfluent.EXAMPLES_PATH + host_mount_path = pyfluent.CONTAINER_MOUNT_PATH elif "volumes" in container_dict: logger.warning( "'volumes' keyword specified in 'container_dict', but " From d3ec884f86518d915f74fff6a5791199a8b3b995 Mon Sep 17 00:00:00 2001 From: Harshal Pohekar Date: Mon, 3 Jun 2024 23:25:51 +0530 Subject: [PATCH 29/31] rename variable 1 --- src/ansys/fluent/core/__init__.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/ansys/fluent/core/__init__.py b/src/ansys/fluent/core/__init__.py index f7574822c26..9f04b67d29d 100644 --- a/src/ansys/fluent/core/__init__.py +++ b/src/ansys/fluent/core/__init__.py @@ -69,9 +69,8 @@ def version_info() -> str: USER_DATA_PATH = platformdirs.user_data_dir( appname="ansys_fluent_core", appauthor="Ansys" ) -EXAMPLES_PATH = os.getcwd() - -PYFLUENT_CONTAINER_MOUNT_PATH = os.path.join(USER_DATA_PATH, "examples") +EXAMPLES_PATH = os.path.join(USER_DATA_PATH, "examples") +CONTAINER_MOUNT_PATH = os.getcwd() # Set this to False to stop automatically inferring and setting REMOTING_SERVER_ADDRESS INFER_REMOTING_IP = True From 6fa030e6164995316247b5edbdb76904c544a060 Mon Sep 17 00:00:00 2001 From: Harshal Pohekar Date: Tue, 4 Jun 2024 09:55:30 +0530 Subject: [PATCH 30/31] use env --- src/ansys/fluent/core/__init__.py | 1 - src/ansys/fluent/core/launcher/fluent_container.py | 4 +++- tests/conftest.py | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/ansys/fluent/core/__init__.py b/src/ansys/fluent/core/__init__.py index 9f04b67d29d..0b320f05512 100644 --- a/src/ansys/fluent/core/__init__.py +++ b/src/ansys/fluent/core/__init__.py @@ -70,7 +70,6 @@ def version_info() -> str: appname="ansys_fluent_core", appauthor="Ansys" ) EXAMPLES_PATH = os.path.join(USER_DATA_PATH, "examples") -CONTAINER_MOUNT_PATH = os.getcwd() # Set this to False to stop automatically inferring and setting REMOTING_SERVER_ADDRESS INFER_REMOTING_IP = True diff --git a/src/ansys/fluent/core/launcher/fluent_container.py b/src/ansys/fluent/core/launcher/fluent_container.py index b8023720524..c0ff1c82c42 100644 --- a/src/ansys/fluent/core/launcher/fluent_container.py +++ b/src/ansys/fluent/core/launcher/fluent_container.py @@ -186,7 +186,9 @@ def configure_container_dict( if file_transfer_service: host_mount_path = pyfluent.USER_DATA_PATH else: - host_mount_path = pyfluent.CONTAINER_MOUNT_PATH + host_mount_path = Path( + os.getenv("PYFLUENT_CONTAINER_MOUNT_PATH", os.getcwd()) + ) elif "volumes" in container_dict: logger.warning( "'volumes' keyword specified in 'container_dict', but " diff --git a/tests/conftest.py b/tests/conftest.py index bb2f730530d..00efa430125 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -75,7 +75,7 @@ def run_before_each_test( monkeypatch: pytest.MonkeyPatch, request: pytest.FixtureRequest ) -> None: monkeypatch.setenv("PYFLUENT_TEST_NAME", request.node.name) - pyfluent.CONTAINER_MOUNT_PATH = pyfluent.EXAMPLES_PATH + monkeypatch.setenv("PYFLUENT_CONTAINER_MOUNT_PATH", pyfluent.EXAMPLES_PATH) class Helpers: From 2887edcb8ea6eaabb006277b0c91c33a397af893 Mon Sep 17 00:00:00 2001 From: Harshal Pohekar Date: Tue, 4 Jun 2024 11:53:47 +0530 Subject: [PATCH 31/31] use var --- src/ansys/fluent/core/__init__.py | 2 ++ src/ansys/fluent/core/launcher/fluent_container.py | 4 +--- tests/conftest.py | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/ansys/fluent/core/__init__.py b/src/ansys/fluent/core/__init__.py index 0b320f05512..05d635ceb86 100644 --- a/src/ansys/fluent/core/__init__.py +++ b/src/ansys/fluent/core/__init__.py @@ -71,6 +71,8 @@ def version_info() -> str: ) EXAMPLES_PATH = os.path.join(USER_DATA_PATH, "examples") +CONTAINER_MOUNT_PATH = None + # Set this to False to stop automatically inferring and setting REMOTING_SERVER_ADDRESS INFER_REMOTING_IP = True diff --git a/src/ansys/fluent/core/launcher/fluent_container.py b/src/ansys/fluent/core/launcher/fluent_container.py index c0ff1c82c42..0aa913ec3d2 100644 --- a/src/ansys/fluent/core/launcher/fluent_container.py +++ b/src/ansys/fluent/core/launcher/fluent_container.py @@ -186,9 +186,7 @@ def configure_container_dict( if file_transfer_service: host_mount_path = pyfluent.USER_DATA_PATH else: - host_mount_path = Path( - os.getenv("PYFLUENT_CONTAINER_MOUNT_PATH", os.getcwd()) - ) + host_mount_path = pyfluent.CONTAINER_MOUNT_PATH or os.getcwd() elif "volumes" in container_dict: logger.warning( "'volumes' keyword specified in 'container_dict', but " diff --git a/tests/conftest.py b/tests/conftest.py index 00efa430125..bb2f730530d 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -75,7 +75,7 @@ def run_before_each_test( monkeypatch: pytest.MonkeyPatch, request: pytest.FixtureRequest ) -> None: monkeypatch.setenv("PYFLUENT_TEST_NAME", request.node.name) - monkeypatch.setenv("PYFLUENT_CONTAINER_MOUNT_PATH", pyfluent.EXAMPLES_PATH) + pyfluent.CONTAINER_MOUNT_PATH = pyfluent.EXAMPLES_PATH class Helpers: