From 56806d32a52d2d7dc13b8764924aa851b9abc30c Mon Sep 17 00:00:00 2001 From: Nicola Soranzo Date: Mon, 25 Mar 2024 19:05:44 +0000 Subject: [PATCH] Fix parsing of training ``metadata.yaml`` files Fix https://github.com/galaxyproject/planemo/issues/1415 . --- planemo/training/__init__.py | 5 +++-- planemo/training/topic.py | 10 ++++++---- tests/data/training_metadata.yaml | 4 ++-- tests/test_training_topic.py | 6 +++--- tests/test_training_utils.py | 2 +- 5 files changed, 15 insertions(+), 12 deletions(-) diff --git a/planemo/training/__init__.py b/planemo/training/__init__.py index 9c4a73c2c..31ee74711 100644 --- a/planemo/training/__init__.py +++ b/planemo/training/__init__.py @@ -37,8 +37,9 @@ def init_training(self, ctx): if not self.tuto.exists(): info(f"The tutorial {self.tuto.name} in topic {self.topic.name} does not exist. It will be created.") self.tuto.create_tutorial(ctx) - info("WARNING: Change the contributors/maintainers listed in the metadata of the new training ") - info("before serving the website to fit the one listed in the CONTRIBUTORS.yaml file") + info( + "WARNING: Change the contributors listed in the metadata of the new training before serving the website to fit the one listed in the CONTRIBUTORS.yaml file" + ) def check_topic_init_tuto(self): """Check that the topic and tutorial are already there and retrieve them.""" diff --git a/planemo/training/topic.py b/planemo/training/topic.py index 390469d27..f9a2ee212 100644 --- a/planemo/training/topic.py +++ b/planemo/training/topic.py @@ -3,6 +3,8 @@ import collections import os +from galaxy.util import listify + from planemo import templates from .utils import ( load_yaml, @@ -63,7 +65,7 @@ def __init__(self, name="new_topic", target="use", title="The new topic", summar self.title = title self.summary = summary self.docker_image = "" - self.maintainers = ["maintainers"] + self.editorial_board = [] self.parent_dir = parent_dir self.set_default_requirement() self.set_paths() @@ -86,13 +88,13 @@ def init_from_metadata(self): self.summary = metadata["summary"] self.requirements = [] if "requirements" in metadata: - for r in metadata["requirements"]: + for r in listify(metadata["requirements"]): req = Requirement() req.init_from_dict(r) self.requirements.append(req) if "docker_image" in metadata: self.docker_image = metadata["docker_image"] - self.maintainers = metadata["maintainers"] + self.editorial_board = metadata["editorial_board"] self.set_paths() # GETTERS @@ -112,7 +114,7 @@ def export_metadata_to_ordered_dict(self): metadata["summary"] = self.summary metadata["requirements"] = self.get_requirements() metadata["docker_image"] = self.docker_image - metadata["maintainers"] = self.maintainers + metadata["editorial_board"] = self.editorial_board return metadata # SETTERS diff --git a/tests/data/training_metadata.yaml b/tests/data/training_metadata.yaml index 797fe30e3..5bb8d0e1c 100644 --- a/tests/data/training_metadata.yaml +++ b/tests/data/training_metadata.yaml @@ -9,6 +9,6 @@ requirements: topic_name: introduction tutorials: - peaks2genes -maintainers: +editorial_board: - maintainer1 -- maintainer2 \ No newline at end of file +- maintainer2 diff --git a/tests/test_training_topic.py b/tests/test_training_topic.py index a887d8a5f..03a3bc4e2 100644 --- a/tests/test_training_topic.py +++ b/tests/test_training_topic.py @@ -17,7 +17,7 @@ def test_topic_init(): assert topic.title == "The new topic" assert topic.summary == "Summary" assert topic.docker_image == "" - assert "maintainers" in topic.maintainers + assert topic.editorial_board == [] assert topic.parent_dir == "topics" assert topic.dir == "topics/new_topic" assert topic.requirements[0].topic_name == "introduction" @@ -57,7 +57,7 @@ def test_topic_init_from_metadata(): assert topic.summary == "Summary" assert topic.requirements[0].topic_name == "introduction" assert topic.requirements[0].tutorials == ["peaks2genes"] - assert "maintainer1" in topic.maintainers + assert "maintainer1" in topic.editorial_board shutil.rmtree(topic.parent_dir) @@ -80,7 +80,7 @@ def test_topic_export_metadata_to_ordered_dict(): assert "summary" in metadata assert "requirements" in metadata assert "docker_image" in metadata - assert "maintainers" in metadata + assert "editorial_board" in metadata def test_topic_set_paths(): diff --git a/tests/test_training_utils.py b/tests/test_training_utils.py index e0c43d592..f92ca51a2 100644 --- a/tests/test_training_utils.py +++ b/tests/test_training_utils.py @@ -18,7 +18,7 @@ def test_load_yaml(): # test if name there assert metadata["name"] == "test" # test if order of material is conserved - assert metadata["maintainers"][0] == "maintainer1" + assert metadata["editorial_board"][0] == "maintainer1" def test_save_to_yaml():