Skip to content
Merged
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
10 changes: 8 additions & 2 deletions src/ansys/fluent/core/launcher/container_launcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
_process_invalid_args,
)
import ansys.fluent.core.launcher.watchdog as watchdog
from ansys.fluent.core.utils.file_transfer_service import RemoteFileHandler
from ansys.fluent.core.utils.file_transfer_service import PimFileTransferService

_THIS_DIR = os.path.dirname(__file__)
_OPTIONS_FILE = os.path.join(_THIS_DIR, "fluent_launcher_options.json")
Expand Down Expand Up @@ -51,6 +51,7 @@ def __init__(
topy: Optional[Union[str, list]] = None,
start_watchdog: Optional[bool] = None,
scheduler_options: Optional[dict] = None,
file_transfer_service: Optional[Any] = None,
):
"""Launch Fluent session in container mode.

Expand Down Expand Up @@ -136,6 +137,8 @@ def __init__(
which means an independent watchdog process is run to ensure
that any local GUI-less Fluent sessions started by PyFluent are properly closed (or killed if frozen)
when the current Python process ends.
file_transfer_service : optional
File transfer service. Uploads/downloads files to/from the server.

Returns
-------
Expand Down Expand Up @@ -168,6 +171,9 @@ def __init__(
setattr(self, arg_name, arg_values)
self.argvals = argvals
self.new_session = self.mode.value[0]
self.file_transfer_service = (
file_transfer_service if file_transfer_service else PimFileTransferService()
)

def __call__(self):
if self.mode == FluentMode.SOLVER_ICING:
Expand Down Expand Up @@ -205,7 +211,7 @@ def __call__(self):
launcher_args=self.argvals,
inside_container=True,
),
remote_file_handler=RemoteFileHandler(),
remote_file_handler=self.file_transfer_service,
)

if self.start_watchdog is None and self.cleanup_on_exit:
Expand Down
6 changes: 4 additions & 2 deletions src/ansys/fluent/core/launcher/launcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
from ansys.fluent.core.session_pure_meshing import PureMeshing
from ansys.fluent.core.session_solver import Solver
from ansys.fluent.core.session_solver_icing import SolverIcing
from ansys.fluent.core.utils.file_transfer_service import RemoteFileHandler

_THIS_DIR = os.path.dirname(__file__)
_OPTIONS_FILE = os.path.join(_THIS_DIR, "fluent_launcher_options.json")
Expand Down Expand Up @@ -101,6 +100,7 @@ def launch_fluent(
topy: Optional[Union[str, list]] = None,
start_watchdog: Optional[bool] = None,
scheduler_options: Optional[dict] = None,
file_transfer_service: Optional[Any] = None,
**kwargs,
) -> Union[Meshing, PureMeshing, Solver, SolverIcing, SlurmFuture, dict]:
"""Launch Fluent locally in server mode or connect to a running Fluent server
Expand Down Expand Up @@ -205,6 +205,8 @@ def launch_fluent(
"scheduler_account": "<account>"}``. The keys ``scheduler_headnode``,
``scheduler_queue`` and ``scheduler_account`` are optional and should be
specified in a similar manner to Fluent's scheduler options.
file_transfer_service : optional
File transfer service. Uploads/downloads files to/from the server.

