From 27320b6c0446cf9d041db1fc042e459ce79e50d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Manuel=20Dom=C3=ADnguez?= Date: Fri, 22 Sep 2023 18:06:51 +0200 Subject: [PATCH 1/3] Workaround for XML nodes of job resource parameters losing their children This bug was spotted because the job resource parameters selector broke on usegalaxy.eu. For the tool keras_train_and_eval, the option "Use GPU resources" shows up, but no drop-down menu is available and no items can be selected. The options are available as children of the XML nodes tagged with "param" within the scope of `galaxy.jobs.parse_resource_parameters`. They are then returned and later retrieved within the scope of `galaxy.util.parse_resource_parameters`, but by then, the children of the XML node (the options) are gone. See https://github.com/galaxyproject/galaxy/issues/16727 for more details. --- lib/galaxy/jobs/__init__.py | 3 ++- lib/galaxy/util/__init__.py | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/galaxy/jobs/__init__.py b/lib/galaxy/jobs/__init__.py index ee695304f410..2b4d4c082336 100644 --- a/lib/galaxy/jobs/__init__.py +++ b/lib/galaxy/jobs/__init__.py @@ -21,6 +21,7 @@ import packaging.version import yaml +from lxml import etree from pulsar.client.staging import COMMAND_VERSION_FILENAME import galaxy @@ -576,7 +577,7 @@ def get_tool_resource_xml(self, tool_id, tool_type): field_name, self.resource_parameters ) raise KeyError(message) - fields.append(self.resource_parameters[field_name]) + fields.append(etree.fromstring(self.resource_parameters[field_name])) if fields: conditional_element = parse_xml_string(self.JOB_RESOURCE_CONDITIONAL_XML) diff --git a/lib/galaxy/util/__init__.py b/lib/galaxy/util/__init__.py index b1355cf67be8..949ba6863668 100644 --- a/lib/galaxy/util/__init__.py +++ b/lib/galaxy/util/__init__.py @@ -914,7 +914,7 @@ def parse_resource_parameters(resource_param_file): resource_definitions_root = resource_definitions.getroot() for parameter_elem in resource_definitions_root.findall("param"): name = parameter_elem.get("name") - resource_parameters[name] = parameter_elem + resource_parameters[name] = etree.tostring(parameter_elem) return resource_parameters From ff3ad4175edf944a0dee058c9de37a31088a59b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Manuel=20Dom=C3=ADnguez?= <43052541+kysrpex@users.noreply.github.com> Date: Mon, 25 Sep 2023 09:00:36 +0200 Subject: [PATCH 2/3] Import `etree` from `galaxy.util` Import `etree` from `galaxy.util` as suggested in the code review. Co-authored-by: Marius van den Beek --- lib/galaxy/jobs/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/galaxy/jobs/__init__.py b/lib/galaxy/jobs/__init__.py index 41a6b4d04c28..dd3c8bf21928 100644 --- a/lib/galaxy/jobs/__init__.py +++ b/lib/galaxy/jobs/__init__.py @@ -23,7 +23,7 @@ ) import yaml -from lxml import etree +from galaxy.util import etree from packaging.version import Version from pulsar.client.staging import COMMAND_VERSION_FILENAME From 4bb1d56aec5378555e4c3a9d36f186c3f0467ab1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Manuel=20Dom=C3=ADnguez?= Date: Mon, 25 Sep 2023 09:37:41 +0200 Subject: [PATCH 3/3] Fix imports order --- lib/galaxy/jobs/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/galaxy/jobs/__init__.py b/lib/galaxy/jobs/__init__.py index dd3c8bf21928..f70d7250bad4 100644 --- a/lib/galaxy/jobs/__init__.py +++ b/lib/galaxy/jobs/__init__.py @@ -23,7 +23,6 @@ ) import yaml -from galaxy.util import etree from packaging.version import Version from pulsar.client.staging import COMMAND_VERSION_FILENAME @@ -75,6 +74,7 @@ ToolEvaluator, ) from galaxy.util import ( + etree, parse_xml_string, RWXRWXRWX, safe_makedirs,