From 9dc77ffebc5de4aaa5c9de883947e039cfaecd49 Mon Sep 17 00:00:00 2001 From: Harshal Pohekar <106588300+hpohekar@users.noreply.github.com> Date: Fri, 25 Oct 2024 19:57:59 +0530 Subject: [PATCH] feat: Remove alive-progress dependency (#3424) * feat: Manual progress bar * feat: remove alive-progress * feat: print file name only * feat: refactor * feat: remove progress bar * feat: update logger name * feat: update logger name * feat: update logger message * feat: update logger * feat: use print --- pyproject.toml | 1 - .../core/utils/file_transfer_service.py | 62 ++++++++----------- 2 files changed, 26 insertions(+), 37 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index bccf2213581..2660bd06e5b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -44,7 +44,6 @@ ansys-api-fluent = "^0.3.28" ansys-platform-instancemanagement = "~=1.0" ansys-tools-filetransfer = ">=0.1,<0.3" ansys-units = "^0.3.2" -alive-progress = ">=3.1.5" beartype = ">=0.17" docker = ">=7.1.0" grpcio = "^1.30.0" diff --git a/src/ansys/fluent/core/utils/file_transfer_service.py b/src/ansys/fluent/core/utils/file_transfer_service.py index 5ea4290da0f..bd02b5632c2 100644 --- a/src/ansys/fluent/core/utils/file_transfer_service.py +++ b/src/ansys/fluent/core/utils/file_transfer_service.py @@ -1,6 +1,5 @@ """Provides a module for file transfer service.""" -import logging import os import pathlib import random @@ -14,9 +13,6 @@ from ansys.fluent.core.warnings import PyFluentUserWarning import ansys.platform.instancemanagement as pypim -logger = logging.getLogger("pyfluent.file_transfer_service") - - # Host path which is mounted to the file-transfer-service container MOUNT_SOURCE = platformdirs.user_data_dir( appname="ansys_fluent_core", appauthor="Ansys" @@ -482,23 +478,20 @@ def upload(self, file_name: list[str] | str, remote_file_name: str | None = None """ files = [file_name] if isinstance(file_name, str) else file_name if self.is_configured(): - from alive_progress import alive_bar - - with alive_bar(len(files), title="Uploading...") as bar: - for file in files: - if os.path.isfile(file): - if not self.file_service.file_exist(os.path.basename(file)): - self.upload_file( - file_name=file, remote_file_name=remote_file_name - ) - bar() - else: - warnings.warn( - f"\n{file} with the same name exists at the remote location.\n", - PyFluentUserWarning, - ) - elif not self.file_service.file_exist(os.path.basename(file)): - raise FileNotFoundError(f"{file} does not exist.") + for file in files: + if os.path.isfile(file): + if not self.file_service.file_exist(os.path.basename(file)): + self.upload_file( + file_name=file, remote_file_name=remote_file_name + ) + print(f"\n{os.path.basename(file_name)} uploaded.\n") + else: + warnings.warn( + f"\n{file} with the same name exists at the remote location.\n", + PyFluentUserWarning, + ) + elif not self.file_service.file_exist(os.path.basename(file)): + raise FileNotFoundError(f"{file} does not exist.") def download_file(self, file_name: str, local_directory: str | None = None): """Download a file from the server supported by `PyPIM`. @@ -537,21 +530,18 @@ def download(self, file_name: list[str] | str, local_directory: str | None = "." """ files = [file_name] if isinstance(file_name, str) else file_name if self.is_configured(): - from alive_progress import alive_bar - - with alive_bar(len(files), title="Downloading...") as bar: - for file in files: - if os.path.isfile(file): - warnings.warn( - f"\nFile already exists. File path:\n{file}\n", - PyFluentUserWarning, - ) - else: - self.download_file( - file_name=os.path.basename(file), - local_directory=local_directory, - ) - bar() + for file in files: + if os.path.isfile(file): + warnings.warn( + f"\nFile already exists. File path:\n{file}\n", + PyFluentUserWarning, + ) + else: + self.download_file( + file_name=os.path.basename(file), + local_directory=local_directory, + ) + print(f"\n{os.path.basename(file_name)} downloaded.\n") def __call__(self, pim_instance: Any | None = None): self.pim_instance = pim_instance