Skip to content
This repository was archived by the owner on Apr 16, 2026. It is now read-only.

Proposed fix for issue #718#168

Merged
cmungall merged 2 commits into
mainfrom
dataclass_update
Apr 29, 2022
Merged

Proposed fix for issue #718#168
cmungall merged 2 commits into
mainfrom
dataclass_update

Conversation

@hsolbrig

Copy link
Copy Markdown
Contributor

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.

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:
```python
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.
@hsolbrig hsolbrig requested a review from cmungall April 28, 2022 21:12
@hsolbrig hsolbrig marked this pull request as draft April 28, 2022 21:23
@cmungall

Copy link
Copy Markdown
Member

linkml/linkml#718

Reduce the chance of unintended namespace collisions
@codecov-commenter

codecov-commenter commented Apr 28, 2022

Copy link
Copy Markdown

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%) ⬆️
linkml_runtime/utils/dataclass_extensions_376.py 100.00% <100.00%> (+82.64%) ⬆️
linkml_runtime/utils/schemaview.py 84.49% <100.00%> (+0.23%) ⬆️
linkml_runtime/utils/schemaops.py 72.00% <0.00%> (-8.44%) ⬇️
linkml_runtime/dumpers/rdf_dumper.py 69.23% <0.00%> (-2.57%) ⬇️
linkml_runtime/utils/namespaces.py 69.81% <0.00%> (ø)
linkml_runtime/utils/eval_utils.py 75.53% <0.00%> (+2.12%) ⬆️
linkml_runtime/utils/yamlutils.py 75.21% <0.00%> (+2.56%) ⬆️

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.

@hsolbrig hsolbrig marked this pull request as ready for review April 28, 2022 22:39
@cmungall cmungall merged commit 23f2fb6 into main Apr 29, 2022
@cmungall cmungall deleted the dataclass_update branch April 29, 2022 01:07
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants