linkml / linkml

Linked Open Data Modeling Language
https://linkml.io/linkml
Other
311 stars 96 forks source link

Enum inheritance not working in gen-sqlddl and others #1685

Open kappe-c opened 10 months ago

kappe-c commented 10 months ago

Describe the bug

Several tools (all but linkml-validate?) do not implement enum inheritance. If I made no mistake.
E.g., when running
linkml-sqldb dump -s schema.yaml -D schema.db -C MyClass data.yaml
I get the error
ValueError: Unknown MyEnumB enumeration code: B

schema:

id: https://example.org/inheriting-enum
name: inheritingenum

imports: https://w3id.org/linkml/types

enums:
  MyEnumA:
    permissible_values:
      A:
  MyEnumB:
    inherits:
      - MyEnumA
    include:
      - permissible_values:
          B:

classes:
  MyClass:
    attributes:
      my_attr:
        # range: MyEnumA # simple enum works
        range: MyEnumB

Data:

# my_attr: A
my_attr: B # neither permissable values included in MyEnumA nor inherited from MyEnumB are recognized

I know it is said that "tooling support for dynamic enums is maturing" but also that "default behavior will be too permissive" 1; while here it is not permissive at all.

Reluctantly (because installing OAK seemed overkill) I also tried the given suggestion

vskit expand -s schema.yaml -o schema_expanded.yaml

This has no effect (except for changing the indention a little)!

I also found that, e.g, gen-doc does not know what to do with inherits and includes.

To reproduce

Steps to reproduce the behavior:

  1. Create the two files
  2. Run the command(s)

Expected behavior

There are no complaints about A or B as a value for range MyEnumB.

To me this seems like the simplest case of a "dynamic enum". Just like the set of slots is extended from a parent to a child class, I would expect the set of permissible values to be extended in the enum example given above (actually the first thing I tried was using is_a). In particular I think it should not be a problem for database tools to materialize/expand such enums.

About your computer (if applicable, please complete the following information):

plbremer commented 9 months ago

@kappe-c a workaround, for the moment, for us, looks like

enums: EnumBenchlingCellLineExtension: description: >- Cell Lines for benchling extension permissible_values: foo:

EnumBenchlingCellLine: inherits: EnumBenchlingCellLineExtension description: >- Cell Lines for benchling dynamic pv_formula: LABEL reachable_from: source_ontology: obo:clo source_nodes:

operating vskit expand on EnumBenchlingCellLine will yield permissible values containing the extension and the dynamic. so, essentially, the enumeration that is dynamic must inherit the extension. Inheriting something that is dynamic does not seem to work.