cwltool icon indicating copy to clipboard operation
cwltool copied to clipboard

cwltool doesn't complain when max is lesser than min in ResourceRequirements

Open Stellatsuu opened this issue 3 months ago • 5 comments

Following this discussion: https://cwl.discourse.group/t/how-does-resourcerequirement-work/1019, cwltool does not validate whether resourceMax is greater than resourceMin in ResourceRequirements.

According to the CWL documentation, this should not be allowed, as it states: "It is an error if max < min.".

Stellatsuu avatar Oct 15 '25 09:10 Stellatsuu

(I work with @Stellatsuu) Looks like there is something to change in this area: https://github.com/common-workflow-language/cwltool/blob/9781b4c89c3126e2b19f6feaf4e7327d71e754e8/cwltool/process.py#L995-L1027

Naively, I would add the following condition at line 1022:

if mx < mn:
    raise ValidationException(
        f"{a}Min cannot be greater than {a}Max."
    )

If that sounds good to the CWL experts, we can come up with a PR (and a unit test).

Cheers

aldbr avatar Oct 15 '25 14:10 aldbr

Hello @aldbr !

If that sounds good to the CWL experts, we can come up with a PR (and a unit test). Yes please, that works. As a bonus it would be nice to catch these types of error if static values or easily computable CWL expression are used, before the workflow is executed (cwltool --validate)

mr-c avatar Oct 23 '25 11:10 mr-c

This issue has been mentioned on Common Workflow Language Discourse. There might be relevant details there:

https://cwl.discourse.group/t/how-does-resourcerequirement-work/1019/6

cwl-bot avatar Oct 23 '25 14:10 cwl-bot

Hello @mr-c,

I'm currently working on adding the minmax resreq validation in cwltool (I already created a pull request (see last thread update) about that issue on cwl-utils). We think it would be great to validate it on both cwl-utils and cwltool, what are your thoughs on this?

As of now, I am trying to add the validation to the --validate option, but I don't understand how that works. Do I have to manually add the validation in resolve_and_validate_document function? Or is there another way to do so?

Stellatsuu avatar Nov 13 '25 15:11 Stellatsuu

Hello @mr-c,

Howdy @Stellatsuu !

I'm currently working on adding the minmax resreq validation in cwltool (I already created a pull request (see last thread update) about that issue on cwl-utils). We think it would be great to validate it on both cwl-utils and cwltool, what are your thoughs on this?

Sure! Though there isn't much (any?) validation code in cwl-utils outside of the autogenerated code.

As of now, I am trying to add the validation to the --validate option, but I don't understand how that works. Do I have to manually add the validation in resolve_and_validate_document function? Or is there another way to do so?

Yes, the other place additional validation can go is the workflow checker in cwltool/checker.py

mr-c avatar Nov 13 '25 16:11 mr-c