Skip to content
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

refactor: gRPC FTS refactoring #2742

Closed
wants to merge 20 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/ansys/fluent/core/launcher/container_launcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,11 @@ class DockerLauncher:

def __init__(
self,
mode: FluentMode,
ui_mode: UIMode,
graphics_driver: Union[FluentWindowsGraphicsDriver, FluentLinuxGraphicsDriver],
mode: Optional[Union[FluentMode, str, None]] = None,
ui_mode: Union[UIMode, str, None] = None,
graphics_driver: Union[
FluentWindowsGraphicsDriver, FluentLinuxGraphicsDriver, str, None
] = None,
product_version: Optional[FluentVersion] = None,
version: Optional[str] = None,
precision: Optional[str] = None,
Expand Down
13 changes: 8 additions & 5 deletions src/ansys/fluent/core/launcher/fluent_container.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@
import tempfile
from typing import List, Optional, Union

import ansys.fluent.core as pyfluent
from ansys.fluent.core._version import fluent_release_version
from ansys.fluent.core.session import _parse_server_info_file
from ansys.fluent.core.utils.execution import timeout_loop
Expand Down Expand Up @@ -179,9 +178,7 @@ def configure_container_dict(
else:
logger.debug(f"container_dict before processing: {container_dict}")

if not host_mount_path:
host_mount_path = pyfluent.EXAMPLES_PATH
elif "volumes" in container_dict:
if "volumes" in container_dict:
logger.warning(
"'volumes' keyword specified in 'container_dict', but "
"it is going to be overwritten by specified 'host_mount_path'."
Expand All @@ -203,7 +200,13 @@ def configure_container_dict(
container_dict.pop("volumes")

if "volumes" not in container_dict:
container_dict.update(volumes=[f"{host_mount_path}:{container_mount_path}"])
container_dict.update(
volumes=(
[f"{host_mount_path}:{container_mount_path}"]
if host_mount_path
else [f"pyfluent_data:{container_mount_path}"]
)
)
else:
logger.debug(f"container_dict['volumes']: {container_dict['volumes']}")
if len(container_dict["volumes"]) != 1:
Expand Down
8 changes: 5 additions & 3 deletions src/ansys/fluent/core/launcher/pim_launcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,11 @@ class PIMLauncher:

def __init__(
self,
mode: FluentMode,
ui_mode: UIMode,
graphics_driver: Union[FluentWindowsGraphicsDriver, FluentLinuxGraphicsDriver],
mode: Optional[Union[FluentMode, str, None]] = None,
ui_mode: Union[UIMode, str, None] = None,
graphics_driver: Union[
FluentWindowsGraphicsDriver, FluentLinuxGraphicsDriver, str, None
] = None,
product_version: Optional[FluentVersion] = None,
version: Optional[str] = None,
precision: Optional[str] = None,
Expand Down
8 changes: 5 additions & 3 deletions src/ansys/fluent/core/launcher/standalone_launcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,11 @@ class StandaloneLauncher:

def __init__(
self,
mode: FluentMode,
ui_mode: UIMode,
graphics_driver: Union[FluentWindowsGraphicsDriver, FluentLinuxGraphicsDriver],
mode: Optional[Union[FluentMode, str, None]] = None,
ui_mode: Union[UIMode, str, None] = None,
graphics_driver: Union[
FluentWindowsGraphicsDriver, FluentLinuxGraphicsDriver, str, None
] = None,
product_version: Optional[FluentVersion] = None,
version: Optional[str] = None,
precision: Optional[str] = None,
Expand Down
17 changes: 12 additions & 5 deletions src/ansys/fluent/core/utils/file_transfer_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ def _get_files(
file_name: Union[str, pathlib.PurePath, list[Union[str, pathlib.PurePath]]],
path: str,
):
path = path if path else pyfluent.EXAMPLES_PATH
if isinstance(file_name, (str, pathlib.PurePath)):
file_name = pathlib.Path(file_name)
file_path_check = os.path.join(path, file_name.name)
Expand Down Expand Up @@ -175,17 +176,19 @@ def __init__(
self.container_mount_path = (
container_mount_path if container_mount_path else "/home/container/workdir/"
)
self.host_mount_path = (
host_mount_path if host_mount_path else pyfluent.EXAMPLES_PATH
)
self.host_mount_path = host_mount_path
try:
self.host_port = port if port else random.randint(5000, 6000)
self.ports = {"50000/tcp": self.host_port}
self.container = self.docker_client.containers.run(
image=f"{self.image_name}:{self.image_tag}",
ports=self.ports,
detach=True,
volumes=[f"{self.host_mount_path}:{self.container_mount_path}"],
volumes=(
[f"{self.host_mount_path}:{self.container_mount_path}"]
if self.host_mount_path
else [f"pyfluent_data:{self.container_mount_path}"]
),
)
except docker.errors.DockerException:
self.host_port = port if port else random.randint(6000, 7000)
Expand All @@ -194,7 +197,11 @@ def __init__(
image=f"{self.image_name}:{self.image_tag}",
ports=self.ports,
detach=True,
volumes=[f"{self.host_mount_path}:{self.container_mount_path}"],
volumes=(
[f"{self.host_mount_path}:{self.container_mount_path}"]
if self.host_mount_path
else [f"pyfluent_data:{self.container_mount_path}"]
),
)
self.client = ft.Client.from_server_address(f"localhost:{self.host_port}")

Expand Down