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
Changes from 8 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
44 changes: 15 additions & 29 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,17 +178,21 @@ def configure_container_dict(
else:
logger.debug(f"container_dict before processing: {container_dict}")

if host_mount_path and "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'."
)
container_dict.pop("volumes")

if host_mount_path and not os.path.exists(host_mount_path):
Path(host_mount_path).mkdir(parents=True, exist_ok=True)
if not os.path.exists(host_mount_path):
os.makedirs(host_mount_path)

if container_mount_path and "volumes" in container_dict:
if not container_mount_path:
container_mount_path = os.getenv(
"PYFLUENT_CONTAINER_MOUNT_PATH", DEFAULT_CONTAINER_MOUNT_PATH
)
elif "volumes" in container_dict:
logger.warning(
"'volumes' keyword specified in 'container_dict', but "
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
"'volumes' keyword specified in 'container_dict', but "
"'volumes' keyword is specified in 'container_dict', but "

The string needs to have a verb.

"it is going to be overwritten by specified 'container_mount_path'."
Expand All @@ -200,8 +203,8 @@ def configure_container_dict(
container_dict.update(
volumes=(
[f"{host_mount_path}:{container_mount_path}"]
if (host_mount_path and container_mount_path)
else ["pyfluent_data:/mnt/pyfluent"]
if host_mount_path
else [f"pyfluent_data:{container_mount_path}"]
)
)
else:
Expand Down Expand Up @@ -253,9 +256,7 @@ def configure_container_dict(

if "working_dir" not in container_dict:
container_dict.update(
working_dir=(
container_mount_path if container_mount_path else "/mnt/pyfluent"
),
working_dir=container_mount_path,
)

if "command" in container_dict:
Expand All @@ -272,23 +273,16 @@ def configure_container_dict(

if container_server_info_file:
container_server_info_file = (
PurePosixPath(
container_mount_path if container_mount_path else "/mnt/pyfluent"
)
PurePosixPath(container_mount_path)
/ PurePosixPath(container_server_info_file).name
)
else:
fd, sifile = tempfile.mkstemp(
suffix=".txt",
prefix="serverinfo-",
dir=host_mount_path if host_mount_path else pyfluent.USER_DATA_PATH,
suffix=".txt", prefix="serverinfo-", dir=host_mount_path
)
os.close(fd)
container_server_info_file = (
PurePosixPath(
container_mount_path if container_mount_path else "/mnt/pyfluent"
)
/ Path(sifile).name
PurePosixPath(container_mount_path) / Path(sifile).name
)

if not fluent_image:
Expand Down Expand Up @@ -318,15 +312,7 @@ def configure_container_dict(
if k not in container_dict:
container_dict[k] = v

Path(pyfluent.USER_DATA_PATH).mkdir(parents=True, exist_ok=True)

server_info_file_path = (
host_mount_path if host_mount_path else pyfluent.USER_DATA_PATH
)

host_server_info_file = (
Path(server_info_file_path) / container_server_info_file.name
)
host_server_info_file = Path(host_mount_path) / container_server_info_file.name

return (
container_dict,
Expand Down