Skip to content
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

DM-42544: Add check for duplicate IDs when validating a schema #34

Merged
merged 4 commits into from Jan 23, 2024

Conversation

JeremyMcCormick
Copy link
Collaborator

@JeremyMcCormick JeremyMcCormick commented Jan 19, 2024

The function for building a map of IDs to objects was rewritten using a visitor pattern, as the old version using recursion was prone to error and not working consistently. Duplicates are added to a set as the schema is visited. The model_validator function will throw an error if any duplicates are found, which will include a complete list of all the duplicate IDs. The new implementation of the ID builder and duplicate check was tested by running on several sdm_schemas which are known to contain duplicate IDs (imsim, hsc). These will be fixed in a different ticket branch on sdm_schemas.

Copy link

codecov bot commented Jan 19, 2024

Codecov Report

Attention: 3 lines in your changes are missing coverage. Please review.

Comparison is base (3d5ace3) 92.71% compared to head (b1d7790) 92.58%.

Files Patch % Lines
python/felis/datamodel.py 91.42% 1 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #34      +/-   ##
==========================================
- Coverage   92.71%   92.58%   -0.14%     
==========================================
  Files          18       18              
  Lines        1923     1943      +20     
  Branches      381      381              
==========================================
+ Hits         1783     1799      +16     
- Misses         86       87       +1     
- Partials       54       57       +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

The function for creating the ID map was not working and was rewritten
to use a visitor pattern instead of recursion. Duplicates are added to
a set as the schema is visited. The model_validator will raise an error
if duplicates are found and print a complete list of the duplicated
IDs.
This was not checked before but validating a schema will always check
for duplicates now. A few duplicate IDs are fixed now that were used
unintentionally.
An error will be thrown if the object is not found.
Copy link

@gpdf gpdf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, covers an important missing bit in the current validation.

@JeremyMcCormick JeremyMcCormick merged commit 1088d39 into main Jan 23, 2024
9 of 10 checks passed
@JeremyMcCormick JeremyMcCormick deleted the tickets/DM-42544 branch January 23, 2024 01:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants