common-workflow-language / common-workflow-language/schema_salad

metaschema predicates pollute salad document namespace

Open
#506 8 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
86
Forks
64
Avg merge
19h 24m
Merged PRs (30d)
19

Description

Alternative title: CWL enum `symbols` get fully expanded instead of being left as pure strings

Source issue: https://github.com/common-workflow-lab/cwljava/issues/70

For example, `CommandInputEnumSchema` https://github.com/common-workflow-language/cwl-v1.2/blob/a0f2d38e37ff51721fdeaf993bb2ab474b17246b/CommandLineTool.yml#L355 extends `InputEnumSchema` https://github.com/common-workflow-language/cwl-v1.2/blob/a0f2d38e37ff51721fdeaf993bb2ab474b17246b/Process.yml#L689 which extends `sld:EnumSchema`https://github.com/common-workflow-language/cwl-v1.2/blob/a0f2d38e37ff51721fdeaf993bb2ab474b17246b/salad/schema_salad/metaschema/metaschema_base.yml#L135 which defines the `symbols` field as follows:

``` yaml
type: string[]
jsonldPredicate:
_id: "sld:symbols"
_type: "@id"
identity: true
doc: "Defines the set of valid sy
```

The `_type: "@id"` and `identity: true` might be fine for the metaschema of Schema Salad, but is inappropriate for a CWL Enum definition, where we expect plain strings.

`cwltool` ignores this, but codegen readers of CWL (cwljava, cwl-utils) cannot.

(all of this is also true for the `Output` and non-`Command` versions of `EnumSchema` in CWL)

I can't find a way to override this with a `specializeFrom`/`To` nor with overlapping field definitions, nor with re-rooting the CWL schema to not derive from `sld:EnumSchema` as the metaschema predicates collide with the CWL schema predicates

```
schema_salad.exceptions.SchemaException: Predicate collision on symbols, '{'@id': 'https://w3id.org/cwl/salad#symbols', '@type': '@id', 'identity': True}' != 'https://w3id.org/cwl/cwl#InputEnumSchema/symbols'
```

(even if I use `jsonldPredicate: { _id: "sld:symbols" }` ):
```
schema_salad.exceptions.SchemaException: Predicate collision on symbols, '{'@id': 'https://w3id.org/cwl/salad#symbols', '@type': '@id', 'identity': True}' != '{'@id': 'https://w3id.org/cwl/salad#symbols'}'
```

Fix options:

1. Hack the schema (fixes the codegen, but introduces big problems down the line): Re-root the CWL schema to not extend `sld:EnumSchema` and rename `symbols` from the metaschema to be something else (and update all other schema salad documents to use this new name in their definitions)
2. Hack the codegen (manually change the type of the symbols field post generation): would unblock https://github.com/common-workflow-lab/cwljava/issues/70 but it not sustainable
3. Scope the predicates situation so that schema-salad documents themselves can use any predicate name from the metaschema, and then apply fix 1 without renaming the existing use of `symbols` in the metaschema. I like this, but I don't know how to implement it yet
4. Do nothing. Consumers of the CWL codegen libraries will be forced to subtract out the ID of the parent object to get the true values of CWL `type: enum`s.

Contributor guide

Open the contributing guide

Research direction

Start with schema_salad/metaschema/metaschema_base.yml and the cited CWL Process.yml and CommandLineTool.yml definitions, then reproduce the predicate collision in the schema loading or code-generation entry point. Done means resolving the namespace collision so CWL enum symbols remain plain strings without breaking schema-salad documents or other EnumSchema variants.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
tooling
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.