Open joeflack4 opened 6 months ago
I agree with this, but isnt this going to be print the same number of rows?
What about truncating the output and only print the first 10 cases, and then saying "There are 1230 similar ones, omitted for brevity"?
Same number of rows, but text reduced by like 1/3 or so because it won't print the warning message for each line.
I think printing such a sample is also a good idea. Could change behavior to print some / all based on verbosity settings, or save more to a logfile, at some point in the future.
I explored catching the warnings and basically it will require a huge amount of refactoring, because the warning is written a few methods down from where I could collect the erroneous mappings, and that method is called in dozens of places.
in #502 I have
What do you think?
Wow you got right to this. Yeah I think this seems pretty good!
Overview
I noticed recently that sometimes warnings are overly verbose. For example, sometimes for a given type of warning, it prints a full warning for each instance of an offending class or mapping, rather than printing some text about the type of warning and then providing a concise list of all the offending cases.
Current behavior
Example
In [my instance](https://github.com/monarch-initiative/mondo-ingest/pull/412#discussion_r1493469285), this warning repeated 100's of times, each time with a different mapping object, but the same error message. Here's what it looks like with just 3 entries (the latter 2 are fake / just examples). ``` WARNING:sssom.parsers:One mapping in the mapping set is not well-formed, and therfore not included in the mapping set ({'mapping_justification': 'semapv:UnspecifiedMatching', 'subject_id': 'Orphanet:3080', 'predicate_id': 'oboInOwl:hasDbXref', 'subject_label': 'Intellectual disability, Wolff type'}). Error: object_id must be supplied WARNING:sssom.parsers:One mapping in the mapping set is not well-formed, and therfore not included in the mapping set ({'mapping_justification': 'semapv:UnspecifiedMatching', 'subject_id': 'Orphanet:3081', 'predicate_id': 'oboInOwl:hasDbXref', 'subject_label': 'LABEL'}). Error: object_id must be supplied WARNING:sssom.parsers:One mapping in the mapping set is not well-formed, and therfore not included in the mapping set ({'mapping_justification': 'semapv:UnspecifiedMatching', 'subject_id': 'Orphanet:3082', 'predicate_id': 'oboInOwl:hasDbXref', 'subject_label': 'LABEL'}). Error: object_id must be supplied ```
Suggested behavior
Example
``` WARNING:sssom.parsers:Non well-formed mappings detected in mapping set, and therefore were excluded. Error: object_id must be supplied Offending mappings: ({'mapping_justification': 'semapv:UnspecifiedMatching', 'subject_id': 'Orphanet:3080', 'predicate_id': 'oboInOwl:hasDbXref', 'subject_label': 'Intellectual disability, Wolff type'}). ({'mapping_justification': 'semapv:UnspecifiedMatching', 'subject_id': 'Orphanet:3081', 'predicate_id': 'oboInOwl:hasDbXref', 'subject_label': 'LABEL'}). ({'mapping_justification': 'semapv:UnspecifiedMatching', 'subject_id': 'Orphanet:3082', 'predicate_id': 'oboInOwl:hasDbXref', 'subject_label': 'LABEL'}). ```
Additional details
Related
549