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

Add ContainerImage #66

Merged
merged 3 commits into from
Nov 6, 2023
Merged

Add ContainerImage #66

merged 3 commits into from
Nov 6, 2023

Conversation

simleo
Copy link
Collaborator

@simleo simleo commented Nov 3, 2023

Adds support for converting "cwlprov:image" entries to "ContainerImage".

Copy link

codecov bot commented Nov 6, 2023

Codecov Report

Attention: 1 lines in your changes are missing coverage. Please review.

Comparison is base (d052f77) 97.61% compared to head (8a56a22) 97.62%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #66      +/-   ##
==========================================
+ Coverage   97.61%   97.62%   +0.01%     
==========================================
  Files          12       13       +1     
  Lines        1928     1983      +55     
==========================================
+ Hits         1882     1936      +54     
- Misses         46       47       +1     
Files Coverage Δ
src/runcrate/convert.py 97.89% <100.00%> (+0.04%) ⬆️
tests/test_cwlprov_crate_builder.py 99.89% <100.00%> (+<0.01%) ⬆️
tests/test_utils.py 100.00% <100.00%> (ø)
src/runcrate/utils.py 96.77% <96.29%> (-3.23%) ⬇️

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@simleo simleo merged commit 59702e9 into ResearchObject:main Nov 6, 2023
11 checks passed
@simleo simleo deleted the container_img branch November 6, 2023 10:21
@simleo
Copy link
Collaborator Author

simleo commented Nov 6, 2023

@mr-c I had to pin cwl-utils to 0.29 since 0.30 makes most tests fail: https://github.com/ResearchObject/runcrate/actions/runs/6746561680/job/18340868647

@simleo
Copy link
Collaborator Author

simleo commented Nov 6, 2023

I've tried to update the code by changing the occurrences of type to type_ where appropriate, but two tests (test_revsort and test_secondary_files) still fail with:

data_dir = PosixPath('/tmp/runcrate/tests/data'), tmpdir = PosixPath('/tmp/pytest-of-simleo/pytest-16/test_revsort0')

    def test_revsort(data_dir, tmpdir):
        root = data_dir / "revsort-run-1"
        output = tmpdir / "revsort-run-1-crate"
        license = "Apache-2.0"
        readme = data_dir / "README.md"
        inputs_file = root / "workflow" / "primary-job.json"
        workflow_name = "RevSort"
>       builder = ProvCrateBuilder(root, workflow_name=workflow_name, license=license, readme=readme)

tests/test_cwlprov_crate_builder.py:39: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
src/runcrate/convert.py:203: in __init__
    self.cwl_defs = get_workflow(self.wf_path)
src/runcrate/convert.py:182: in get_workflow
    defs = load_document_by_yaml(json_wf, wf_path.absolute().as_uri(), load_all=True)
/home/simleo/git/runcrate/venv/lib/python3.11/site-packages/cwl_utils/parser/__init__.py:227: in load_document_by_yaml
    result = cwl_v1_0.load_document_by_yaml(
/home/simleo/git/runcrate/venv/lib/python3.11/site-packages/cwl_utils/parser/cwl_v1_0.py:20290: in load_document_by_yaml
    result, metadata = _document_load(
/home/simleo/git/runcrate/venv/lib/python3.11/site-packages/cwl_utils/parser/cwl_v1_0.py:876: in _document_load
    loader.load(doc["$graph"], baseuri, loadingOptions),
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = CommandLineTool | ExpressionTool | Workflow | array<CommandLineTool | ExpressionTool | Workflow>
doc = [{'class': 'Workflow', 'doc': 'Reverse the lines in a document, then sort those lines.', 'hints': [{'class': 'DockerRe...ommand': 'sort', 'class': 'CommandLineTool', 'doc': 'Sort lines using the `sort` command', 'id': '#sorttool.cwl', ...}]
baseuri = 'file:///tmp/runcrate/tests/data/revsort-run-1/workflow/packed.cwl'
loadingOptions = <cwl_utils.parser.cwl_v1_0.LoadingOptions object at 0x7f345e586990>, docRoot = None, lc = []

    def load(self, doc, baseuri, loadingOptions, docRoot=None, lc=None):
        # type: (Any, str, LoadingOptions, Optional[str], Optional[List[Any]]) -> Any
        errors = []
    
        if lc is None:
            lc = []
    
        for t in self.alternates:
            try:
                return t.load(doc, baseuri, loadingOptions, docRoot=docRoot, lc=lc)
            except ValidationException as e:
                if isinstance(t, _ArrayLoader) and len(self.alternates) > 1:
                    continue
                if isinstance(doc, (CommentedMap, dict)):
                    if "class" in doc:
                        if str(doc.get("class")) == str(t):
                            errors.append(
                                ValidationException(
                                    f"Object `{baseuri.split('/')[-1]}` is not valid because:",
                                    SourceLine(doc, next(iter(doc)), str),
                                    [e],
                                )
                            )
                    else:
                        if "array" in str(t):
                            continue
                        else:
                            if "id" in doc:
                                id = baseuri.split("/")[-1] + "#" + str(doc.get("id"))
                                if "id" in lc:
                                    errors.append(
                                        ValidationException(
                                            f"checking object `{id}`",
                                            SourceLine(lc, "id", str),
                                            [e],
                                        )
                                    )
                                else:
                                    errors.append(
                                        ValidationException(
                                            f"checking object `{id}`",
                                            SourceLine(lc, doc.get("id"), str),
                                            [e],
                                        )
                                    )
                            else:
                                if not isinstance(
                                    t, (_PrimitiveLoader)
                                ):  # avoids 'tried <class "NoneType"> was {x}' errors
                                    errors.append(
                                        ValidationException(f"tried `{t}` but", None, [e])
                                    )
                else:
                    # avoids "tried <class "CWLType"> but x" and instead returns the values for parsing
                    errors.append(ValidationException("", None, [e]))
    
        if isinstance(doc, (CommentedMap, dict)) and "class" in doc:
            if str(doc.get("class")) not in str(self.alternates):
                errors.append(
                    ValidationException(
                        "Field `class` contains undefined reference to "
                        + "`"
                        + "/".join(baseuri.split("/")[0:-1])
                        + "/"
                        + str(doc.get("class"))
                        + "`",
                        SourceLine(doc, "class", str),
                        [],
                    )
                )
>       raise ValidationException("", None, errors, "*")
E       schema_salad.exceptions.ValidationException: Value is a array, but valid type for this field is an object.
E       Value is a array, but valid type for this field is an object.
E       Value is a array, but valid type for this field is an object.

@mr-c
Copy link
Contributor

mr-c commented Nov 6, 2023

@simleo yep, I ran into the same thing; I've filled an issue and assigned it to the author of the change common-workflow-language/schema_salad#766

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants