linkml / linkml-runtime

Runtime support for linkml generated models
https://linkml.io/linkml/
Creative Commons Zero v1.0 Universal
25 stars 23 forks source link

Proposed fix for issue #718 #168

Closed hsolbrig closed 2 years ago

hsolbrig commented 2 years ago

The dataclasses package uses the built-in class signature detection to throw a TypeError if an unrecognized parameter is passed in a constructor. This: a) makes it difficult or impossible to print information about where the parameter came from in a yaml (other file) b) limits our options as to whether we go ahead and continue processing.

The current fix (prior to this submission) was overriding the _init_fn in the dataclasses library, which turned out to be anything but stable. This new fix, instead, tries to focus on the _create_fn, whose signature and behavior is considerably more stable.

IF this fix works, we want to proceed by changing the python generators to emit something like:

import linkml_runtime.utils.dataclass_extensions_376 as dc_tweak
# This line makes certain that the import remains
DC_IN = dc_tweak.DC_CREATE_FN

And, finally, renaming dataclass_extensions_376 to something more reasonable.

cmungall commented 2 years ago

https://github.com/linkml/linkml/pull/718

codecov-commenter commented 2 years ago

Codecov Report

Merging #168 (a4c5e2d) into main (482a7c2) will increase coverage by 1.41%. The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main     #168      +/-   ##
==========================================
+ Coverage   62.54%   63.95%   +1.41%     
==========================================
  Files          49       49              
  Lines        5219     5105     -114     
  Branches     1468     1394      -74     
==========================================
+ Hits         3264     3265       +1     
+ Misses       1593     1480     -113     
+ Partials      362      360       -2     
Impacted Files Coverage Δ
linkml_runtime/utils/context_utils.py 70.17% <100.00%> (+22.17%) :arrow_up:
linkml_runtime/utils/dataclass_extensions_376.py 100.00% <100.00%> (+82.64%) :arrow_up:
linkml_runtime/utils/schemaview.py 84.49% <100.00%> (+0.23%) :arrow_up:
linkml_runtime/utils/schemaops.py 72.00% <0.00%> (-8.44%) :arrow_down:
linkml_runtime/dumpers/rdf_dumper.py 69.23% <0.00%> (-2.57%) :arrow_down:
linkml_runtime/utils/namespaces.py 69.81% <0.00%> (ø)
linkml_runtime/utils/eval_utils.py 75.53% <0.00%> (+2.12%) :arrow_up:
linkml_runtime/utils/yamlutils.py 75.21% <0.00%> (+2.56%) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 0b83adc...a4c5e2d. Read the comment docs.