Repository navigation
Cleanup metadata.py - #526
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #526 +/- ##
==========================================
+ Coverage 74.09% 74.35% +0.26%
==========================================
Files 18 18
Lines 1733 1735 +2
==========================================
+ Hits 1284 1290 +6
+ Misses 449 445 -4
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
c99e052 to
6d647d9
Compare
| yield key.strip(), value.strip() | ||
|
|
||
|
|
||
| @dataclass |
There was a problem hiding this comment.
These dataclasses were just moved up
696163e to
8863d4a
Compare
8863d4a to
c033e03
Compare
|
@edan-bainglass this is still a draft because I want to add a bunch of tests, but could you please review? Also, could you try initiating a review from copilot, I am curious. Note, this is just a refactor PR. In a follow-up I'd like to improve the citations parsing / validation. |
|
Hmm, there may be a regression after all. Have a closer look at the change from |
20da719 to
42b86a0
Compare
| yield "categories", categories | ||
|
|
||
| citations = aiidalab.get("citations", metadata_pep426.get("citations")) | ||
| citation_string = aiidalab.get("citations", metadata_pep426.get("citations")) |
There was a problem hiding this comment.
citations field is specific to AiiDAlab, I don't think we should be trying to read it from metadata table (setuptools would probably not be happy with that). I'll fix this in a separate PR.
So this was more subtle and took me a while to disentagle. I don't think the original code handled the case of no setup.cfg, it would raise TypeError because the returned empty dict was being passed to the Metadata constructor, and "title" and "description" fields are not optional. I've had Claude to write a bunch of unit tests, and then I ran them on main branch to ensure they pass, and fixed things accordingly. We now do raise a The new tests also uncovered some strange edge cases which I don't think are handled correctly, but I'll handle them in follow-up PRs. @edan-bainglass please take a look. |
There was a problem hiding this comment.
Thanks @danielhollas! This is very nice! Better typing, metadata parsing/validation, and exception handling (e.g., missing config file). I truly hope this is the last we here of this part of the code for some time (other than the already stacked #540) 😅
|
Hi @danielhollas. Sorry, having a closer look at this as a reference for another matter, and I'm noticing that the citation dataclasses are no longer being used in the code? Is this correct? I see that they are still used for validation in the schemas. Could you clarify? 🙂🙏 |
|
What do you mean by "no longer"? They were not used even before this PR --- this is what I was mentioning that the citations are not being validated when read from setup.cfg. the schema validation only happens during registry build (afaik). I will fix this in a follow up, hopefully today. |
Sorry, yes, Not "no longer" 😅 They were used only to generate the schemas, which remains now. But as a validation in the code itself. I was under the impression that was part of the work. But if this is reserved for a follow up, or clearly deemed as not required, no problem 🙂 |
A bit of a refactor of
metadata.py, mostly for the purpose of better type safety (utilizing MetadataDict type more).