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

Added fix for adding annotations that are not strings in ontodoc #512

Merged

Conversation

francescalb
Copy link
Collaborator

@francescalb francescalb commented Dec 12, 2022

Furthermore, reenabled test for ontodoc. This is still a minimal test, but I think it can be gradually expanded.

Lastly - because a new altLabel was added in the testontology, it was reveiled that the same entity is returned twice in get_by_label_all in test_prefix. Issue #511 was made bacause of this.

Description:

Type of change:

  • Bug fix.
  • New feature.
  • Documentation update.

Checklist:

This checklist can be used as a help for the reviewer.

  • Is the code easy to read and understand?
  • Are comments for humans to read, not computers to disregard?
  • Does a new feature has an accompanying new test (in the CI or unit testing schemes)?
  • Has the documentation been updated as necessary?
  • Does this close the issue?
  • Is the change limited to the issue?
  • Are errors handled for all outcomes?
  • Does the new feature provide new restrictions on dependencies, and if so is this documented?

Comments:

Furthermore, reenabled test for ontodoc. This is still aminimal test,
but I think can be gradually expanded.

Lastlt - because a new altLabel was added in the testontology, it was revieled that
the same entity is returned twice in by get_by_label_all in test_prefix. Issue #511 was
made bacause of this.
@francescalb francescalb linked an issue Dec 12, 2022 that may be closed by this pull request
@codecov-commenter
Copy link

codecov-commenter commented Dec 13, 2022

Codecov Report

Merging #512 (9d29601) into master (6bba50d) will increase coverage by 2.38%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master     #512      +/-   ##
==========================================
+ Coverage   63.08%   65.46%   +2.38%     
==========================================
  Files          16       16              
  Lines        3080     3081       +1     
==========================================
+ Hits         1943     2017      +74     
+ Misses       1137     1064      -73     
Impacted Files Coverage Δ
ontopy/ontodoc.py 66.33% <100.00%> (+14.63%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

ontopy/ontodoc.py Outdated Show resolved Hide resolved
@@ -288,6 +288,7 @@ def itemdoc(
annotations.keys(), key=lambda key: order.get(key, key)
):
for value in annotations[key]:
value = str(value)
Copy link
Collaborator

Choose a reason for hiding this comment

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

This could fail, I suppose, if the type of value cannot be cast to a str type.
You could instead wrap it in a try/except block, where you're catching TypeError and ValueError exceptions, re-raising them with an appropriate custom message?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I discussed this with @jesper-friis , and we can't really see a situation in which this not enough. I think it is better to leave it as is, and update this if and when we find examples of situations in which a different handling is needed.

Copy link
Collaborator

Choose a reason for hiding this comment

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

As you wish. Casting to str is in general quite generous in this case, so it's fine I suppose. However, I'd argue it's good convention to consider possible edge cases and try to catch them if possible so exception messages are clear and helpful.

@francescalb francescalb merged commit d4ffbfe into master Dec 14, 2022
@francescalb francescalb deleted the 510-ontodoc-adding-annotations-that-are-not-strings-fail branch December 14, 2022 13:04
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.

ontodoc: adding annotations that are not strings fail
3 participants