Skip to content

Commit

Permalink
fix: update fluent container mount path and show them using logging (#…
Browse files Browse the repository at this point in the history
…2874)

* fix: Update host_mount_path and examples download path

* show mapped path using logging

* update working dir

* Update src/ansys/fluent/core/launcher/fluent_container.py

Co-authored-by: Raphael Luciano <[email protected]>

* use os.getcwd()

* remove __name__

* replace pyfluent.EXAMPLES_PATH with os.getcwd()

* replace EXAMPLES_PATH with os.getcwd()

* update test_file_transfer_service.py

* update __init__.py

* test fix

* test fix 1

* system coupling fix

* Revert "system coupling fix"

This reverts commit 1e41bfa.

* Revert "test fix 1"

This reverts commit 4b295d8.

* Revert "test fix"

This reverts commit 982e02e.

* Revert "update __init__.py"

This reverts commit 16e6f7c.

* Revert "update test_file_transfer_service.py"

This reverts commit 3b7cfe4.

* Revert "replace EXAMPLES_PATH with os.getcwd()"

This reverts commit 5f5aa6c.

* Revert "replace pyfluent.EXAMPLES_PATH with os.getcwd()"

This reverts commit b54363f.

* remove download_file changes

* configure host_mount_path

* add test to check warning

* add test to check warning 1

* add test to check warning 2

* add module level variable

---------

Co-authored-by: Raphael Luciano <[email protected]>
  • Loading branch information
hpohekar and raph-luc authored Jun 5, 2024
1 parent f6ceaa9 commit 99ef6e9
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/ansys/fluent/core/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
5 changes: 4 additions & 1 deletion src/ansys/fluent/core/launcher/fluent_container.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 "
Expand Down Expand Up @@ -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:
Expand Down
2 changes: 2 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down
12 changes: 12 additions & 0 deletions tests/test_launcher.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import os
from pathlib import Path
import platform

Expand Down Expand Up @@ -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

0 comments on commit 99ef6e9

Please sign in to comment.