From 99909506fa598da5e13768495779c717efb3b5ab Mon Sep 17 00:00:00 2001 From: Bradley Dice Date: Tue, 6 Apr 2021 09:48:51 -0500 Subject: [PATCH] Add submission summary feature. (#488) * Add submission summary feature. * Update changelog. * Sort status counts by status code. --- changelog.txt | 1 + flow/project.py | 33 +++++++++++++++++++++++++++----- flow/templates/base_status.jinja | 10 +++++----- 3 files changed, 34 insertions(+), 10 deletions(-) diff --git a/changelog.txt b/changelog.txt index e28f26346..4b78e7cf5 100644 --- a/changelog.txt +++ b/changelog.txt @@ -16,6 +16,7 @@ Added - Documentation for all directives (#480). - Defined validators for the ``fork`` directive (#480). +- Submission summary now appears in ``FlowProject`` status output, showing the number of queued, running, unknown statuses. (#472, #488). Changed +++++++ diff --git a/flow/project.py b/flow/project.py index 10d9fce2c..b4c00e6ee 100644 --- a/flow/project.py +++ b/flow/project.py @@ -2711,7 +2711,6 @@ def dotted_get(mapping, key): if detailed: # get detailed view info - status_legend = " ".join(f"[{v}]:{k}" for k, v in self.ALIASES.items()) if compact: num_operations = len(self._operations) @@ -2738,6 +2737,7 @@ def dotted_get(mapping, key): f"[{v}]:{k}" for k, v in OPERATION_STATUS_SYMBOLS.items() ) + status_legend = " ".join(f"[{v}]:{k}" for k, v in self.ALIASES.items()) context["jobs"] = list(statuses.values()) context["overview"] = overview context["detailed"] = detailed @@ -2746,12 +2746,12 @@ def dotted_get(mapping, key): context["compact"] = compact context["pretty"] = pretty context["unroll"] = unroll + context["status_legend"] = status_legend if overview: context["progress_sorted"] = progress_sorted if detailed: context["alias_bool"] = {True: "Y", False: "N"} context["scheduler_status_code"] = _FMT_SCHEDULER_STATUS - context["status_legend"] = status_legend if compact: context["extra_num_operations"] = max(num_operations - 1, 0) if not unroll: @@ -2771,11 +2771,34 @@ def _add_placeholder_operation(job): _add_placeholder_operation(job) op_counter = Counter() + op_submission_status_counter = defaultdict(Counter) for job in context["jobs"]: for group_name, group_status in job["groups"].items(): - if group_name != "" and group_status["eligible"]: - op_counter[group_name] += 1 - context["op_counter"] = op_counter.most_common(eligible_jobs_max_lines) + if group_name != "": + if group_status["eligible"]: + op_counter[group_name] += 1 + op_submission_status_counter[group_name][ + group_status["scheduler_status"] + ] += 1 + + def _op_submission_summary(counter): + """Generate string of statuses and counts, sorted by status.""" + return ", ".join( + f"[{_FMT_SCHEDULER_STATUS[status]}]: {count}" + for status, count in sorted(counter.items()) + ) + + op_counter_status = [ + [ + group_name, + group_count, + _op_submission_summary(op_submission_status_counter[group_name]), + ] + for group_name, group_count in op_counter.most_common( + eligible_jobs_max_lines + ) + ] + context["op_counter"] = op_counter_status num_omitted_operations = len(op_counter) - len(context["op_counter"]) if num_omitted_operations > 0: context["op_counter"].append( diff --git a/flow/templates/base_status.jinja b/flow/templates/base_status.jinja index f8c948ecf..e6ba26ed9 100644 --- a/flow/templates/base_status.jinja +++ b/flow/templates/base_status.jinja @@ -27,10 +27,10 @@ {% endblock%} {% block operation_summary %} -| operation | number of eligible jobs | -| --------- | ----------------------- | -{% for op, n_jobs in op_counter %} -| {{ op }} | {{ n_jobs }} | +| operation | number of eligible jobs | submission status | +| --------- | ----------------------- | ----------------- | +{% for op, n_jobs, op_submission_status in op_counter %} +| {{ op }} | {{ n_jobs }} | {{ op_submission_status }} | {% endfor %} {% endblock %} {% endif %} @@ -53,6 +53,6 @@ {% endif %} {% endfor %} {% endfor %} -{{ status_legend }} {% endif %} {% endblock %} +{{ status_legend }}