Skip to content

Commit 4b01958

Browse files
mkundu1pyansys-ci-bot
authored andcommitted
fix: Some config and env var cleanup (#4380)
1. Remove the config equivalent to `PYFLUENT_FLUENT_ROOT` environment variable. That environment variable is only for development use. 2. Remove the mentions of the environment `PYFLUENT_LAUNCH_CONTAINER` from user documentation. That environment variable is only for CI use. 3. Fix a typo in slurm launcher. --------- Co-authored-by: pyansys-ci-bot <[email protected]>
1 parent e4b60fc commit 4b01958

File tree

10 files changed

+10
-28
lines changed

10 files changed

+10
-28
lines changed

doc/changelog.d/4380.fixed.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Some config and env var cleanup

doc/source/user_guide/file_transfer.rst

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,6 @@ Depending on how Fluent is launched, different file transfer strategies are avai
4747

4848
.. code-block:: python
4949
50-
>>> import os
51-
>>> os.environ["PYFLUENT_LAUNCH_CONTAINER"] = "1"
5250
>>> import ansys.fluent.core as pyfluent
5351
>>> from ansys.fluent.core import examples
5452
>>> from ansys.fluent.core.utils.file_transfer_service import ContainerFileTransferStrategy

doc/source/user_guide/session/launching_ansys_fluent.rst

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,6 @@ Use this method when:
5454

5555
.. code-block:: python
5656
57-
import os
58-
os.environ["PYFLUENT_LAUNCH_CONTAINER"] = "1"
59-
6057
import ansys.fluent.core as pyfluent
6158
from ansys.fluent.core.utils.networking import get_free_port
6259
@@ -453,21 +450,13 @@ Pass ``use_docker_compose=True`` or ``use_podman_compose=True`` to use Docker Co
453450

454451
Example:
455452

456-
Set environment variables to select the container engine:
457-
458-
.. code:: python
459-
460-
>>> import os
461-
>>> os.environ["PYFLUENT_LAUNCH_CONTAINER"] = "1"
462-
463-
464-
Then launch:
453+
Launch Fluent in container mode via PyFluent:
465454

466455
.. code:: python
467456
468457
>>> import ansys.fluent.core as pyfluent
469458
>>> from ansys.fluent.core import examples
470-
>>> solver_session = pyfluent.launch_fluent(use_docker_compose=True)
459+
>>> solver_session = pyfluent.launch_fluent(start_container=True, use_docker_compose=True)
471460
>>> case_file_name = examples.download_file("mixing_elbow.cas.h5", "pyfluent/mixing_elbow")
472461
>>> solver_session.file.read(file_name=case_file_name, file_type="case")
473462
>>> solver_session.exit()

src/ansys/fluent/core/examples/downloads.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ def download_file(
137137
save_path : str, optional
138138
Path to download the specified file to.
139139
return_without_path : bool, optional
140-
When unspecified, defaults to False, unless the PYFLUENT_LAUNCH_CONTAINER=1 environment variable is specified,
140+
When unspecified, defaults to False, unless the launch_fluent_container config is set to True,
141141
in which case defaults to True.
142142
Relevant when using Fluent Docker container images, as the full path for the imported file from
143143
the host side is not necessarily going to be the same as the one for Fluent inside the container.

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
"""Provides a module for enums used in the PyFluent."""
2424

2525
from enum import Enum
26+
import os
2627
import warnings
2728

2829
from ansys.fluent.core.exceptions import DisallowedValuesError
@@ -344,7 +345,6 @@ def _get_standalone_launch_fluent_version(argvals) -> FluentVersion | None:
344345
FluentVersion, optional
345346
Fluent version or ``None``
346347
"""
347-
from ansys.fluent.core import config
348348

349349
# Look for Fluent version in the following order:
350350
# 1. product_version parameter passed with launch_fluent
@@ -358,7 +358,7 @@ def _get_standalone_launch_fluent_version(argvals) -> FluentVersion | None:
358358

359359
# (DEV) if "PYFLUENT_FLUENT_ROOT" environment variable is defined, we cannot
360360
# determine the Fluent version, so returning None.
361-
if config.fluent_root:
361+
if "PYFLUENT_FLUENT_ROOT" in os.environ:
362362
return None
363363

364364
# 2. the latest ANSYS version from AWP_ROOT environment variables

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,6 @@ def get_fluent_exe_path(**launch_argvals) -> Path:
149149
Path
150150
Fluent executable path
151151
"""
152-
from ansys.fluent.core import config
153152

154153
def get_exe_path(fluent_root: Path) -> Path:
155154
if launcher_utils.is_windows():
@@ -171,7 +170,7 @@ def get_exe_path(fluent_root: Path) -> Path:
171170
return FluentVersion(product_version).get_fluent_exe_path()
172171

173172
# (DEV) "PYFLUENT_FLUENT_ROOT" environment variable
174-
fluent_root = config.fluent_root
173+
fluent_root = os.getenv("PYFLUENT_FLUENT_ROOT")
175174
if fluent_root:
176175
return get_exe_path(Path(fluent_root))
177176

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,7 @@ def _prepare(self):
460460
launch_cmd += _build_journal_argument(
461461
self._argvals["topy"], self._argvals["journal_file_names"]
462462
)
463-
launch_cmd += ' --setenv="FLUENT_ALLOW_REMOTE_GRPC_CONNECTION=1"'
463+
launch_cmd += ' -setenv="FLUENT_ALLOW_REMOTE_GRPC_CONNECTION=1"'
464464

465465
logger.debug(f"Launching Fluent with command: {launch_cmd}")
466466
proc = subprocess.Popen(launch_cmd, **kwargs)

src/ansys/fluent/core/module_config.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -300,11 +300,6 @@ class Config:
300300
lambda instance: instance._env.get("PYFLUENT_HIDE_LOG_SECRETS") == "1"
301301
)
302302

303-
#: The Fluent root directory to be used for PyFluent, defaults to the value of ``PYFLUENT_FLUENT_ROOT`` environment variable.
304-
fluent_root = _ConfigDescriptor["Config"](
305-
lambda instance: instance._env.get("PYFLUENT_FLUENT_ROOT")
306-
)
307-
308303
#: The remoting server address to be used in Fluent, defaults to the value of ``REMOTING_SERVER_ADDRESS`` environment variable.
309304
remoting_server_address = _ConfigDescriptor["Config"](
310305
lambda instance: instance._env.get("REMOTING_SERVER_ADDRESS")

tests/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ def mock_awp_vars(self, version=None):
196196
version = FluentVersion.current_release()
197197
elif not isinstance(version, FluentVersion):
198198
version = FluentVersion(version)
199-
self.monkeypatch.setattr(pyfluent.config, "fluent_root", None)
199+
self.monkeypatch.delenv("PYFLUENT_FLUENT_ROOT", raising=False)
200200
for fv in FluentVersion:
201201
if fv <= version:
202202
self.monkeypatch.setenv(fv.awp_var, f"ansys_inc/{fv.name}")

tests/test_launcher.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ def test_get_fluent_exe_path_from_product_version_launcher_arg(helpers):
374374

375375
def test_get_fluent_exe_path_from_pyfluent_fluent_root(helpers, monkeypatch):
376376
helpers.mock_awp_vars()
377-
monkeypatch.setattr(pyfluent.config, "fluent_root", "dev/vNNN/fluent")
377+
monkeypatch.setenv("PYFLUENT_FLUENT_ROOT", "dev/vNNN/fluent")
378378
if platform.system() == "Windows":
379379
expected_path = Path("dev/vNNN/fluent") / "ntbin" / "win64" / "fluent.exe"
380380
else:

0 commit comments

Comments
 (0)