From bdfdbce2852b7f28da53d2bf6ac4368c68d5f13a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anders=20Fredrik=20Ki=C3=A6r?= <31612826+anders-kiaer@users.noreply.github.com> Date: Thu, 26 Sep 2019 17:02:25 +0200 Subject: [PATCH] Add progress information when making portable webviz (#102) --- webviz_config/_build_webviz.py | 4 ++-- webviz_config/webviz_assets.py | 6 ++++-- webviz_config/webviz_store.py | 11 ++++++++++- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/webviz_config/_build_webviz.py b/webviz_config/_build_webviz.py index 50ff21a1..cd15d119 100644 --- a/webviz_config/_build_webviz.py +++ b/webviz_config/_build_webviz.py @@ -40,8 +40,8 @@ def build_webviz(args): if args.portable: print( "\033[1m\033[94m" - "Extracting, processing and saving requested data to build " - "folder such that the webviz instance is portable." + "Saving requested data to build folder " + "such that the webviz instance is portable." "\033[0m" ) diff --git a/webviz_config/webviz_assets.py b/webviz_config/webviz_assets.py index 807395be..dc57e81e 100644 --- a/webviz_config/webviz_assets.py +++ b/webviz_config/webviz_assets.py @@ -73,7 +73,7 @@ def make_portable(self, asset_folder): """Copy over all added assets to the given folder (asset_folder). """ - for assigned_id, filename in self._assets.items(): + for counter, (assigned_id, filename) in enumerate(self._assets.items()): new_filename = os.path.join(asset_folder, assigned_id) print( @@ -84,7 +84,9 @@ def make_portable(self, asset_folder): shutil.copyfile(filename, os.path.join(asset_folder, assigned_id)) - print(" \033[92m\033[1m[\u2713] Copied\033[0m") + print( + f" \033[92m\033[1m[\u2713] Copied ({counter + 1}/{len(self._assets)})\033[0m" + ) def _generate_id(self, filename): """From the filename, create a safe resource id not already present diff --git a/webviz_config/webviz_store.py b/webviz_config/webviz_store.py index 64c0c934..70fe5dc6 100644 --- a/webviz_config/webviz_store.py +++ b/webviz_config/webviz_store.py @@ -145,6 +145,12 @@ def get_stored_data(self, func, *args, **kwargs): ) def build_store(self): + + total_calls = sum( + len(calls) for calls in self.storage_function_argvalues.values() + ) + counter = 0 + for func in self.storage_functions: for argtuples in self.storage_function_argvalues[func]: kwargs = dict(argtuples) @@ -167,7 +173,10 @@ def build_store(self): else: raise ValueError(f"Unknown return type {type(output)}") - print(" \033[92m\033[1m[\u2713] Saved\033[0m") + counter += 1 + print( + f" \033[92m\033[1m[\u2713] Saved ({counter}/{total_calls})\033[0m" + ) def webvizstore(func):