Skip to content

Commit 13969e6

Browse files
authored
Merge branch 'rluciano/container-and-launch-fixes' into rluciano/env-vars-revision
2 parents cba8260 + 220aece commit 13969e6

File tree

4 files changed

+17
-20
lines changed

4 files changed

+17
-20
lines changed

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

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -123,15 +123,6 @@ def dict_to_str(dict: dict) -> str:
123123
"""Converts the dict to string while hiding the 'environment' argument from the dictionary,
124124
if the environment variable 'PYFLUENT_HIDE_LOG_SECRETS' is '1'.
125125
This is useful for logging purposes, to avoid printing sensitive information such as license server details.
126-
127-
Parameters
128-
----------
129-
dict : dict
130-
The container dictionary to be converted to string.
131-
Returns
132-
-------
133-
string
134-
Nicely formatted string representation of the dictionary, with the 'environment' key removed if hiding secrets.
135126
"""
136127

137128
if "environment" in dict and os.getenv("PYFLUENT_HIDE_LOG_SECRETS") == "1":
@@ -182,9 +173,12 @@ def configure_container_dict(
182173
args : List[str]
183174
List of Fluent launch arguments.
184175
mount_source : str | Path, optional
185-
Existing path in the host operating system that will be mounted to ``mount_target``.
176+
Path on the host system to mount into the container. This directory will serve as the working directory
177+
for the Fluent process inside the container. If not specified, PyFluent's current working directory will
178+
be used.
186179
mount_target : str | Path, optional
187-
Path inside the container where ``mount_source`` will be mounted to.
180+
Path inside the container where ``mount_source`` will be mounted. This will be the working directory path
181+
visible to the Fluent process running inside the container.
188182
timeout : int, optional
189183
Time limit for the Fluent container to start, in seconds. By default, 60 seconds.
190184
port : int, optional

tests/test_builtin_settings.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -661,8 +661,8 @@ def test_builtin_settings(mixing_elbow_case_data_session):
661661
else:
662662
with pytest.raises(RuntimeError):
663663
CustomVectors(settings_source=solver)
664-
tmp_save_path = tempfile.mkdtemp(dir=pyfluent.EXAMPLES_PATH)
665-
project_file = Path(tmp_save_path) / "mixing_elbow_param.flprj"
664+
tmp_save_path = Path(tempfile.mkdtemp(dir=pyfluent.EXAMPLES_PATH))
665+
project_file = Path(tmp_save_path.parts[-1]) / "mixing_elbow_param.flprj"
666666
solver.settings.parametric_studies.initialize(project_filename=str(project_file))
667667
assert ParametricStudies(settings_source=solver) == solver.parametric_studies
668668
assert (

tests/test_launcher.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -554,10 +554,10 @@ def test_fluent_automatic_transcript(monkeypatch):
554554
with monkeypatch.context() as m:
555555
m.setattr(pyfluent, "FLUENT_AUTOMATIC_TRANSCRIPT", True)
556556
with TemporaryDirectory(dir=pyfluent.EXAMPLES_PATH) as tmp_dir:
557-
with pyfluent.launch_fluent(container_dict=dict(working_dir=tmp_dir)):
557+
with pyfluent.launch_fluent(container_dict=dict(mount_source=tmp_dir)):
558558
assert list(Path(tmp_dir).glob("*.trn"))
559559
with TemporaryDirectory(dir=pyfluent.EXAMPLES_PATH) as tmp_dir:
560-
with pyfluent.launch_fluent(container_dict=dict(working_dir=tmp_dir)):
560+
with pyfluent.launch_fluent(container_dict=dict(mount_source=tmp_dir)):
561561
assert not list(Path(tmp_dir).glob("*.trn"))
562562

563563

tests/test_session.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -594,7 +594,6 @@ def test_general_exception_behaviour_in_session(new_solver_session):
594594
case_file = examples.download_file(
595595
"mixing_elbow.cas.h5",
596596
"pyfluent/mixing_elbow",
597-
return_without_path=False,
598597
)
599598
solver.settings.file.read(file_type="case", file_name=case_file)
600599
solver.file.write(file_name="sample.cas.h5", file_type="case")
@@ -658,16 +657,20 @@ def test_app_utilities_new_and_old(mixing_elbow_settings_session):
658657

659658
assert not solver._app_utilities.is_solution_data_available()
660659

661-
tmp_dir = tempfile.mkdtemp(dir=pyfluent.EXAMPLES_PATH)
660+
tmp_path = tempfile.mkdtemp(dir=pyfluent.EXAMPLES_PATH)
662661

663-
solver.chdir(tmp_dir)
662+
# when running in a container, only the randomly generated folder name will be seen
663+
# the full paths will be different between host and container
664+
tmp_folder = Path(tmp_path).parts[-1]
665+
666+
solver.chdir(tmp_folder)
664667

665668
cortex_info = solver._app_utilities.get_controller_process_info()
666669
solver_info = solver._app_utilities.get_solver_process_info()
667670

668-
assert Path(cortex_info.working_directory) == Path(tmp_dir)
671+
assert Path(cortex_info.working_directory).parts[-1] == tmp_folder
669672

670-
assert Path(solver_info.working_directory) == Path(tmp_dir)
673+
assert Path(solver_info.working_directory).parts[-1] == tmp_folder
671674

672675

673676
@pytest.mark.standalone

0 commit comments

Comments
 (0)