Add method to infer minimum compatible SSSOM version.#604
Add method to infer minimum compatible SSSOM version.#604gouttegd wants to merge 8 commits intomapping-commons:masterfrom
Conversation
Add a new method to the MappingSetDataFrame class to automatically determine the minimum version of the SSSOM specification the set is compatible with -- that is, the earliest version that defines all the slots and all the enum values present in the set.
|
|
Fix wrong slot name when looking for "composed entity expression". Let Python compare version numbers as tuples of integers. Use `max(list)` instead of `sorted(list)[-1]`.
matentzn
left a comment
There was a problem hiding this comment.
I just want to say a huge THANK YOU for these PRs.. Much appreciated.
I dont see any red flags, lgtm!
|
Marking as draft to prevent inadvertent premature merging. |
Amend the SSSOMSchemaView#get_minimum_version() method to return a (major, minor) tuple, rather than a SssomVersionEnum object. The SssomVersionObject (which is automatically generated from the LinkML schema) is cumbersome to use, for at least two reasons: 1) obtaining the actual value of the enum requires accessing two levels of attributes (SssomVersionObject.code.text); 2) SssomVersionEnum values cannot be meaningfully compared (e.g. to check that a given version number is higher than another given version), we must (a) obtain the text value, (b) split that value over the middle dot, (c) convert the strings to integers, (d) put the integers into a tuple. OK, this can be done in one line of code, but this is cumbersome all the same, and it's best if that kind of things is not left to client code.
matentzn
left a comment
There was a problem hiding this comment.
An optional comment, feel free to merge if you are satisfied.
| # Should never happen, schema is incorrect | ||
| return None | ||
| return (version[0], version[1]) | ||
| except AttributeError: # No added_in annotation, defaults to 1.0 |
There was a problem hiding this comment.
Are there no other theoretical scenarions the "AttributeError" is thrown in the try block?
There was a problem hiding this comment.
No realistic one. AttributeError is thrown when trying to access an attribute that doesn’t exist.
Which attribute are we trying to access here?
self.view: this one has to exist, it is defined a few lines above in the same file.self.view.induced_slot: This field is defined in LinkML’sSchemaViewclass, of whichself.viewis an instance.slot.annotations: This field is defined in LinkML’sSlotDefinitionclass, of whichslot(as returned by the function above) should be an instance – if it is not, then there must be a pretty serious bug in LinkML.slot.annotations.added_in: This is the field that may not exist, if the slot we are looking at is not tagged with aadded_inannotation in the LinkML model.slot.annotations.added_in.value: If theadded_infield exists, then it should always have this field – again, if it does not, then something is wrong with LinkML.
|
Ah we still need the sssom schema version, sorry, just remembered. |
Yep, that’s why I have not done anything to resolve the conflicts since the PR can’t be merged before the |
|
Superseded in favour of #616, which includes the |
This PR adds a new method to the
MappingSetDataFrameclass to automatically determine the minimum version of the SSSOM specification the set is compatible with – that is, the earliest version that defines all the slots and all the enum values present in the set.This method could later be used to implement the behaviour recommended by the spec: automatically inserting the
sssom_versionslot when a set is written, if the set requires another version than 1.0. This could simply look like: