Skip to content

Commit

Permalink
Merge pull request #19279 from jmchilton/metrics_usability
Browse files Browse the repository at this point in the history
[24.2] Fix invocation metrics usability by providing job context.
  • Loading branch information
jmchilton authored Dec 8, 2024
2 parents cb62d4c + d1c0154 commit f5f2efe
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 7 deletions.
2 changes: 2 additions & 0 deletions client/src/api/schema/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18470,6 +18470,8 @@ export interface components {
* }
*/
WorkflowJobMetric: {
/** Job Id */
job_id: string;
/**
* Name
* @description The name of the metric variable.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { computed, ref, watch } from "vue";
import { type ComputedRef } from "vue";
import { type components, GalaxyApi } from "@/api";
import { getAppRoot } from "@/onload/loadConfig";
import { errorMessageAsString } from "@/utils/simple-error";
const VegaWrapper = () => import("./VegaWrapper.vue");
Expand Down Expand Up @@ -72,6 +73,8 @@ function metricToSpecData(
return {
y,
x: itemToX(item),
job_id: item.job_id,
tooltip: "click to view job",
};
});
return {
Expand Down Expand Up @@ -109,6 +112,10 @@ function itemToSpec(item: boxplotData) {
calculate: "random() - 0.5",
as: "random_jitter",
},
{
calculate: "'" + getAppRoot() + "jobs/' + datum.job_id + '/view'",
as: "url",
},
],
layer: [
{
Expand Down Expand Up @@ -141,6 +148,8 @@ function itemToSpec(item: boxplotData) {
scale: { zero: false },
title: item.y_title,
},
tooltip: { field: "tooltip", type: "nominal" },
href: { field: "url", type: "nominal" },
},
width: "container",
},
Expand Down
4 changes: 2 additions & 2 deletions lib/galaxy/managers/jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -788,7 +788,7 @@ def invocation_job_source_iter(sa_session, invocation_id):

def get_job_metrics_for_invocation(sa_session: galaxy_scoped_session, invocation_id: int):
single_job_stmnt = (
select(WorkflowStep.order_index, Job.tool_id, WorkflowStep.label, JobMetricNumeric)
select(WorkflowStep.order_index, Job.id, Job.tool_id, WorkflowStep.label, JobMetricNumeric)
.join(Job, JobMetricNumeric.job_id == Job.id)
.join(
WorkflowInvocationStep,
Expand All @@ -799,7 +799,7 @@ def get_job_metrics_for_invocation(sa_session: galaxy_scoped_session, invocation
.join(WorkflowStep, WorkflowStep.id == WorkflowInvocationStep.workflow_step_id)
)
collection_job_stmnt = (
select(WorkflowStep.order_index, Job.tool_id, WorkflowStep.label, JobMetricNumeric)
select(WorkflowStep.order_index, Job.id, Job.tool_id, WorkflowStep.label, JobMetricNumeric)
.join(Job, JobMetricNumeric.job_id == Job.id)
.join(ImplicitCollectionJobsJobAssociation, Job.id == ImplicitCollectionJobsJobAssociation.job_id)
.join(
Expand Down
1 change: 1 addition & 0 deletions lib/galaxy/schema/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -2173,6 +2173,7 @@ class JobMetric(Model):

class WorkflowJobMetric(JobMetric):
tool_id: str
job_id: str
step_index: int
step_label: Optional[str]

Expand Down
13 changes: 8 additions & 5 deletions lib/galaxy/webapps/galaxy/services/invocations.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,19 +167,22 @@ def show_invocation_step(self, trans, step_id) -> InvocationStep:
def show_invocation_metrics(self, trans: ProvidesHistoryContext, invocation_id: int):
extended_job_metrics = get_job_metrics_for_invocation(trans.sa_session, invocation_id)
job_metrics = []
job_ids = []
tool_ids = []
step_indexes = []
step_labels = []
for row in extended_job_metrics:
step_indexes.append(row[0])
tool_ids.append(row[1])
step_labels.append(row[2])
job_metrics.append(row[3])
job_ids.append(row[1])
tool_ids.append(row[2])
step_labels.append(row[3])
job_metrics.append(row[4])
metrics_dict_list = summarize_metrics(trans, job_metrics)
for tool_id, step_index, step_label, metrics_dict in zip(
tool_ids, step_indexes, step_labels, metrics_dict_list
for tool_id, job_id, step_index, step_label, metrics_dict in zip(
tool_ids, job_ids, step_indexes, step_labels, metrics_dict_list
):
metrics_dict["tool_id"] = tool_id
metrics_dict["job_id"] = trans.security.encode_id(job_id)
metrics_dict["step_index"] = step_index
metrics_dict["step_label"] = step_label
return metrics_dict_list
Expand Down

0 comments on commit f5f2efe

Please sign in to comment.