Skip to content

chore: Add a way to extract Fluent launch command and subprocess arguments from StandaloneLauncher #4028

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 3 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/4028.maintenance.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add a way to extract Fluent launch command and subprocess arguments from StandaloneLauncher
2 changes: 0 additions & 2 deletions src/ansys/fluent/core/launcher/launcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
1 change: 1 addition & 0 deletions src/ansys/fluent/core/launcher/slurm_launcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
18 changes: 15 additions & 3 deletions src/ansys/fluent/core/launcher/standalone_launcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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 = {
Expand Down Expand Up @@ -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:
Expand All @@ -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

Comment on lines +251 to +260
Copy link
Collaborator

Choose a reason for hiding this comment

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

Where are we going to use this information ? Does it require for the standalone mode only ?

Copy link
Collaborator

Choose a reason for hiding this comment

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

yes, a similar question in the same line, why not for container launcher as well?

def __call__(self):
if self.argvals["dry_run"]:
print(f"Fluent launch string: {self._launch_string}")
Expand Down
Loading