diff --git a/src/ansys/fluent/core/__init__.py b/src/ansys/fluent/core/__init__.py index ffeb645257d..e1366d1e508 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 26fddea6c82..0aa913ec3d2 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 or os.getcwd() elif "volumes" in container_dict: logger.warning( "'volumes' keyword specified in 'container_dict', but " @@ -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.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: if not port: diff --git a/tests/conftest.py b/tests/conftest.py index 57d09bcb9a0..bb2f730530d 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.CONTAINER_MOUNT_PATH = pyfluent.EXAMPLES_PATH class Helpers: diff --git a/tests/test_launcher.py b/tests/test_launcher.py index f048b78d514..5b7f4b06664 100644 --- a/tests/test_launcher.py +++ b/tests/test_launcher.py @@ -1,3 +1,4 @@ +import os from pathlib import Path import platform @@ -448,3 +449,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_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(container_dict=container_dict) + assert container_dict["host_mount_path"] in caplog.text + assert container_dict["container_mount_path"] in caplog.text