From d2c01903a632ccc10e59bc31640991c50ad7b164 Mon Sep 17 00:00:00 2001 From: hujambo-dunia Date: Thu, 25 Apr 2024 12:34:29 -0400 Subject: [PATCH 1/2] Added front-end email template files (removed back-end email templating strings) --- .../tools/email_templates/errors_dataset.html | 66 +++++++++ .../tools/email_templates/errors_dataset.txt | 44 ++++++ lib/galaxy/tools/errors.py | 132 ++---------------- 3 files changed, 124 insertions(+), 118 deletions(-) create mode 100644 lib/galaxy/tools/email_templates/errors_dataset.html create mode 100644 lib/galaxy/tools/email_templates/errors_dataset.txt diff --git a/lib/galaxy/tools/email_templates/errors_dataset.html b/lib/galaxy/tools/email_templates/errors_dataset.html new file mode 100644 index 000000000000..3d4e44ef73e2 --- /dev/null +++ b/lib/galaxy/tools/email_templates/errors_dataset.html @@ -0,0 +1,66 @@ + + +

Galaxy Tool Error Report

+from ${host} + +

Error Localization

+ + + + + + +
Dataset${dataset_id} (${dataset_id_encoded})
History${history_id} (${history_id_encoded})
Failed Job${hid}: ${history_item_name} (${hda_id_encoded})
+ +

User Provided Information

+ +The user ${email_str} provided the following information: + +
+${message}
+
+ + +

Detailed Job Information

+ +Job environment and execution information is available at the job info page. + + + + + + + + + +
Job ID${job_id} (${job_id_encoded})
Tool ID${job_tool_id}
Tool Version${tool_version}
Job PID or DRM id${job_runner_external_id}
Job Tool Version${job_tool_version}
+ +

Job Execution and Failure Information

+ +

Command Line

+
+${job_command_line}
+
+ +

stderr

+
+${job_stderr}
+
+ +

stdout

+
+${job_stdout}
+
+ +

Job Information

+
+${job_info}
+
+ +

Job Traceback

+
+${job_traceback}
+
+ +This is an automated message. Do not reply to this address. + diff --git a/lib/galaxy/tools/email_templates/errors_dataset.txt b/lib/galaxy/tools/email_templates/errors_dataset.txt new file mode 100644 index 000000000000..d1c90ce1cb0a --- /dev/null +++ b/lib/galaxy/tools/email_templates/errors_dataset.txt @@ -0,0 +1,44 @@ +GALAXY TOOL ERROR REPORT +------------------------ + +This error report was sent from the Galaxy instance hosted on the server +"${host}" +----------------------------------------------------------------------------- +This is in reference to dataset id ${dataset_id} (${dataset_id_encoded}) from history id ${history_id} (${history_id_encoded}) +----------------------------------------------------------------------------- +You should be able to view the history containing the related history item (${hda_id_encoded}) + +${hid}: ${history_item_name} + +by logging in as a Galaxy admin user to the Galaxy instance referenced above +and pointing your browser to the following link. + +${history_view_link} +----------------------------------------------------------------------------- +The user ${email_str} provided the following information: + +${message} +----------------------------------------------------------------------------- +info url: ${hda_show_params_link} +job id: ${job_id} (${job_id_encoded}) +tool id: ${job_tool_id} +tool version: ${tool_version} +job pid or drm id: ${job_runner_external_id} +job tool version: ${job_tool_version} +----------------------------------------------------------------------------- +job command line: +${job_command_line} +----------------------------------------------------------------------------- +job stderr: +${job_stderr} +----------------------------------------------------------------------------- +job stdout: +${job_stdout} +----------------------------------------------------------------------------- +job info: +${job_info} +----------------------------------------------------------------------------- +job traceback: +${job_traceback} +----------------------------------------------------------------------------- +(This is an automated message). diff --git a/lib/galaxy/tools/errors.py b/lib/galaxy/tools/errors.py index e6d3a79429f1..32b47f8c1eae 100644 --- a/lib/galaxy/tools/errors.py +++ b/lib/galaxy/tools/errors.py @@ -2,8 +2,10 @@ Functionality for dealing with tool errors. """ +import os import string +import jinja2 import markupsafe from galaxy import ( @@ -13,122 +15,6 @@ from galaxy.security.validate_user_input import validate_email_str from galaxy.util import unicodify -error_report_template = """ -GALAXY TOOL ERROR REPORT ------------------------- - -This error report was sent from the Galaxy instance hosted on the server -"${host}" ------------------------------------------------------------------------------ -This is in reference to dataset id ${dataset_id} (${dataset_id_encoded}) from history id ${history_id} (${history_id_encoded}) ------------------------------------------------------------------------------ -You should be able to view the history containing the related history item (${hda_id_encoded}) - -${hid}: ${history_item_name} - -by logging in as a Galaxy admin user to the Galaxy instance referenced above -and pointing your browser to the following link. - -${history_view_link} ------------------------------------------------------------------------------ -The user ${email_str} provided the following information: - -${message} ------------------------------------------------------------------------------ -info url: ${hda_show_params_link} -job id: ${job_id} (${job_id_encoded}) -tool id: ${job_tool_id} -tool version: ${tool_version} -job pid or drm id: ${job_runner_external_id} -job tool version: ${job_tool_version} ------------------------------------------------------------------------------ -job command line: -${job_command_line} ------------------------------------------------------------------------------ -job stderr: -${job_stderr} ------------------------------------------------------------------------------ -job stdout: -${job_stdout} ------------------------------------------------------------------------------ -job info: -${job_info} ------------------------------------------------------------------------------ -job traceback: -${job_traceback} ------------------------------------------------------------------------------ -(This is an automated message). -""" - -error_report_template_html = """ - - -

