Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invocations #199

Merged
merged 1 commit into from
May 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion abm/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

# These imports are required because we need Python to be load them to the
# symbol table so the parse_menu method can find them in globals()
from lib import job, dataset, workflow, history, library, folder, benchmark, helm, kubectl, config, experiment, users, cloudlaunch
from lib import job, dataset, workflow, history, library, folder, benchmark, helm, kubectl, config, experiment, users, cloudlaunch, invocation

log = logging.getLogger('abm')
handler = logging.StreamHandler()
Expand Down
38 changes: 38 additions & 0 deletions abm/lib/invocation.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
from common import Context, connect, summarize_metrics, print_json

def doList(context: Context, args: list):
wid = None
hid = None
while len(args) > 0:
arg = args.pop(0)
if args in ['-h', '--history']:
hid = args.pop(0)
elif arg in ['-w', '--workflow']:
wid = args.pop(0)
else:
print(f'Invalid parameter: {arg}')
return
gi = connect(context)
invocations = gi.invocations.get_invocations(workflow_id=wid, history_id=hid)
print('ID\tState\tWorkflow\tHistory')
for invocation in invocations:
id = invocation['id']
state = invocation['state']
workflow = invocation['workflow_id']
history = invocation['history_id']
print(f'{id}\t{state}\t{workflow}\t{history}')


def summarize(context: Context, args: list):
if len(args) == 0:
print("ERROR: Provide one or more invocation ID values.")
return
gi = connect(context)
id = args[0]
all_jobs = []
jobs = gi.jobs.get_jobs(invocation_id=id)
for job in jobs:
job['invocation_id'] = id
job['workflow_id'] = ''
all_jobs.append(job)
summarize_metrics(gi, all_jobs)
11 changes: 11 additions & 0 deletions abm/lib/menu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,17 @@
help: playground code
handler: experiment.test
params: [VARIES]
- name: [invocation, inv, invocations]
help: get information about job and workflow invocations
menu:
- name: [list, ls]
help: list all invocations.
handler: invocation.doList
params: "[-w|--workflow ID] [-h|--history ID]"
- name: [summarize]
help: generate a CSV of job metrics for an invocation
params: ID
handler: invocation.summarize
- name: [helm]
help: execute a helm command
menu:
Expand Down
11 changes: 9 additions & 2 deletions abm/lib/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,15 @@ def invocation(context:Context, args:list):
# return
gi = connect(context)
# result = gi.workflows.show_invocation(workflow_id, invocation_id)
result = gi.invocations.get_invocations(workflow_id=workflow_id, view='element', step_details=True)
print(json.dumps(result, indent=4))
invocations = gi.invocations.get_invocations(workflow_id=workflow_id, view='element', step_details=True)
# print(json.dumps(result, indent=4))
print('ID\tState\tWorkflow\tHistory')
for invocation in invocations:
id = invocation['id']
state = invocation['state']
workflow = invocation['workflow_id']
history = invocation['history_id']
print(f'{id}\t{state}\t{workflow}\t{history}')


def find(context: Context, args: list):
Expand Down