Skip to content

Commit

Permalink
Add submission summary feature. (#488)
Browse files Browse the repository at this point in the history
* Add submission summary feature.

* Update changelog.

* Sort status counts by status code.
  • Loading branch information
bdice authored Apr 6, 2021
1 parent 3c2a1b0 commit 9990950
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 10 deletions.
1 change: 1 addition & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
+++++++
Expand Down
33 changes: 28 additions & 5 deletions flow/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand All @@ -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:
Expand All @@ -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(
Expand Down
10 changes: 5 additions & 5 deletions flow/templates/base_status.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -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 %}
Expand All @@ -53,6 +53,6 @@
{% endif %}
{% endfor %}
{% endfor %}
{{ status_legend }}
{% endif %}
{% endblock %}
{{ status_legend }}

0 comments on commit 9990950

Please sign in to comment.