-
Notifications
You must be signed in to change notification settings - Fork 27
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
Modify induced_class()
/ induced_slot()
so it materializes non-scalar metaslots as well
#335
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #335 +/- ##
==========================================
+ Coverage 63.44% 63.49% +0.04%
==========================================
Files 63 63
Lines 8942 8943 +1
Branches 2569 2569
==========================================
+ Hits 5673 5678 +5
+ Misses 2648 2646 -2
+ Partials 621 619 -2 ☔ View full report in Codecov by Sentry. |
well it looks like it made the upstream tests fail in an interesting way. will put my comments on the actual PR in a review but first... the error is here, keyerror on first, the test is wrong - the source schema does not have what's sort of funny is that what must have been happening there is that the list for
that would be a real big problem if nonscalar slots metaslots were ever mutated outside of the schemaview (unfortunately they are), since then any values set on the slot would have the wildly unpredictable behavior of propagating back up to the slot usage of the last ancestor to have it set, which would then propagate back down to any other slots that inherit from it. this is additionally a problem because so anyway, obvi this PR should only be merged along with a patch to the upstream tests, but i think we are probably in for a bit of a ride as we figure out what other unanticipated behavior this method has in store for us lol |
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.
change to induced_slot
looks fine! probably the best we can do given the state of JsonObj
et al making stuff so expensive. It does add a few %s more runtime per call to what is already the most expensive method in the library, which is not great, but it is what it is.
reason why i'm requesting changes is that the test here doesn't test for the problem in linkml/linkml#2224 - this test passes when I run it against the old behavior, while the MWE here correctly fails. good practice when bugfixing - write the test first, check that it fails, fix the bug, check that tests pass.
the bug is that slot usage for an unrelated metaslot causes a different nonscalar metaslot to be overridden - ie. tempo
should have some nonscalar metaslot value set, DJController
should have slot_usage
for a different metaslot set, and then the test should assert that the first metaslot is unchanged. So, only override one or the other attr, check that the non-overridden one is the value of the base definition, check that the overridden one is the value that's set in slot_usage
.
rest of comments are style things intended for maintainability :)
…_2224.yaml` Co-authored-by: Jonny Saunders <sneakers-the-rat@protonmail.com>
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.
Thank you for the review @sneakers-the-rat!! i'll make the necessary changes based on your review comments and request another review!
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! Only thing I would change is adding a docstring to the test asserting what it tests, but good with me with or without ♥
Before we merge we should re-run upstream tests and patch that at the same time so we dont forget :) (Should we just make upstream tests be on by default like the rest of the tests? Seems like in practice this way doesnt rly work bc have to keep manually re-running, even if it was a good idea in principle to save compute time.) |
I looked at the upstream linkml test that's causing the error in test_docgen.py, and I think it's okay to remove this assertion: https://github.com/linkml/linkml/blob/main/tests/test_generators/test_docgen.py#L320-L321 The contents of {
"name": {"name": "name", "pattern": "^\\S+ \\S+$"},
"species name": {"equals_string": "human", "name": "species name"},
"stomach count": {"equals_number": 1, "name": "stomach count"},
} |
…t_utils/test_schemaview.py` Co-authored-by: Jonny Saunders <sneakers-the-rat@protonmail.com>
Actually yno what would be a good idea is writing a specific test for that not happening. I can follow up with that. We should probably consider anything that is specifically touched within induced slot worthy of close testing, since almost more than any other method im aware of, if it is doing unexpected things the whole everything could break |
Thank you!! will you make a PR for this? i'll be happy to review it 😁 once that patch is ready to go, we can merge this PR in first, and then the patch PR on linkml. |
Lets put that test over here, no? Since its a test of schemaview behavior? |
@sierra-moxon noticed that the example here: linkml/linkml#2224 (comment) has an override, can we change the test example so the range at the slot level uses |
Fixes linkml/linkml#2224
There are 3 ways in which we could have written
linkml-runtime/linkml_runtime/utils/schemaview.py
Line 1376 in 798591b
if v2:
if v2 is not None and ((isinstance(v2, (dict, list)) and v2) or (isinstance(v2, JsonObj) and as_dict(v2))):
if not is_empty(v2):
Definition of
is_empty()
linkml-runtime/linkml_runtime/utils/formatutils.py
Lines 112 to 121 in 798591b