Galaxy Tool Error Report

-from ${host} - -

Error Localization

- - - - - - -
Dataset${dataset_id} (${dataset_id_encoded})
History${history_id} (${history_id_encoded})
Failed Job${hid}: ${history_item_name} (${hda_id_encoded})
- -

User Provided Information

- -The user ${email_str} provided the following information: - -
-${message}
-
- - -

Detailed Job Information

- -Job environment and execution information is available at the job info page. - - - - - - - - - -
Job ID${job_id} (${job_id_encoded})
Tool ID${job_tool_id}
Tool Version${tool_version}
Job PID or DRM id${job_runner_external_id}
Job Tool Version${job_tool_version}
- -

Job Execution and Failure Information

- -

Command Line

-
-${job_command_line}
-
- -

stderr

-
-${job_stderr}
-
- -

stdout

-
-${job_stdout}
-
- -

Job Information

-
-${job_info}
-
- -

Job Traceback

-
-${job_traceback}
-
- -This is an automated message. Do not reply to this address. - -""" - class ErrorReporter: def __init__(self, hda, app): @@ -218,14 +104,18 @@ def create_report(self, user, email="", message="", redact_user_details_in_bugre message=util.unicodify(message), ) - self.report = string.Template(error_report_template).safe_substitute(report_variables) + self.report = string.Template(self.get_report_template("errors_dataset", "txt")).safe_substitute( + report_variables + ) # Escape all of the content for use in the HTML report for parameter in report_variables.keys(): if report_variables[parameter] is not None: report_variables[parameter] = markupsafe.escape(unicodify(report_variables[parameter])) - self.html_report = string.Template(error_report_template_html).safe_substitute(report_variables) + self.html_report = string.Template(self.get_report_template("errors_dataset", "html")).safe_substitute( + report_variables + ) def _send_report(self, user, email=None, message=None, **kwd): return self.report @@ -235,6 +125,12 @@ def send_report(self, user, email=None, message=None, **kwd): self.create_report(user, email=email, message=message, **kwd) return self._send_report(user, email=email, message=message, **kwd) + def get_report_template(self, report_type, report_format): + path = os.path.abspath(os.path.join(os.path.dirname(__file__), "email_templates")) + env = jinja2.Environment(loader=jinja2.FileSystemLoader(path)) + template = env.get_template(report_type + "." + report_format) + return template.render() + class EmailErrorReporter(ErrorReporter): def _send_report(self, user, email=None, message=None, **kwd): From 5d77c98badf10d64e1f80402ccab129f37d976ee Mon Sep 17 00:00:00 2001 From: hujambo-dunia Date: Mon, 29 Apr 2024 14:44:44 -0400 Subject: [PATCH 2/2] Fix for clarification of output stream sources --- .../tools/email_templates/errors_dataset.html | 147 +++++++++++------- .../tools/email_templates/errors_dataset.txt | 6 + lib/galaxy/tools/errors.py | 6 +- 3 files changed, 105 insertions(+), 54 deletions(-) diff --git a/lib/galaxy/tools/email_templates/errors_dataset.html b/lib/galaxy/tools/email_templates/errors_dataset.html index 3d4e44ef73e2..a8789793d939 100644 --- a/lib/galaxy/tools/email_templates/errors_dataset.html +++ b/lib/galaxy/tools/email_templates/errors_dataset.html @@ -1,66 +1,109 @@ -

Galaxy Tool Error Report

-from ${host} +

Galaxy Tool Error Report

+ + from + + ${host} + + -

Error Localization

- - - - - - -
Dataset${dataset_id} (${dataset_id_encoded})
History${history_id} (${history_id_encoded})
Failed Job${hid}: ${history_item_name} (${hda_id_encoded})
+

Error Localization

+ + + + + + + + + + + + + + + +
Dataset + ${dataset_id} (${dataset_id_encoded}) +
History + ${history_id} (${history_id_encoded}) +
Failed Job${hid}: ${history_item_name} (${hda_id_encoded})
-

User Provided Information

+

User Provided Information

+ The user + ${email_str} + provided the following information: +
+            ${message}
+        
-The user ${email_str} provided the following information: +

Detailed Job Information

+ Job environment and execution information is available at the job + info page. -
-${message}
-
+ + + + + + + + + + + + + + + + + + + + + + + +
Job ID${job_id} (${job_id_encoded})
Tool ID${job_tool_id}
Tool Version${tool_version}
Job PID or DRM id${job_runner_external_id}
Job Tool Version${job_tool_version}
+

Job Execution and Failure Information

+

Command Line

+
+            ${job_command_line}
+        
-

Detailed Job Information

+

Job stderr

+
+            ${job_stderr}
+        
-Job environment and execution information is available at the job info page. +

Job stdout

+
+            ${job_stdout}
+        
- - - - - - - - -
Job ID${job_id} (${job_id_encoded})
Tool ID${job_tool_id}
Tool Version${tool_version}
Job PID or DRM id${job_runner_external_id}
Job Tool Version${job_tool_version}
+

Job Information

+
+            ${job_info}
+        
-

Job Execution and Failure Information

+

Job Traceback

+
+            ${job_traceback}
+        
-

Command Line

-
-${job_command_line}
-
+

Tool Execution and Failure Information

+

Tool stderr

+
+            ${tool_stderr}
+        
-

stderr

-
-${job_stderr}
-
+

Tool stdout

+
+            ${tool_stdout}
+        
-

stdout

-
-${job_stdout}
-
- -

Job Information

-
-${job_info}
-
- -

Job Traceback

-
-${job_traceback}
-
- -This is an automated message. Do not reply to this address. - + This is an automated message. Do not reply to this address. + + diff --git a/lib/galaxy/tools/email_templates/errors_dataset.txt b/lib/galaxy/tools/email_templates/errors_dataset.txt index d1c90ce1cb0a..05d9669b6d10 100644 --- a/lib/galaxy/tools/email_templates/errors_dataset.txt +++ b/lib/galaxy/tools/email_templates/errors_dataset.txt @@ -41,4 +41,10 @@ ${job_info} job traceback: ${job_traceback} ----------------------------------------------------------------------------- +tool stderr: +${tool_stderr} +----------------------------------------------------------------------------- +tool stdout: +${tool_stdout} +----------------------------------------------------------------------------- (This is an automated message). diff --git a/lib/galaxy/tools/errors.py b/lib/galaxy/tools/errors.py index 32b47f8c1eae..51df260e02c2 100644 --- a/lib/galaxy/tools/errors.py +++ b/lib/galaxy/tools/errors.py @@ -96,10 +96,12 @@ def create_report(self, user, email="", message="", redact_user_details_in_bugre job_tool_version=hda.tool_version, job_runner_external_id=job.job_runner_external_id, job_command_line=job.command_line, - job_stderr=util.unicodify(job.stderr), - job_stdout=util.unicodify(job.stdout), + job_stderr=util.unicodify(job.job_stderr), + job_stdout=util.unicodify(job.job_stdout), job_info=util.unicodify(job.info), job_traceback=util.unicodify(job.traceback), + tool_stderr=util.unicodify(job.tool_stderr), + tool_stdout=util.unicodify(job.tool_stdout), email_str=email_str, message=util.unicodify(message), )