From 88fc644f9702711e949648b92df22b83da760e4a Mon Sep 17 00:00:00 2001 From: Mainak Kundu Date: Fri, 16 May 2025 15:34:37 -0400 Subject: [PATCH 1/3] chore: Add a way to extract Fluent launch command and subprocess arguments from StandaloneLauncher --- src/ansys/fluent/core/launcher/launcher.py | 2 -- src/ansys/fluent/core/launcher/slurm_launcher.py | 1 + .../fluent/core/launcher/standalone_launcher.py | 14 +++++++++++++- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/ansys/fluent/core/launcher/launcher.py b/src/ansys/fluent/core/launcher/launcher.py index 723054192eaa..70932c1c789b 100644 --- a/src/ansys/fluent/core/launcher/launcher.py +++ b/src/ansys/fluent/core/launcher/launcher.py @@ -312,8 +312,6 @@ def launch_fluent( The allocated machines and core counts are queried from the scheduler environment and passed to Fluent. """ - if env is None: - env = {} def _mode_to_launcher_type(fluent_launch_mode: LaunchMode): launcher_mode_type = { diff --git a/src/ansys/fluent/core/launcher/slurm_launcher.py b/src/ansys/fluent/core/launcher/slurm_launcher.py index ca12e30784a6..84b7f09916f7 100644 --- a/src/ansys/fluent/core/launcher/slurm_launcher.py +++ b/src/ansys/fluent/core/launcher/slurm_launcher.py @@ -416,6 +416,7 @@ def __init__( """ if not _SlurmWrapper.is_available(): raise RuntimeError("Slurm is not available.") + env = env or {} locals_ = locals().copy() argvals = { arg: locals_.get(arg) diff --git a/src/ansys/fluent/core/launcher/standalone_launcher.py b/src/ansys/fluent/core/launcher/standalone_launcher.py index 8bc4bc392bbc..044b47751001 100644 --- a/src/ansys/fluent/core/launcher/standalone_launcher.py +++ b/src/ansys/fluent/core/launcher/standalone_launcher.py @@ -184,7 +184,7 @@ def __init__( In job scheduler environments (e.g., SLURM, LSF, PBS), resources and compute nodes are allocated, and core counts are queried from these environments before being passed to Fluent. """ - import ansys.fluent.core as pyfluent + env = env or {} locals_ = locals().copy() argvals = { @@ -234,6 +234,8 @@ def __init__( ) if is_windows(): + import ansys.fluent.core as pyfluent + if pyfluent.LAUNCH_FLUENT_STDOUT or pyfluent.LAUNCH_FLUENT_STDERR: self._launch_cmd = self._launch_string else: @@ -246,6 +248,16 @@ def __init__( else: self._launch_cmd = self._launch_string + @property + def command(self) -> str: + """Return the command for launching Fluent.""" + return self._launch_string + + @property + def subprocess_keywords(self) -> Dict[str, Any]: + """Return the keyword arguments for launching Fluent via Python subprocess.""" + return self._kwargs + def __call__(self): if self.argvals["dry_run"]: print(f"Fluent launch string: {self._launch_string}") From 5bac246168b59b83ca3d22078317dc339e224016 Mon Sep 17 00:00:00 2001 From: pyansys-ci-bot <92810346+pyansys-ci-bot@users.noreply.github.com> Date: Fri, 16 May 2025 19:36:52 +0000 Subject: [PATCH 2/3] chore: adding changelog file 4028.maintenance.md [dependabot-skip] --- doc/changelog.d/4028.maintenance.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 doc/changelog.d/4028.maintenance.md diff --git a/doc/changelog.d/4028.maintenance.md b/doc/changelog.d/4028.maintenance.md new file mode 100644 index 000000000000..fbf86421c912 --- /dev/null +++ b/doc/changelog.d/4028.maintenance.md @@ -0,0 +1 @@ +Add a way to extract Fluent launch command and subprocess arguments from StandaloneLauncher \ No newline at end of file From 9356a2d754b642d5dd3992a34e009f8a777fae2d Mon Sep 17 00:00:00 2001 From: Mainak Kundu Date: Fri, 16 May 2025 15:41:32 -0400 Subject: [PATCH 3/3] chore: Add a way to extract Fluent launch command and subprocess arguments from StandaloneLauncher --- src/ansys/fluent/core/launcher/standalone_launcher.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ansys/fluent/core/launcher/standalone_launcher.py b/src/ansys/fluent/core/launcher/standalone_launcher.py index 044b47751001..abc7e16e59ac 100644 --- a/src/ansys/fluent/core/launcher/standalone_launcher.py +++ b/src/ansys/fluent/core/launcher/standalone_launcher.py @@ -40,7 +40,7 @@ import os from pathlib import Path import subprocess -from typing import Any, Dict +from typing import Any from ansys.fluent.core.launcher.error_handler import ( LaunchFluentError, @@ -91,7 +91,7 @@ def __init__( journal_file_names: None | str | list[str] = None, start_timeout: int = 60, additional_arguments: str = "", - env: Dict[str, Any] | None = None, + env: dict[str, Any] | None = None, cleanup_on_exit: bool = True, dry_run: bool = False, start_transcript: bool = True, @@ -254,7 +254,7 @@ def command(self) -> str: return self._launch_string @property - def subprocess_keywords(self) -> Dict[str, Any]: + def subprocess_keywords(self) -> dict[str, Any]: """Return the keyword arguments for launching Fluent via Python subprocess.""" return self._kwargs