From a00bd8bf8eb22bfb38be9146c244fd22f60d3a8f Mon Sep 17 00:00:00 2001 From: Martin Cech Date: Mon, 21 May 2018 16:12:36 -0400 Subject: [PATCH 1/3] escape pipe in details so we can have pipes inside markdown tables --- doc/parse_gx_xsd.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/parse_gx_xsd.py b/doc/parse_gx_xsd.py index cf72dfdaf98..d61a60f6945 100644 --- a/doc/parse_gx_xsd.py +++ b/doc/parse_gx_xsd.py @@ -128,7 +128,7 @@ def _build_attributes_table(tag, attributes, hide_attributes=False, attribute_na use = attribute.attrib.get("use", "optional") == "required" if "|" in details: - raise Exception("Cannot build Markdown table") + details.replace("|", "\|") details = details.replace("\n", " ").strip() best_practices = _get_bp_link(annotation_el) if best_practices: From 01d2a5c2ae7e5a1f3b5fcfdd2b1eca766a69d5ec Mon Sep 17 00:00:00 2001 From: Nicola Soranzo Date: Tue, 22 May 2018 15:10:22 +0100 Subject: [PATCH 2/3] Fix parsing of `scontrol show job` Fix the following traceback: ``` galaxy.jobs.runners.slurm ERROR 2018-05-22 13:01:07,050 (1024816/14094939) Failure in SLURM _complete_terminal_job(), job final state will be: failed Traceback (most recent call last): File "/tgac/services/galaxy/prod/galaxy/lib/galaxy/jobs/runners/slurm.py", line 86, in _complete_terminal_job slurm_state = _get_slurm_state() File "/tgac/services/galaxy/prod/galaxy/lib/galaxy/jobs/runners/slurm.py", line 81, in _get_slurm_state job_info_dict = dict([out_param.split('=', 1) for out_param in stdout.split()]) ValueError: dictionary update sequence element #52 has length 1; 2 is required ``` --- lib/galaxy/jobs/runners/slurm.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/lib/galaxy/jobs/runners/slurm.py b/lib/galaxy/jobs/runners/slurm.py index 52c9e7fb011..c4c38163f9a 100644 --- a/lib/galaxy/jobs/runners/slurm.py +++ b/lib/galaxy/jobs/runners/slurm.py @@ -37,7 +37,7 @@ class SlurmJobRunner(DRMAAJobRunner): def _complete_terminal_job(self, ajs, drmaa_state, **kwargs): def _get_slurm_state_with_sacct(job_id, cluster): - cmd = ['sacct', '-n', '-o state%-32'] + cmd = ['sacct', '-n', '-o', 'state%-32'] if cluster: cmd.extend(['-M', cluster]) cmd.extend(['-j', job_id]) @@ -77,7 +77,20 @@ class SlurmJobRunner(DRMAAJobRunner): return job_state return 'NOT_FOUND' raise Exception('`%s` returned %s, stderr: %s' % (' '.join(cmd), p.returncode, stderr)) - job_info_dict = dict([out_param.split('=', 1) for out_param in stdout.split()]) + stdout = stdout.strip() + # stdout is a single line in format "key1=value1 key2=value2 ..." + job_info_keys = [] + job_info_values = [] + for job_info in stdout.split(): + try: + # Some value may contain `=` (e.g. `StdIn=StdIn=/dev/null`) + k, v = job_info.split('=', 1) + job_info_keys.append(k) + job_info_values.append(v) + except ValueError: + # Some value may contain spaces (e.g. `Comment=** time_limit (60m) min_nodes (1) **`) + job_info_values[-1] += ' ' + job_info + job_info_dict = dict(zip(job_info_keys, job_info_values)) return job_info_dict['JobState'] try: From 9a840537cb5037e280a8db14125a46fbb422d305 Mon Sep 17 00:00:00 2001 From: Martin Cech Date: Tue, 22 May 2018 14:15:36 -0400 Subject: [PATCH 3/3] pass the check for pipe presence in details the docs build fine and the table renders fine too --- doc/parse_gx_xsd.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/doc/parse_gx_xsd.py b/doc/parse_gx_xsd.py index d61a60f6945..9c4da2cd5cd 100644 --- a/doc/parse_gx_xsd.py +++ b/doc/parse_gx_xsd.py @@ -128,7 +128,8 @@ def _build_attributes_table(tag, attributes, hide_attributes=False, attribute_na use = attribute.attrib.get("use", "optional") == "required" if "|" in details: - details.replace("|", "\|") + # This seems to work fine for now, but potentially can cause problems. + pass details = details.replace("\n", " ").strip() best_practices = _get_bp_link(annotation_el) if best_practices: