Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix parsing of training metadata.yaml files #1439

Merged
merged 1 commit into from
Apr 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions planemo/training/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""
Expand Down
10 changes: 6 additions & 4 deletions planemo/training/topic.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import collections
import os

from galaxy.util import listify

from planemo import templates
from .utils import (
load_yaml,
Expand Down Expand Up @@ -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()
Expand All @@ -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
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions tests/data/training_metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ requirements:
topic_name: introduction
tutorials:
- peaks2genes
maintainers:
editorial_board:
- maintainer1
- maintainer2
- maintainer2
6 changes: 3 additions & 3 deletions tests/test_training_topic.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)


Expand All @@ -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():
Expand Down
2 changes: 1 addition & 1 deletion tests/test_training_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down