-
Notifications
You must be signed in to change notification settings - Fork 28
Annotate class-specific usage of slot with added_in.
#482
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
Annotate class-specific usage of slot with added_in.
#482
Conversation
The `added_in` annotation is used to indicate that a slot has been introduced in a specific version of the specification. For now, that annotation is only used in the model-wide definition of slots, which means it can only indicate when a brand new slot has been introduced -- it can not be used to indicate that a pre-existing slot has been added to a class in which it was not used before. For example, the `similarity_measure` slot has existed since before 1.0, but has been only been added to the MappingSet class for version 1.1. In this commit, we make use of LinkML's `slot_usage` mechanism to add the `added_in` annotation not only to the general (model-wide) definition of a slot, but also to the specific instance of a slot within a class.
matentzn
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great!
|
can we add a unit test that checks that added in is annotated on all fields? This would also require back-annotating all old fields to be added in 1.0 |
(1) This would mean having to add to every single slot the following stanza instantiates: sssom:Versionable
annotations:
added_in: "1.0"Rather than cluttering the schema, it is much easier and much more readable in my opinion to keep the current and reasonable assumption that, if a slot does not have an explicit I wouldn’t be against a test that checks the diff on the (2) This would not have helped in the slightest with the issue that the present PR is addressing, which is the fact that slots that were already existing in 1.0 but were only used in the |
|
Would it be possible to make the implicit assumption explicit by setting added_in: 1.0 as a default value? This way we could use SchemaView to write a simple test that no new slot should have a added_in annotation < current release |
|
How would that “simple” test work? How would it know which slots are new (and therefore should not have a Let‘s say we add a new The “simple” test will find that the How does the test distinguish between
|
|
If you want to test that new slots have an (a) On every PR, compare the old schema with the new schema, get the list of slots in both to figure out which slots are added in the new schema (if any), then check whether all those added slots have a (b) Compile once and for all the list of 1.0 slots (it just needs to be done once since that list will by definition never change), and on every PR check that all slots that are not on that list (which are all the post-1.0 slots) have a And this will still not catch the issue that the present PR is addressing. |
ehartley
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good!
This PR adds a test that any new slot must (1) carry a `added_in` annotation that (2) is set to the current version of the spec. The test works by preparing a fixed compiled list of all the “non-new” slots (all slots present in the 1.0 release) for both the `Mapping` and `MappingSet` classes. It then loads the current schema and iterates over all slots for those two classes, checking that every slot that is not a pre-existing slot is annotated as expected. Of note, the test currently fails (as it should), because the `similarity_measure`, `curation_rule`, and `curation_rule_text` slots are _new_ on the `MappingSet` class but are currently not annotated as such (this is what #482 is fixing).
docs/have been added/updated if necessarymake testhas been run locally[ ] tests have been added/updated (if applicable)[ ] CHANGELOG.md has been updated.Already covered by previous changesThe
added_inannotation is used to indicate that a slot has been introduced in a specific version of the specification. For now, that annotation is only used in the model-wide definition of slots, which means it can only indicate when a brand new slot has been introduced – it can not be used to indicate that a pre-existing slot has been added to a class in which it was not used before.For example, the
similarity_measureslot has existed since before 1.0, but has been only been added to theMappingSetclass for version 1.1. Currently that information is not contained in the model, implementers need to check the Model changes across versions section of the spec to be aware of that.Likewise for
curation_ruleandcuration_rule_text, which have just been added to theMappingSetclass.In this PR, we make use of LinkML's
slot_usagemechanism to add theadded_inannotation not only to the general (model-wide) definition of a slot, but also to the specific instance of a slot within a class.This allows to encode, directly into the model, that the use of
similarity_measure,curation_rule, andcuration_rule_textat the level of theMappingSetclass is only possible starting from version 1.1.(This really should have been done directly in the PRs that added those slots to the
MappingSetclass – #412 and #472 –, but at the time I had not realized that it was possible to useslot_usageto add annotations to a slot only within the context of a particular class.)