Returns
-------
Expand Down Expand Up @@ -316,5 +318,5 @@ def connect_to_fluent(
watchdog.launch(os.getpid(), port, password, ip)

return new_session(
fluent_connection=fluent_connection, remote_file_handler=RemoteFileHandler()
fluent_connection=fluent_connection,
)
16 changes: 8 additions & 8 deletions src/ansys/fluent/core/launcher/launcher_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,7 @@
from ansys.fluent.core.session_pure_meshing import PureMeshing
from ansys.fluent.core.session_solver import Solver
from ansys.fluent.core.session_solver_icing import SolverIcing
from ansys.fluent.core.utils.file_transfer_service import (
PimFileTransferService,
RemoteFileHandler,
)
from ansys.fluent.core.utils.file_transfer_service import PimFileTransferService
from ansys.fluent.core.utils.fluent_version import FluentVersion
from ansys.fluent.core.utils.networking import find_remoting_ip
import ansys.platform.instancemanagement as pypim
Expand Down Expand Up @@ -555,6 +552,7 @@ def launch_remote_fluent(
mode: FluentMode = FluentMode.SOLVER,
dimensionality: Optional[str] = None,
launcher_args: Optional[Dict[str, Any]] = None,
file_transfer_service: Optional[Any] = None,
) -> Union[Meshing, PureMeshing, Solver, SolverIcing]:
"""Launch Fluent remotely using `PyPIM <https://pypim.docs.pyansys.com>`.

Expand Down Expand Up @@ -585,6 +583,8 @@ def launch_remote_fluent(
dimensionality : str, optional
Geometric dimensionality of the Fluent simulation. The default is ``None``,
in which case ``"3d"`` is used. Options are ``"3d"`` and ``"2d"``.
file_transfer_service : optional
File transfer service. Uploads/downloads files to/from the server.

Returns
-------
Expand Down Expand Up @@ -615,10 +615,10 @@ def launch_remote_fluent(
launcher_args=launcher_args,
)

remote_file_handler = RemoteFileHandler(
transfer_service=PimFileTransferService(
pim_instance=fluent_connection._remote_instance
)
remote_file_handler = (
file_transfer_service
if file_transfer_service
else PimFileTransferService(pim_instance=fluent_connection._remote_instance)
)

return session_cls(
Expand Down
8 changes: 8 additions & 0 deletions src/ansys/fluent/core/launcher/pim_launcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
_process_invalid_args,
launch_remote_fluent,
)
from ansys.fluent.core.utils.file_transfer_service import PimFileTransferService

_THIS_DIR = os.path.dirname(__file__)
_OPTIONS_FILE = os.path.join(_THIS_DIR, "fluent_launcher_options.json")
Expand Down Expand Up @@ -44,6 +45,7 @@ def __init__(
topy: Optional[Union[str, list]] = None,
start_watchdog: Optional[bool] = None,
scheduler_options: Optional[dict] = None,
file_transfer_service: Optional[Any] = None,
):
"""Launch Fluent session in `PIM<https://pypim.docs.pyansys.com/version/stable/>` mode.

Expand Down Expand Up @@ -129,6 +131,8 @@ def __init__(
which means an independent watchdog process is run to ensure
that any local GUI-less Fluent sessions started by PyFluent are properly closed (or killed if frozen)
when the current Python process ends.
file_transfer_service : optional
File transfer service. Uploads/downloads files to/from the server.

Returns
-------
Expand Down Expand Up @@ -173,6 +177,9 @@ def __init__(
"'start_watchdog' argument for 'launch_fluent' is currently not supported "
"when starting a remote Fluent PyPIM client."
)
self.file_transfer_service = (
file_transfer_service if file_transfer_service else PimFileTransferService()
)

def __call__(self):
logger.info(
Expand All @@ -191,4 +198,5 @@ def __call__(self):
mode=self.mode,
dimensionality=self.version,
launcher_args=self.argvals,
file_transfer_service=self.file_transfer_service,
)
10 changes: 8 additions & 2 deletions src/ansys/fluent/core/launcher/standalone_launcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
_raise_exception_g_gu_in_windows_os,
)
import ansys.fluent.core.launcher.watchdog as watchdog
from ansys.fluent.core.utils.file_transfer_service import RemoteFileHandler
from ansys.fluent.core.utils.file_transfer_service import PimFileTransferService

_THIS_DIR = os.path.dirname(__file__)
_OPTIONS_FILE = os.path.join(_THIS_DIR, "fluent_launcher_options.json")
Expand Down Expand Up @@ -57,6 +57,7 @@ def __init__(
topy: Optional[Union[str, list]] = None,
start_watchdog: Optional[bool] = None,
scheduler_options: Optional[dict] = None,
file_transfer_service: Optional[Any] = None,
):
"""Launch Fluent session in standalone mode.

Expand Down Expand Up @@ -142,6 +143,8 @@ def __init__(
which means an independent watchdog process is run to ensure
that any local GUI-less Fluent sessions started by PyFluent are properly closed (or killed if frozen)
when the current Python process ends.
file_transfer_service : optional
File transfer service. Uploads/downloads files to/from the server.

Returns
-------
Expand Down Expand Up @@ -174,6 +177,9 @@ def __init__(
setattr(self, arg_name, arg_values)
self.argvals = argvals
self.new_session = self.mode.value[0]
self.file_transfer_service = (
file_transfer_service if file_transfer_service else PimFileTransferService()
)

def __call__(self):
if self.lightweight_mode is None:
Expand Down Expand Up @@ -236,7 +242,7 @@ def __call__(self):

session = self.new_session.create_from_server_info_file(
server_info_file_name=server_info_file_name,
remote_file_handler=RemoteFileHandler(),
remote_file_handler=self.file_transfer_service,
cleanup_on_exit=self.cleanup_on_exit,
start_transcript=self.start_transcript,
launcher_args=self.argvals,
Expand Down
12 changes: 6 additions & 6 deletions src/ansys/fluent/core/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,9 +288,9 @@ def upload(self, file_name: str, remote_file_name: Optional[str] = None):
remote_file_name : str, optional
remote file name, by default None
"""
return PimFileTransferService(self.fluent_connection._remote_instance).upload(
file_name, remote_file_name
)
return PimFileTransferService(
self.fluent_connection._remote_instance
).upload_file(file_name, remote_file_name)

def download(self, file_name: str, local_file_name: Optional[str] = "."):
"""Download a file from the server supported by `PyPIM<https://pypim.docs.pyansys.com/version/stable/>`.
Expand All @@ -302,9 +302,9 @@ def download(self, file_name: str, local_file_name: Optional[str] = "."):
local_file_name : str, optional
local file path, by default current directory
"""
return PimFileTransferService(self.fluent_connection._remote_instance).download(
file_name, local_file_name
)
return PimFileTransferService(
self.fluent_connection._remote_instance
).download_file(file_name, local_file_name)

def __dir__(self):
returned_list = sorted(set(list(self.__dict__.keys()) + dir(type(self))))
Expand Down
Loading