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

Enforce that Array[Type]+ are non-empty #187

Merged
merged 1 commit into from
Feb 16, 2022
Merged

Conversation

mr-c
Copy link
Member

@mr-c mr-c commented Feb 16, 2022

https://github.com/openwdl/wdl/blob/main/versions/1.1/SPEC.md#arrayx

An Array may have an empty value (i.e. an array of length zero), unless it is declared using +, the non-empty postfix quantifier, which represents a constraint that the Array value must contain one-or-more elements.

Only enforced for WDL Task inputs for now.

For Workflow inputs we will have to synthesize a new step to do the checking

Uses a hack from common-workflow-language/common-workflow-language#907

@codecov
Copy link

codecov bot commented Feb 16, 2022

Codecov Report

Merging #187 (6b0ac1e) into main (63d60b5) will increase coverage by 0.22%.
The diff coverage is 94.28%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #187      +/-   ##
==========================================
+ Coverage   93.70%   93.93%   +0.22%     
==========================================
  Files           3        3              
  Lines         667      692      +25     
  Branches      196      203       +7     
==========================================
+ Hits          625      650      +25     
  Misses         17       17              
  Partials       25       25              
Impacted Files Coverage Δ
wdl2cwl/main.py 93.93% <94.28%> (+0.23%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 63d60b5...6b0ac1e. Read the comment docs.

Comment on lines +208 to +210
arguments:
- valueFrom: ${if (inputs.counts_txt.length == 0) {throw "counts_txt must
contain at least one item.";} else { return "";}}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Total hack. Doesn't change the command line if the array has at least one item. Throws a javascript exception if the array is empty, effectively avoiding execution of the tool if the input is malformed.

Copy link
Contributor

@ntachukwu ntachukwu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome

@mr-c mr-c merged commit 80c2e0b into main Feb 16, 2022
@mr-c mr-c deleted the array_non_empty_enforce branch February 16, 2022 16:33
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.

None yet

2 participants