Skip to content
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
2 changes: 1 addition & 1 deletion packages/python/openproblems/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`:
Expand Down
2 changes: 1 addition & 1 deletion packages/python/openproblems/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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",
]
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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

Expand Down