From 2a4e67ac8572bbf20aadd39fad736fabb2c4f4a7 Mon Sep 17 00:00:00 2001 From: Marnik Bercx Date: Fri, 15 Dec 2023 22:45:45 +0100 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Print=20a=20table=20with=20the=20st?= =?UTF-8?q?atus=20when=20submitting?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When using the `BaseSubmissionController.submit_new_batch()` method with `verbose == True`, print a table with an overview of completed, active, ... runs. --- aiida_submission_controller/base.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/aiida_submission_controller/base.py b/aiida_submission_controller/base.py index 922d12e..d63e3e6 100644 --- a/aiida_submission_controller/base.py +++ b/aiida_submission_controller/base.py @@ -7,6 +7,9 @@ from aiida import engine, orm from aiida.common import NotExistent from pydantic import BaseModel, validator +from rich import print +from rich.console import Console +from rich.table import Table CMDLINE_LOGGER = logging.getLogger("verdi") @@ -171,6 +174,32 @@ def submit_new_batch(self, dry_run=False, sort=True, verbose=False): if dry_run: return {key: None for key in to_submit} + if verbose: + table = Table(title="Status") + + table.add_column("Total", justify="left", style="cyan", no_wrap=True) + table.add_column("Finished", justify="left", style="cyan", no_wrap=True) + table.add_column("Left to run", justify="left", style="cyan", no_wrap=True) + table.add_column("Max active", justify="left", style="cyan", no_wrap=True) + table.add_column("Active", justify="left", style="cyan", no_wrap=True) + table.add_column("Available", justify="left", style="cyan", no_wrap=True) + + table.add_row( + str(self.parent_group.count()), + str(self.num_already_run), + str(self.num_to_run), + str(self.max_concurrent), + str(self.num_active_slots), + str(self.num_available_slots), + ) + console = Console() + console.print(table) + + if len(to_submit) == 0: + print("[bold blue]Info:[/] 😴 Nothing to submit.") + else: + print(f"[bold blue]Info:[/] 🚀 Submitting {len(to_submit)} new workchains!") + submitted = {} for workchain_extras in to_submit: try: