biolink / biolinkml

DEPRECATED: replaced by linkml
https://github.com/linkml/linkml
Creative Commons Zero v1.0 Universal
23 stars 12 forks source link

Clarify semantics of inlined: True - dicts vs lists #186

Closed cmungall closed 3 years ago

cmungall commented 4 years ago

We have a problem with the semantics of inlined

In the jsonschema, this is turned into a list of objects

In the python datamodel, this is turned into a dict, keyed by the identifier field of the objects

We need to fix this

I think we should have an additional flag inline_as_list, this can be default False to preserve compatibility (e.g. meta.py)

hsolbrig commented 4 years ago

I need to check, but I think it is converted into a dict only if the inlined objects have identifiers. Not a json schema expert, but it seems like it should support the same constructs, no?

hsolbrig commented 4 years ago

To add to this -- the modeling language itself is heavily dependent on the current inlined and referenced behavior. A reference to or list of references to objects can only reference objects that have a key slot. (May apply to identifier as well -- will have to check). A single inline slot (should) behave as expected -- just expands right there. A inlined multivalued slot behaves differently depending on whether it has a key or not. If keyed, it becomes a dictionary. This is how the slots, classes, types and subsets are defined in the SchemaDefinition object. (Note that, by definition, two objects in the same list cannot have the same key). If inlined element does NOT have a key, it is represented as a list. The alt_descriptions element in the model is an example of this class.

cmungall commented 4 years ago

Thanks for the clarification

So we have a use case where we would like inlined objects with keys to be serialized as lists. I think the proposed inline_as_list can handle this and will not break anything if we interpret the default False or unspecified as being "generate a Dict IF the object is keyed, otherwise fall back to list"

cmungall commented 4 years ago

Speaking offline with Harold

key should give us the functionality I proposed with inline_as_list

cmungall commented 4 years ago

Following up with call with @hsolbrig (we forgot about our discussion a month ago!)

we think it's too opaque with key

I'm proposing inlined_as_list but @hsolbrig thinks we can combine into one tag

we use lists here:

https://github.com/microbiomedata/nmdc-metadata/blob/master/examples/nmdc-01.json

cmungall commented 3 years ago

This is resolved

We have

https://biolink.github.io/biolinkml/docs/inlined_as_list

(note: inlined not inline which I erroneously stated earlier)