Skip to content

Commit

Permalink
Revert "Added/modified backend API endpoints when there is a Job ID (…
Browse files Browse the repository at this point in the history
…Dataset Page) and when there is no Job ID (Tool Form Page): passes newly included Error-Transcript JSON and User object to the email report methods (Work-in-Progress)."

This reverts commit 038eb44.
  • Loading branch information
hujambo-dunia committed Apr 5, 2024
1 parent 038eb44 commit c2e3c90
Show file tree
Hide file tree
Showing 8 changed files with 52 additions and 132 deletions.
80 changes: 29 additions & 51 deletions client/src/components/Common/SelfReportingError.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@
<div class="response-message"></div>
</div>
<h3 class="h-lg">Dataset Error Report</h3>
<BAlert v-for="(notification, index) in notifications" :key="index" :variant="notification.variant" show>
<span v-html="notification.text" />
</BAlert>
<p v-if="notifications && !notifications.variant" v-html="notifications[0].text" />
<span v-else-if="notifications && notifications.variant">
<BAlert :variant="notifications.variant">
<span v-html="notifications[0].text" />
</BAlert>
</span>
<div v-if="hasDetails(commandOutputs)">
<h4 class="h-md">Details</h4>
<div v-for="(commandOutput, index) in commandOutputs" :key="index">
Expand All @@ -18,6 +21,19 @@
</div>
</div>
</div>
<JobProblemProvider v-slot="{ result: jobProblems }" :job-id="dataset.creating_job" @error="onError">
<div v-if="jobProblems && (jobProblems.has_duplicate_inputs || jobProblems.has_empty_inputs)">
<h4 class="common_problems mt-3 h-md">Detected Common Potential Problems</h4>
<p v-if="jobProblems.has_empty_inputs" id="dataset-error-has-empty-inputs">
The tool was started with one or more empty input datasets. This frequently results in tool errors
due to problematic input choices.
</p>
<p v-if="jobProblems.has_duplicate_inputs" id="dataset-error-has-duplicate-inputs">
The tool was started with one or more duplicate input datasets. This frequently results in tool
errors due to problematic input choices.
</p>
</div>
</JobProblemProvider>
<h4 class="mt-3 h-md">Troubleshooting</h4>
<p>
There are a number of helpful resources to self diagnose and correct problems.
Expand All @@ -44,19 +60,6 @@
v-model="message"
:area="true"
title="Please provide detailed information on the activities leading to this issue:" />
<BLink
:aria-expanded="isExpanded ? 'true' : 'false'"
aria-controls="collapse-previous"
@click="isExpanded = !isExpanded">
({{ title }}) Error transcript:
</BLink>
<BCollapse id="collapse-previous" v-model="isExpanded">
<FormElement
id="transcript"
v-model="transcript"
:area="true"
title="Error transcript:" />
</BCollapse><br>
<b-button
id="dataset-error-submit"
variant="primary"
Expand All @@ -71,7 +74,7 @@
<script>
import { FontAwesomeIcon } from "@fortawesome/vue-fontawesome";
import { BAlert, BButton, BCollapse, BLink } from "bootstrap-vue";
import { BAlert } from "bootstrap-vue";
import FormElement from "components/Form/FormElement";
import { JobProblemProvider } from "components/providers/JobProvider";
import { mapState } from "pinia";
Expand All @@ -81,17 +84,13 @@ import { useMarkdown } from "@/composables/markdown";
import { useUserStore } from "@/stores/userStore";
import { sendErrorReport } from "../DatasetInformation/services";
import { sendErrorReportTool } from "../ToolInformation/services";
export default {
components: {
FontAwesomeIcon,
FormElement,
JobProblemProvider,
BAlert,
BButton,
BCollapse,
BLink,
},
props: {
dataset: {
Expand All @@ -106,10 +105,6 @@ export default {
type: Array,
default: () => [],
},
transcript: {
type: String,
default: "",
},
},
setup() {
const { renderMarkdown } = useMarkdown({ openLinksInNewPage: true });
Expand All @@ -120,7 +115,6 @@ export default {
message: null,
errorMessage: null,
resultMessages: [],
isExpanded: false,
};
},
computed: {
Expand All @@ -134,36 +128,20 @@ export default {
const isEmailActive = !getGalaxyInstance().config.show_inactivity_warning;
return !this.currentUser?.email || !isEmailActive;
},
title() {
return this.isExpanded ? `-` : `+`;
},
},
methods: {
onError(err) {
this.errorMessage = err;
},
submit(dataset, userEmailJob) {
const email = userEmailJob || this.currentUserEmail;
const message = this.message;
if (this.transcript) {
sendErrorReportTool(dataset, message, email, this.transcript).then(
(resultMessages) => {
this.resultMessages = resultMessages;
},
(errorMessage) => {
this.errorMessage = errorMessage;
}
);
} else {
sendErrorReport(dataset, message, email, this.transcript).then(
(resultMessages) => {
this.resultMessages = resultMessages;
},
(errorMessage) => {
this.errorMessage = errorMessage;
}
);
}
submit(dataset, email) {
sendErrorReport(dataset, this.message, email).then(
(resultMessages) => {
this.resultMessages = resultMessages;
},
(errorMessage) => {
this.errorMessage = errorMessage;
}
);
},
hasDetails(outputs) {
return (
Expand Down
2 changes: 0 additions & 2 deletions client/src/components/DatasetInformation/DatasetError.vue
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ export default {
return [
{
text: `An error occurred while running the tool <b id='dataset-error-tool-id' class='text-break '>${toolId}</b>.`,
variant: "danger"
},
];
},
Expand All @@ -103,7 +102,6 @@ export default {
submit(dataset, userEmailJob) {
const email = userEmailJob || this.currentUserEmail;
const message = this.message;
sendErrorReport(dataset, message, email).then(
(resultMessages) => {
this.resultMessages = resultMessages;
Expand Down
42 changes: 10 additions & 32 deletions client/src/components/Tool/ToolForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@
<ToolEntryPoints v-for="job in entryPoints" :key="job.id" :job-id="job.id" />
</div>
<b-modal v-model="showError" size="sm" :title="errorTitle | l" scrollable ok-only>
<SelfReportingError
:result-messages="[]"
:show-form="'true'"
:message="''"
:transcript="errorContentPretty"
:submit="submit"
:dataset="dataset"
:historyId="currentHistoryId"
:command-outputs="buildCommandOutputs(errorMessage)"
:notifications="buildNotifications(formConfig.id)" />
<b-alert v-if="errorMessage" show variant="danger">
{{ errorMessage }}
</b-alert>
<b-alert show variant="warning">
The server could not complete this request. Please verify your parameter settings, retry submission and
contact the Galaxy Team if this error persists. A transcript of the submitted data is shown below.
</b-alert>
<small class="text-muted">
<pre>{{ errorContentPretty }}</pre>
</small>
</b-modal>
<ToolRecommendation v-if="showRecommendation" :tool-id="formConfig.id" />
<ToolCard
Expand Down Expand Up @@ -127,7 +127,6 @@ import ToolCard from "./ToolCard";
import { allowCachedJobs } from "./utilities";
import FormSelect from "@/components/Form/Elements/FormSelect.vue";
import SelfReportingError from "../Common/SelfReportingError.vue";
export default {
components: {
Expand All @@ -140,7 +139,6 @@ export default {
ToolEntryPoints,
ToolRecommendation,
Heading,
SelfReportingError,
},
props: {
id: {
Expand Down Expand Up @@ -401,26 +399,6 @@ export default {
}
);
},
buildNotifications(toolId) {
return [
{
text: `An error occurred while running the tool <b id='dataset-error-tool-id' class='text-break '>${toolId}</b>.`,
variant: "danger"
},
{
text: "The server could not complete this request. Please verify your parameter settings, retry submission and contact the Galaxy Team if this error persists. A transcript of the submitted data is shown below.",
variant: "warning"
},
];
},
buildCommandOutputs(detail) {
return [
{
text: "Tool Message (?)",
detail: [detail],
}
];
},
},
};
</script>
5 changes: 0 additions & 5 deletions lib/galaxy/schema/jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,6 @@ class ReportJobErrorPayload(Model):
title="Message",
description="The optional message sent with the error report.",
)
toolTranscript: Optional[str] = Field(
default=None,
title="Transcript",
description="The optional Tool Transcript error created by the user and sent with the error report.",
)


class SearchJobsPayload(Model):
Expand Down
2 changes: 1 addition & 1 deletion lib/galaxy/tools/error_reports/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def submit_report(self, dataset, job, tool, user=None, user_submission=False, **
for plugin in self.plugins:
if user_submission == plugin.user_submission:
try:
response = plugin.submit_report(dataset, job, tool, user, **kwargs)
response = plugin.submit_report(dataset, job, tool, **kwargs)
log.debug("Bug report plugin %s generated response %s", plugin, response)
if plugin.verbose and response:
responses.append(response)
Expand Down
5 changes: 2 additions & 3 deletions lib/galaxy/tools/error_reports/plugins/email.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,12 @@ def __init__(self, **kwargs):
self.verbose = string_as_bool(kwargs.get("verbose", True))
self.user_submission = string_as_bool(kwargs.get("user_submission", True))

def submit_report(self, dataset, job, tool, user, **kwargs):
def submit_report(self, dataset, job, tool, **kwargs):
"""Send report as an email"""
try:
error_reporter = EmailErrorReporter(dataset.id, self.app)
error_reporter.send_report(
user=user,
tool=tool,
user=job.get_user(),
email=kwargs.get("email", None),
message=kwargs.get("message", None),
redact_user_details_in_bugreport=self.redact_user_details_in_bugreport,
Expand Down
12 changes: 6 additions & 6 deletions lib/galaxy/tools/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ def _can_access_dataset(self, user):
roles = []
return self.app.security_agent.can_access_dataset(roles, self.hda.dataset)

def create_report(self, user, tool, email="", message="", redact_user_details_in_bugreport=False, **kwd):
def create_report(self, user, email="", message="", redact_user_details_in_bugreport=False, **kwd):
hda = self.hda
job = self.job
host = self.app.url_for("/", qualified=True)
Expand Down Expand Up @@ -205,8 +205,8 @@ def create_report(self, user, tool, email="", message="", redact_user_details_in
hda_show_params_link=hda_show_params_link,
job_id_encoded=self.app.security.encode_id(job.id),
job_id=job.id,
tool_version=tool.tool_version,
job_tool_id=tool.id,
tool_version=job.tool_version,
job_tool_id=job.tool_id,
job_tool_version=hda.tool_version,
job_runner_external_id=job.job_runner_external_id,
job_command_line=job.command_line,
Expand All @@ -227,12 +227,12 @@ def create_report(self, user, tool, email="", message="", redact_user_details_in

self.html_report = string.Template(error_report_template_html).safe_substitute(report_variables)

def _send_report(self, user, tool, email=None, message=None, **kwd):
def _send_report(self, user, email=None, message=None, **kwd):
return self.report

def send_report(self, user, tool, email=None, message=None, **kwd):
def send_report(self, user, email=None, message=None, **kwd):
if self.report is None:
self.create_report(user, tool, email=email, message=message, **kwd)
self.create_report(user, email=email, message=message, **kwd)
return self._send_report(user, email=email, message=message, **kwd)


Expand Down
36 changes: 4 additions & 32 deletions lib/galaxy/webapps/galaxy/api/jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,6 @@
)
from galaxy.work.context import WorkRequestContext

import json

log = logging.getLogger(__name__)

router = Router(tags=["jobs"])
Expand Down Expand Up @@ -313,41 +311,15 @@ def error(
payload: Annotated[ReportJobErrorPayload, ReportErrorBody],
job_id: JobIdPathParam,
trans: ProvidesUserContext = DependsOnTrans,
) -> JobErrorSummary:
myMessages = self.error_all(payload, job_id, trans)
return JobErrorSummary(messages=myMessages)

@router.post(
"/api/jobs/no-job-id-error",
name="report_error_no_job_id",
summary="Submits a bug report via the API.",
)
def error_no_job_id(
self,
payload: Annotated[ReportJobErrorPayload, ReportErrorBody],
trans: ProvidesUserContext = DependsOnTrans,
) -> JobErrorSummary:
myMessages = self.error_all(payload=payload, job_id=None, trans=trans)
return JobErrorSummary(messages=myMessages)

def error_all(
self,
payload: Annotated[ReportJobErrorPayload, ReportErrorBody],
job_id,
trans: ProvidesUserContext = DependsOnTrans,
) -> JobErrorSummary:
# Get dataset on which this error was triggered
dataset_id = payload.dataset_id
dataset = self.service.hda_manager.get_accessible(id=dataset_id, user=trans.user)
# Get job
job = self.service.get_job(trans, job_id)
if not dataset.creating_job or dataset.creating_job.id != job.id:
raise exceptions.RequestParameterInvalidException("dataset_id was not created by job_id")
if payload.toolTranscript:
job = {}
transcript = json.loads(payload.toolTranscript)
tool = trans.app.toolbox.get_tool(transcript["tool_id"], tool_version=transcript["tool_version"])
else:
job = self.service.get_job(trans, job_id)
tool = trans.app.toolbox.get_tool(job.tool_id, tool_version=job.tool_version) or None
tool = trans.app.toolbox.get_tool(job.tool_id, tool_version=job.tool_version) or None
email = payload.email
if not email and not trans.anonymous:
email = trans.user.email
Expand All @@ -360,7 +332,7 @@ def error_all(
email=email,
message=payload.message,
)
return messages
return JobErrorSummary(messages=messages)

@router.get(
"/api/jobs/{job_id}/inputs",
Expand Down

0 comments on commit c2e3c90

Please sign in to comment.