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

feat(converters): add option include descendants #1630

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

Silvanoc
Copy link
Contributor

"gen-json-schema" and "linkml-validate" have the option "--include-range-class-descendants" so that children of a class specified in a range are added to the generated JSON-Schema as allowed classes.

This patch adds a similar option to "linkml-convert", with the same result in the JSON-Schema being used for validation as the equally named option for "gen-json-schema" and "linkml-validate".

Closes #1629

@Silvanoc Silvanoc marked this pull request as draft September 15, 2023 16:24
@Silvanoc
Copy link
Contributor Author

In draft status until tests are provided. Functional changes already available (manually tested) for preview.

@cmungall
Copy link
Member

Thanks!

I think in general there is less need of user control over this now we have:

This keeps the default as false, but always allows class descendants if there is a type designator, which essentially allows the jsonschema validator to "choose" the intended one based on the value of the type designator.

However, it's still good to have consistency in options and how options are passed through.

Further discussion on dynamic typing:
https://github.com/orgs/linkml/discussions/1548

@Silvanoc
Copy link
Contributor Author

@cmungall I've seen PR #1613, but I didn't know how to take advantage of it. And I've seen that applying the same pattern available for other tools with the option --include-range-class-descendants is very easy.

@Silvanoc
Copy link
Contributor Author

Silvanoc commented Sep 15, 2023

@cmungall I've seen PR #1613, but I didn't know how to take advantage of it. And I've seen that applying the same pattern available for other tools with the option --include-range-class-descendants is very easy.

I think, I've understood it now!

The option --include-range-class-descendants is an external flag that applies subtype polymorphism on all class hierarchies. But it also means that the subtype can be only inferred based on duck typing.

The type designators state explicitly of which subtype an object is, so no more duck typing needed. I haven't tested it yet, but I understand that once a type desingator has been used, descendant classes are automatically included for the subtypes. But not on those without type designators.

I like it!

@Silvanoc
Copy link
Contributor Author

I'm having difficulties to get this functionality working. I suspect that issue #1638 is the origin of the difficulties I'm facing.

"gen-json-schema" and "linkml-validate" have the option
"--include-range-class-descendants" so that children of a class
specified in a range are added to the generated JSON-Schema as allowed
classes.

This patch adds a similar option to "linkml-convert", with the same
result in the JSON-Schema being used for validation as the equally named
option for "gen-json-schema" and "linkml-validate".

Signed-off-by: Silvano Cirujano Cuesta <silvano.cirujano-cuesta@siemens.com>
Extend "linkml-convert" tests to cover the new option
"--include-range-class-descendants".

Signed-off-by: Silvano Cirujano Cuesta <silvano.cirujano-cuesta@siemens.com>
Apply same validation code as in 'linkml-validate' to include range
class descendants.

Signed-off-by: Silvano Cirujano Cuesta <silvano.cirujano-cuesta@siemens.com>
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.

Add --include-range-class-descendants option to "linkml-convert"
2 participants