From 183b5c216b0c42030e55b7b25dad1e0768d6f914 Mon Sep 17 00:00:00 2001 From: Harshal Pohekar <106588300+hpohekar@users.noreply.github.com> Date: Wed, 15 May 2024 19:18:27 +0530 Subject: [PATCH] refactor: fluent_container.py refactoring (#2823) * refactor: fluent_container.py refactoring * update docstring * update docstring 1 * update docstring 2 * update condition --- src/ansys/fluent/core/launcher/container_launcher.py | 6 +++++- src/ansys/fluent/core/launcher/fluent_container.py | 7 +++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/ansys/fluent/core/launcher/container_launcher.py b/src/ansys/fluent/core/launcher/container_launcher.py index ce07f896a87..119317c2483 100644 --- a/src/ansys/fluent/core/launcher/container_launcher.py +++ b/src/ansys/fluent/core/launcher/container_launcher.py @@ -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") diff --git a/src/ansys/fluent/core/launcher/fluent_container.py b/src/ansys/fluent/core/launcher/fluent_container.py index 38839b146cb..26fddea6c82 100644 --- a/src/ansys/fluent/core/launcher/fluent_container.py +++ b/src/ansys/fluent/core/launcher/fluent_container.py @@ -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 @@ -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. @@ -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. @@ -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