Skip to content

Commit

Permalink
Test case for data manager tools YAML generation.
Browse files Browse the repository at this point in the history
  • Loading branch information
jmchilton committed Jul 1, 2023
1 parent 3a822dd commit b0d0a0b
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 1 deletion.
23 changes: 23 additions & 0 deletions src/ephemeris/_config_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,25 @@
StrOrPath = Union[Path, str]


class RepositoryInstallTarget(BaseModel):
name: str
owner: str
tool_shed_url: Optional[str]
tool_panel_section_id: Optional[str]
tool_panel_section_label: Optional[str]
revisions: Optional[List[str]]
install_tool_dependencies: Optional[bool]
install_repository_dependencies: Optional[bool]
install_resolver_dependencies: Optional[bool]


class RepositoryInstallTargets(BaseModel):
""" """
api_key: Optional[str]
galaxy_instance: Optional[str]
tools: List[RepositoryInstallTarget]


class DataManager(BaseModel, extra=Extra.forbid):
tags: List[str]
tool_id: str
Expand Down Expand Up @@ -58,3 +77,7 @@ def read_data_managers(path: StrOrPath) -> DataManagers:

def read_genomes(path: StrOrPath) -> Genomes:
return Genomes(**_read_yaml(path))


def read_tools(path: StrOrPath) -> RepositoryInstallTargets:
return RepositoryInstallTargets(**_read_yaml(path))
9 changes: 8 additions & 1 deletion src/ephemeris/_idc_data_managers_to_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@

import yaml

from ._config_models import read_data_managers
from ._config_models import (
read_data_managers,
RepositoryInstallTargets,
)
from .common_parser import (
add_log_file_argument,
add_verbosity_argument,
Expand Down Expand Up @@ -66,6 +69,10 @@ def build_shed_install_conf(path: str) -> dict:

def write_shed_install_conf(data_manager_conf_path: str, output_path: str) -> None:
tools_yaml = build_shed_install_conf(data_manager_conf_path)

# validate generated dict to ensure we're writing out valid file
RepositoryInstallTargets(**tools_yaml)

with open(output_path, "w") as f:
yaml.safe_dump(tools_yaml, f)

Expand Down
13 changes: 13 additions & 0 deletions tests/test_idc_data_managers_to_tools.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
from pathlib import Path

from ephemeris._config_models import read_tools
from ephemeris._idc_data_managers_to_tools import write_shed_install_conf
from .test_split_genomes import setup_mock_idc_dir


def test_idc_lint_valid(tmp_path: Path):
setup_mock_idc_dir(tmp_path)
output_path = tmp_path / "output.yaml"
write_shed_install_conf(tmp_path / "data_managers.yml", output_path)
# validate the generated tools file...
read_tools(output_path)

0 comments on commit b0d0a0b

Please sign in to comment.