Skip to content

Commit

Permalink
refactor: fluent_container.py refactoring (#2823)
Browse files Browse the repository at this point in the history
* refactor: fluent_container.py refactoring

* update docstring

* update docstring 1

* update docstring 2

* update condition
  • Loading branch information
hpohekar authored May 15, 2024
1 parent 9a1e184 commit 183b5c2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
6 changes: 5 additions & 1 deletion src/ansys/fluent/core/launcher/container_launcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,11 @@ def __call__(self):
if self.product_version:
self.container_dict["image_tag"] = f"v{self.product_version.value}"
if self.dry_run:
config_dict, *_ = configure_container_dict(args, **self.container_dict)
config_dict, *_ = configure_container_dict(
args,
file_transfer_service=self.file_transfer_service,
**self.container_dict,
)
from pprint import pprint

print("\nDocker container run configuration:\n")
Expand Down
7 changes: 5 additions & 2 deletions src/ansys/fluent/core/launcher/fluent_container.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
import os
from pathlib import Path, PurePosixPath
import tempfile
from typing import List, Optional, Union
from typing import Any, List, Optional, Union

import ansys.fluent.core as pyfluent
from ansys.fluent.core._version import fluent_release_version
Expand Down Expand Up @@ -105,6 +105,7 @@ def configure_container_dict(
fluent_image: Optional[str] = None,
image_name: Optional[str] = None,
image_tag: Optional[str] = None,
file_transfer_service: Optional[Any] = None,
**container_dict,
) -> (dict, int, int, Path, bool):
"""Parses the parameters listed below, and sets up the container configuration file.
Expand Down Expand Up @@ -134,6 +135,8 @@ def configure_container_dict(
Ignored if ``fluent_image`` has been specified.
image_tag : str, optional
Ignored if ``fluent_image`` has been specified.
file_transfer_service : optional
Supports file upload and download.
**container_dict
Additional keyword arguments can be specified, they will be treated as Docker container run options
to be passed directly to the Docker run execution. See examples below and `Docker run`_ documentation.
Expand Down Expand Up @@ -180,7 +183,7 @@ def configure_container_dict(
logger.debug(f"container_dict before processing: {container_dict}")

if not host_mount_path:
if pyfluent.USE_FILE_TRANSFER_SERVICE:
if file_transfer_service:
host_mount_path = pyfluent.USER_DATA_PATH
else:
host_mount_path = pyfluent.EXAMPLES_PATH
Expand Down

0 comments on commit 183b5c2

Please sign in to comment.