Skip to content

fix: Some config and env var cleanup #4380

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/changelog.d/4380.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Some config and env var cleanup
2 changes: 0 additions & 2 deletions doc/source/user_guide/file_transfer.rst
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@ Depending on how Fluent is launched, different file transfer strategies are avai

.. code-block:: python

>>> import os
>>> os.environ["PYFLUENT_LAUNCH_CONTAINER"] = "1"
>>> import ansys.fluent.core as pyfluent
>>> from ansys.fluent.core import examples
>>> from ansys.fluent.core.utils.file_transfer_service import ContainerFileTransferStrategy
Expand Down
15 changes: 2 additions & 13 deletions doc/source/user_guide/session/launching_ansys_fluent.rst
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,6 @@ Use this method when:

.. code-block:: python

import os
os.environ["PYFLUENT_LAUNCH_CONTAINER"] = "1"

import ansys.fluent.core as pyfluent
from ansys.fluent.core.utils.networking import get_free_port

Expand Down Expand Up @@ -453,21 +450,13 @@ Pass ``use_docker_compose=True`` or ``use_podman_compose=True`` to use Docker Co

Example:

Set environment variables to select the container engine:

.. code:: python

>>> import os
>>> os.environ["PYFLUENT_LAUNCH_CONTAINER"] = "1"


Then launch:
Launch Fluent in container mode via PyFluent:

.. code:: python

>>> import ansys.fluent.core as pyfluent
>>> from ansys.fluent.core import examples
>>> solver_session = pyfluent.launch_fluent(use_docker_compose=True)
>>> solver_session = pyfluent.launch_fluent(start_container=True, use_docker_compose=True)
>>> case_file_name = examples.download_file("mixing_elbow.cas.h5", "pyfluent/mixing_elbow")
>>> solver_session.file.read(file_name=case_file_name, file_type="case")
>>> solver_session.exit()
Expand Down
2 changes: 1 addition & 1 deletion src/ansys/fluent/core/examples/downloads.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ def download_file(
save_path : str, optional
Path to download the specified file to.
return_without_path : bool, optional
When unspecified, defaults to False, unless the PYFLUENT_LAUNCH_CONTAINER=1 environment variable is specified,
When unspecified, defaults to False, unless the launch_fluent_container config is set to True,
in which case defaults to True.
Relevant when using Fluent Docker container images, as the full path for the imported file from
the host side is not necessarily going to be the same as the one for Fluent inside the container.
Expand Down
4 changes: 2 additions & 2 deletions src/ansys/fluent/core/launcher/launch_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"""Provides a module for enums used in the PyFluent."""

from enum import Enum
import os
import warnings

from ansys.fluent.core.exceptions import DisallowedValuesError
Expand Down Expand Up @@ -344,7 +345,6 @@ def _get_standalone_launch_fluent_version(argvals) -> FluentVersion | None:
FluentVersion, optional
Fluent version or ``None``
"""
from ansys.fluent.core import config

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

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

# 2. the latest ANSYS version from AWP_ROOT environment variables
Expand Down
3 changes: 1 addition & 2 deletions src/ansys/fluent/core/launcher/process_launch_string.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,6 @@ def get_fluent_exe_path(**launch_argvals) -> Path:
Path
Fluent executable path
"""
from ansys.fluent.core import config

def get_exe_path(fluent_root: Path) -> Path:
if launcher_utils.is_windows():
Expand All @@ -171,7 +170,7 @@ def get_exe_path(fluent_root: Path) -> Path:
return FluentVersion(product_version).get_fluent_exe_path()

# (DEV) "PYFLUENT_FLUENT_ROOT" environment variable
fluent_root = config.fluent_root
fluent_root = os.getenv("PYFLUENT_FLUENT_ROOT")
if fluent_root:
return get_exe_path(Path(fluent_root))

Expand Down
2 changes: 1 addition & 1 deletion src/ansys/fluent/core/launcher/slurm_launcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,7 @@ def _prepare(self):
launch_cmd += _build_journal_argument(
self._argvals["topy"], self._argvals["journal_file_names"]
)
launch_cmd += ' --setenv="FLUENT_ALLOW_REMOTE_GRPC_CONNECTION=1"'
launch_cmd += ' -setenv="FLUENT_ALLOW_REMOTE_GRPC_CONNECTION=1"'

logger.debug(f"Launching Fluent with command: {launch_cmd}")
proc = subprocess.Popen(launch_cmd, **kwargs)
Expand Down
5 changes: 0 additions & 5 deletions src/ansys/fluent/core/module_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,11 +300,6 @@ class Config:
lambda instance: instance._env.get("PYFLUENT_HIDE_LOG_SECRETS") == "1"
)

#: The Fluent root directory to be used for PyFluent, defaults to the value of ``PYFLUENT_FLUENT_ROOT`` environment variable.
fluent_root = _ConfigDescriptor["Config"](
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

lambda instance: instance._env.get("PYFLUENT_FLUENT_ROOT")
)

#: The remoting server address to be used in Fluent, defaults to the value of ``REMOTING_SERVER_ADDRESS`` environment variable.
remoting_server_address = _ConfigDescriptor["Config"](
lambda instance: instance._env.get("REMOTING_SERVER_ADDRESS")
Expand Down