nwb-schema icon indicating copy to clipboard operation
nwb-schema copied to clipboard

Question: Is link name optional

Open ehennestad opened this issue 6 months ago • 1 comments

In the format specification:

1.7.1. Link specification keys

1.7.1.1. name

Optional key specifying the name of the link.

I am wondering if this is intentional or whether the name should be required as for the attribute? I have looked through all the type specs for the latest version of the schema, and currently all links have a name. If the name is really optional, how is it intended to be mapped onto it's owning data type? I.e what name should be used for an attribute (python) or property (matlab) of neurodata type class?

ehennestad avatar Jun 20 '25 11:06 ehennestad

According to the spec / spec language, the link name is optional. You can have an unnamed link to a data type, and objects should be mapped as a link based on the data type. There are some examples here: https://github.com/rly/ndx-pose/blob/main/spec/ndx-pose.extensions.yaml

One advantage of having an unnamed link is that you can specify a collection of links, e.g., a group can contain an arbitrary number of links to Image objects, which you can see here: https://github.com/rly/ndx-pose/blob/d2ffebab277253858a1d9259e71e768b2c49387e/spec/ndx-pose.extensions.yaml#L126-L132

Should link name be optional for the non-collection case? Perhaps not. It makes it hard for downstream tools to access the linked object if it does not have a fixed name in the spec or API.

It also introduces some edge cases - what if a group specifies a subgroup of type A and a link of type A, or what if B extends A and a group specifies a subgroup of type A and a link of type B? Which mapping takes precedence?

These edge cases also apply to specs with a collection of links, so we should probably have a rule for precedence. I believe in HDMF, groups and datasets will be mapped before links, but I am not sure.

Note that you can also have an group/dataset with a data type and no name in the spec. This is common for collections but I don't think it is disallowed for non-collections. Perhaps we should disallow that case as well.

@oruebel Can you think of any other use cases?

rly avatar Jun 20 '25 19:06 rly