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

Add --copy-annotation option to ontoconvert #732

Merged
merged 7 commits into from
Mar 16, 2024
Merged

Conversation

jesper-friis
Copy link
Collaborator

Description

This option is needed to automatically rdfs:label annotations to classes and properties when publishing EMMO to increase the FAIRness or the ontology.

Type of change

  • Bug fix.
  • New feature.
  • Documentation update.
  • Test 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

@jesper-friis jesper-friis marked this pull request as draft March 14, 2024 07:08
Copy link

codecov bot commented Mar 14, 2024

Codecov Report

Attention: Patch coverage is 88.88889% with 2 lines in your changes are missing coverage. Please review.

Project coverage is 72.21%. Comparing base (91c20c5) to head (4ea6ce8).

Files Patch % Lines
ontopy/utils.py 88.88% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #732      +/-   ##
==========================================
+ Coverage   72.12%   72.21%   +0.08%     
==========================================
  Files          17       17              
  Lines        3444     3462      +18     
==========================================
+ Hits         2484     2500      +16     
- Misses        960      962       +2     

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

@jesper-friis jesper-friis marked this pull request as ready for review March 14, 2024 10:00
ontopy/utils.py Outdated
Comment on lines 841 to 843
"""In all classes and properties in `onto`, copy annotation `src` to `dst`.

The `src` and `dst` can either be provided as a label string or a full IRI.
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we should document with "Parameters" of "Arguments", as this renders nicely in the docementaion

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

Comment on lines +845 to +846
if onto.world[src]:
src = onto.world[src]
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why check in world?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Because we want to support src of the form http://www.w3.org/2004/02/skos/core#prefLabel

Comment on lines +855 to +856
if "://" not in dst:
raise ValueError(
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we should have tests for errors that we expect may happen.

Copy link
Collaborator Author

@jesper-friis jesper-friis Mar 14, 2024

Choose a reason for hiding this comment

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

Isn't this such a test? True, there might exists invalid IRIs that contain "://", but this easy and covers most of all error cases. The rest will raise an exception from owlready2 when trying to create a new annotation property.

What other errors would you expect?

ontopy/utils.py Outdated
Comment on lines 860 to 863
name = min(dst.rsplit("#")[-1], dst.rsplit("/")[-1])
iri = dst
dst = onto.new_annotation_property(name, owlready2.AnnotationProperty)
dst.iri = iri
Copy link
Collaborator

Choose a reason for hiding this comment

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

Needs test

Copy link
Collaborator Author

@jesper-friis jesper-friis Mar 14, 2024

Choose a reason for hiding this comment

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

This is already tested in tests/tools/test_ontoconvert.py

Just codecov that doesn't recognise tests done in subprocesses...

@@ -39,3 +39,18 @@ def test_run() -> None:
assert re.search("@prefix : <https://w3id.org/ex/testonto#>", output2)
assert re.search("<https://w3id.org/ex/testonto> .* owl:Ontology", output2)
assert re.search("testclass .* owl:Class", output2)

# Test 3 - copy-annotation
Copy link
Collaborator

Choose a reason for hiding this comment

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

you are checking copy_preflabel. I agree that this is an alias for annotation, but I think it would be good to check that other annotations also are added. Most particularly, that we can copy to an annotation that is originally not in the ontology.

Also, I think we should have a test where preflabel is not converted, as prefLabel is copied by default (if I understand store_true correctly).

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

rdfs:label is not in the ontology, so we are actually creating a new annotation.

Ok, added new test with src="prefLabel" .

Copy link
Collaborator

@francescalb francescalb left a comment

Choose a reason for hiding this comment

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

Nice

@jesper-friis jesper-friis merged commit a160921 into master Mar 16, 2024
12 checks passed
@jesper-friis jesper-friis deleted the convert-label branch March 16, 2024 07:21
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