Skip to content

Commit 521425d

Browse files
authored
Added recursive_resolve_and_validate_document (#1375)
* added recursive_resolve_and_validate_document * misc fixes
1 parent 07ebbea commit 521425d

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

cwltool/load_tool.py

+19
Original file line numberDiff line numberDiff line change
@@ -496,3 +496,22 @@ def resolve_overrides(
496496
def load_overrides(ov: str, base_url: str) -> List[CWLObjectType]:
497497
ovloader = Loader(overrides_ctx)
498498
return resolve_overrides(ovloader.fetch(ov), ov, base_url)
499+
500+
501+
def recursive_resolve_and_validate_document(
502+
loadingContext: LoadingContext,
503+
workflowobj: Union[CommentedMap, CommentedSeq],
504+
uri: str,
505+
preprocess_only: bool = False,
506+
skip_schemas: Optional[bool] = None,
507+
) -> Tuple[LoadingContext, str, Process]:
508+
"""Validate a CWL document, checking that a tool object can be built."""
509+
loadingContext, uri = resolve_and_validate_document(
510+
loadingContext,
511+
workflowobj,
512+
uri,
513+
preprocess_only=preprocess_only,
514+
skip_schemas=skip_schemas,
515+
)
516+
tool = make_tool(uri, loadingContext)
517+
return loadingContext, uri, tool

tests/test_recursive_validation.py

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
"""Test the recursive validation feature (validate document and try to build tool)."""
2+
from cwltool.load_tool import fetch_document, recursive_resolve_and_validate_document
3+
4+
from .util import get_data
5+
6+
7+
def test_recursive_validation() -> None:
8+
"""Test the recursive_resolve_and_validate_document function."""
9+
loadingContext, workflowobj, uri = fetch_document(
10+
get_data("tests/wf/default_path.cwl")
11+
)
12+
loadingContext, uri, tool = recursive_resolve_and_validate_document(
13+
loadingContext, workflowobj, uri
14+
)

0 commit comments

Comments
 (0)