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

CWL Enum using numerics ? #267

Open
fmigneault opened this issue Sep 6, 2023 · 3 comments
Open

CWL Enum using numerics ? #267

fmigneault opened this issue Sep 6, 2023 · 3 comments

Comments

@fmigneault
Copy link
Contributor

fmigneault commented Sep 6, 2023

The https://www.commonwl.org/v1.2/CommandLineTool.html#CommandInputEnumSchema only allows string symbols.

However, it is very common to have integer and double/float as well.

Should CommandInputEnumSchema allow these numeric types as well?
Otherwise, how could I add this functionality?
I am trying to convert OpenAPI-style process definitions into CWL processes, and I cannot convert an input using an enum[int] type.

Note that the current JSON schema actually allows (incorrectly?) numbers, given that I did not even realize numbers were not supported while writing it.
https://github.com/common-workflow-language/cwl-v1.2/blob/1.2.1_proposed/json-schema/cwl.yaml#L1354-L1364

@mr-c
Copy link
Member

mr-c commented Sep 7, 2023

Since a CWL enum is basically a (possibly named) type: string with a restricted set of valid values, one could (eventually) implement the numerical version of a CWL enum as a type: int and then use the restrictions syntax that is still being developed to list the acceptable numbers: common-workflow-language/common-workflow-language#764

So for now, I would recommend making non-string based enumerations the appropriate atomic CWL numerical type and listing the valid values in a label or doc note.

If you really need to check this at tool instantiation time (but prior to running the tool) you can generate a inputBinding: { valueFrom: ... } section that uses JavaScript to confirm the validity, returning self in a positive outcome or raising an exception in the failure case.

@fmigneault
Copy link
Contributor Author

Would it be possible to use the SchemaDefRequirement to define some IntEnum? Would validation be performed if such a type was defined and used, or would I still need to define the valueFrom check for each tool that needs IntEnum?

@mr-c
Copy link
Member

mr-c commented Sep 7, 2023

Would it be possible to use the SchemaDefRequirement to define some IntEnum?

Not in CWL v1.0-v1.2, no.

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

No branches or pull requests

2 participants