diff --git a/packages/python/openproblems/CHANGELOG.md b/packages/python/openproblems/CHANGELOG.md index a9bab40..ffdddac 100644 --- a/packages/python/openproblems/CHANGELOG.md +++ b/packages/python/openproblems/CHANGELOG.md @@ -6,7 +6,7 @@ - `resolve_path`: Resolve a path relative to a parent path or project root. * `project.component_tests`: - - `run_check_config` / `check_config`: Validate a component's Viash config (namespace, type, metadata, normalization, variants, Nextflow runner). + - `check_config`: Validate a component's Viash config (namespace, type, metadata, normalization, variants, Nextflow runner). - `run_and_check_output`: Run a component executable and validate its output files against format specifications. * `project.docs`: diff --git a/packages/python/openproblems/README.md b/packages/python/openproblems/README.md index 508ee13..afcb1d7 100644 --- a/packages/python/openproblems/README.md +++ b/packages/python/openproblems/README.md @@ -27,7 +27,7 @@ Utilities for working with Viash projects. Helpers for writing component tests. -- `run_check_config` / `check_config`: Validate a component's Viash configuration. +- `check_config`: Validate a component's Viash configuration. - `run_and_check_output`: Run a component and validate its output files against format specs. #### `openproblems.project.docs` diff --git a/packages/python/openproblems/src/openproblems/project/__init__.py b/packages/python/openproblems/src/openproblems/project/__init__.py index 10832fb..3516b28 100644 --- a/packages/python/openproblems/src/openproblems/project/__init__.py +++ b/packages/python/openproblems/src/openproblems/project/__init__.py @@ -1,7 +1,7 @@ from .find_project_root import find_project_root from .read_viash_config import read_viash_config from .read_nested_yaml import read_nested_yaml -from .component_tests.check_config import run_check_config as check_config +from .component_tests.check_config import check_config from .component_tests.run_and_check_output import run_and_check_output from .docs.read_task_metadata import read_task_metadata from .docs.render_task_readme_qmd import render_task_readme_qmd diff --git a/packages/python/openproblems/src/openproblems/project/component_tests/__init__.py b/packages/python/openproblems/src/openproblems/project/component_tests/__init__.py index b72ae5e..a6ec83e 100644 --- a/packages/python/openproblems/src/openproblems/project/component_tests/__init__.py +++ b/packages/python/openproblems/src/openproblems/project/component_tests/__init__.py @@ -1,41 +1,11 @@ from .check_config import ( - check_info, - check_links, - check_references, - check_url, - run_check_config, + check_config, ) from .run_and_check_output import ( - check_anndata, - check_dataframe, - check_dictionary, - check_format, - check_input_files, - check_output_files, - check_spatialdata, - generate_cmd_args, - get_argument_sets, run_and_check_output, - run_component, ) __all__ = [ - # check_config - "check_info", - "check_links", - "check_references", - "check_url", - "run_check_config", - # run_and_check_output - "check_anndata", - "check_dataframe", - "check_dictionary", - "check_format", - "check_input_files", - "check_output_files", - "check_spatialdata", - "generate_cmd_args", - "get_argument_sets", + "check_config", "run_and_check_output", - "run_component", ] diff --git a/packages/python/openproblems/src/openproblems/project/component_tests/check_config.py b/packages/python/openproblems/src/openproblems/project/component_tests/check_config.py index 14d3cce..d3dacc1 100644 --- a/packages/python/openproblems/src/openproblems/project/component_tests/check_config.py +++ b/packages/python/openproblems/src/openproblems/project/component_tests/check_config.py @@ -105,7 +105,7 @@ def check_info(this_info: Dict, this_config: Dict, comp_type: str) -> None: check_references(references) -def run_check_config(config: dict) -> None: +def check_config(config: dict) -> None: """Validate a viash component config. Checks namespace, info.type, component metadata, preferred_normalization, diff --git a/packages/python/openproblems/src/openproblems/project/component_tests/run_and_check_output.py b/packages/python/openproblems/src/openproblems/project/component_tests/run_and_check_output.py index 75fdfe3..3f05b78 100644 --- a/packages/python/openproblems/src/openproblems/project/component_tests/run_and_check_output.py +++ b/packages/python/openproblems/src/openproblems/project/component_tests/run_and_check_output.py @@ -215,13 +215,20 @@ def get_argument_sets(config: dict, resources_dir: str) -> dict: for arg in config["all_arguments"]: new_arg = arg.copy() arg_info = new_arg.get("info") or {} - example = arg.get("example", [None])[0] - - if example and arg["type"] == "file": + default_or_example = None + if arg_info.get("default"): + default_or_example = arg_info["default"] + elif arg_info.get("example"): + default_or_example = arg_info["example"] + if isinstance(default_or_example, list): + default_or_example = default_or_example[0] + + # use example to find test resource file + if default_or_example and arg["type"] == "file": if arg["direction"] == "input": - value = f"{resources_dir}/{example}" + value = f"{resources_dir}/{default_or_example}" else: - ext_res = re.search(r"\.(\w+)$", example) + ext_res = re.search(r"\.(\w+)$", default_or_example) if ext_res: value = f"{arg['clean_name']}.{ext_res.group(1)}" else: @@ -246,7 +253,7 @@ def get_argument_sets(config: dict, resources_dir: str) -> dict: val = test_instance[arg["clean_name"]] if new_arg["type"] == "file" and new_arg["direction"] == "input": val = f"{resources_dir}/{val}" - new_arg["value"] = val + new_arg["value"] = normalize_argument_value(val, new_arg) new_arguments.append(new_arg) argument_sets[name] = new_arguments