Skip to content

Conversation

@benjeffery
Copy link
Member

Partial work for #1073 on the struct side.

@codecov
Copy link

codecov bot commented Jan 15, 2021

Codecov Report

Merging #1116 (8ccb607) into main (e1eef38) will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #1116   +/-   ##
=======================================
  Coverage   93.70%   93.70%           
=======================================
  Files          26       26           
  Lines       21050    21065   +15     
  Branches      894      899    +5     
=======================================
+ Hits        19724    19739   +15     
  Misses       1289     1289           
  Partials       37       37           
Flag Coverage Δ
c-tests 92.49% <ø> (ø)
lwt-tests 92.80% <ø> (ø)
python-c-tests 94.86% <100.00%> (+<0.01%) ⬆️
python-tests 98.64% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
python/tskit/metadata.py 98.60% <100.00%> (+0.07%) ⬆️

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 e1eef38...8ccb607. Read the comment docs.

Copy link
Member

@jeromekelleher jeromekelleher 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. I think we should validate the schema at construction time, though, so raise an error if MetadataSchema(schema) is called with conflicting required/default values.

exceptions.MetadataSchemaValidationError,
match="Optional property 'int' must have a default value",
):
self.encode(schema, {"float": 5.5})
Copy link
Member

Choose a reason for hiding this comment

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

This should be raised when we create the schema rather than when encoding data I think? (probably is, but the test should reflect this)

Copy link
Member Author

Choose a reason for hiding this comment

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

Modified test to just create schema, the schema was where the error was already being rasied.

prop
for prop, sub_schema in ret.get("properties", {}).items()
if "default" not in sub_schema
]
Copy link
Member

Choose a reason for hiding this comment

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

Can check here if any properties that don't have a default are in required too.

Copy link
Member Author

Choose a reason for hiding this comment

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

That's checked on line 174

@benjeffery
Copy link
Member Author

@jeromekelleher Should be good to go now

@mergify mergify bot merged commit b6cee42 into tskit-dev:main Jan 18, 2021
@benjeffery benjeffery deleted the struct-default branch January 20, 2021 01:11
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.

2 participants