From dc993dfdf9a6b40f998f6e27845e8e27777ec59f Mon Sep 17 00:00:00 2001 From: Keith Suderman Date: Thu, 4 May 2023 15:52:25 -0400 Subject: [PATCH] Summarize multiple histories at once. --- abm/lib/common.py | 6 ++++-- abm/lib/history.py | 28 ++++++++++++++++++++-------- 2 files changed, 24 insertions(+), 10 deletions(-) diff --git a/abm/lib/common.py b/abm/lib/common.py index f8e83bc..f83fee1 100644 --- a/abm/lib/common.py +++ b/abm/lib/common.py @@ -189,7 +189,8 @@ def find_executable(name): def summarize_metrics(gi, jobs: list): header= [ "id", - "history", + "history_id", + "history_name", "state", "tool_id", "invocation_id", @@ -220,7 +221,8 @@ def summarize_metrics(gi, jobs: list): row = [] metrics = metrics_to_dict(job_metrics, header) metrics['id'] = job['id'] - metrics['history'] = job['history_id'] + metrics['history_id'] = job['history_id'] + metrics['history_name'] = job['history_name'] metrics['state'] = job['state'] metrics['tool_id'] = job['tool_id'] metrics['invocation_id'] = job['invocation_id'] diff --git a/abm/lib/history.py b/abm/lib/history.py index 3ba6942..f79fd28 100644 --- a/abm/lib/history.py +++ b/abm/lib/history.py @@ -312,17 +312,29 @@ def summarize(context: Context, args: list): print("ERROR: Provide one or more history ID values.") return gi = connect(context) - hid = args[0] all_jobs = [] - invocations = gi.invocations.get_invocations(history_id=hid) - for invocation in invocations: - id = invocation['id'] - jobs = gi.jobs.get_jobs(history_id=hid, invocation_id=id) + while len(args) > 0: + hid = args.pop(0) + history = gi.histories.show_history(history_id=hid) + jobs = gi.jobs.get_jobs(history_id=hid) for job in jobs: - job['invocation_id'] = id + job['invocation_id'] = '' job['history_id'] = hid - if 'workflow_id' in invocation: - job['workflow_id'] = invocation['workflow_id'] + job['history_name'] = history['name'] + job['workflow_id'] = '' + # if 'workflow_id' in invocation: + # job['workflow_id'] = invocation['workflow_id'] all_jobs.append(job) + # invocations = gi.invocations.get_invocations(history_id=hid) + # for invocation in invocations: + # id = invocation['id'] + # #jobs = gi.jobs.get_jobs(history_id=hid, invocation_id=id) + # jobs = gi.jobs.get_jobs(history_id=hid) + # for job in jobs: + # job['invocation_id'] = id + # job['history_id'] = hid + # if 'workflow_id' in invocation: + # job['workflow_id'] = invocation['workflow_id'] + # all_jobs.append(job) # summarize_metrics(gi, gi.jobs.get_jobs(history_id=args[0])) summarize_metrics(gi, all_jobs)