linkml / linkml-model

Link Modeling Language (LinkML) model
https://linkml.github.io/linkml-model/docs/
33 stars 16 forks source link

`array: null` for any shaped arrays not allowed #187

Open sneakers-the-rat opened 4 months ago

sneakers-the-rat commented 4 months ago

I believe we arrived at a place where this would represent an array with any shape:

classes:
  MyClass:
    attributes:
      an_array:
        range: int
        array:

but currently the range of the array slot is a non-nullable array_expression: https://github.com/linkml/linkml-model/blob/e53a511e4e0fe7c403747f18de77553d42365feb/linkml_model/model/schema/meta.yaml#L1430

edit: wait obviously you can make metamodel attributes optional too my bad. i'll PR

Not sure how to express this in the schema, my first instinct would be something like this:

any_of:
- range: array_expression
- range: null

but I'm not sure if that's valid.

Another option to be able to differentiate between an explicit null like that and an any shaped array might be to make the syntax

array: Any

which would make the metamodel more straightforward:

any_of:
- range: array_expression
- range: Anything
rly commented 3 months ago

@sneakers-the-rat can we close this? I believe this was discussed in https://github.com/linkml/linkml-model/pull/189 or do we want to allow null as an option in addition to {} and unset?

sneakers-the-rat commented 3 months ago

i think we can close this if we make a separate issue for Schemaview should be able to determine whether a value is unset or explicitly null - discussion is here: https://github.com/orgs/linkml/discussions/1975 but imo regardless if we allow it i think we should be able to check (if we choose not to allow explicit nulls then we would need to check for them anyway ;)