-
Notifications
You must be signed in to change notification settings - Fork 134
Enhance OWL enum/permissible value handling and add comprehensive test coverage #2950
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
Conversation
…t coverage This commit improves the OWL generator's handling of permissible values and enums, with better type mapping support and comprehensive test coverage for different OWL representation strategies. ## Changes ### linkml/generators/owlgen.py - Add support for owl: and rdfs: prefixed default permissible value types in `_permissible_value_owl_type_for()` - Add metadata handling for enum definitions via `add_metadata()` call in `_add_enum()` - Add metadata handling for individual permissible value nodes when they are URIRefs - Improve type signature of `add_metadata()` to accept PermissibleValue objects - Add clarifying comment about non-null PV validation logic ### tests/test_generators/test_owlgen.py - Add comprehensive parameterized test `test_permissible_values()` covering: - Different default permissible value types (owl:Class, rdfs:Literal, owl:NamedIndividual) - Per-PV type overrides via implements field - Mixed URI/non-URI permissible value scenarios - Add detailed docstring documenting OWL mapping strategies and expected behaviors - Add PermissibleValueURIMixture enum for test parameterization - Test validates correct owl:unionOf vs owl:oneOf usage based on PV types ### linkml/utils/schema_builder.py - Fix bug in `add_enum()` where PermissibleValue objects weren't being added to enum definition ## Related Issues - Addresses TODO comments in owlgen.py lines 668, 929, 1186, 1205 regarding enum mapping - References #1841 for complex enum constraints The test suite now comprehensively validates that: - owl:Class permissible values generate owl:unionOf expressions with URIRef elements - rdfs:Literal permissible values generate owl:oneOf expressions with Literal elements - owl:NamedIndividual permissible values generate owl:oneOf expressions with URIRef elements - Mixed type scenarios work correctly or are skipped when undefined 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2950 +/- ##
==========================================
+ Coverage 80.11% 83.95% +3.84%
==========================================
Files 141 141
Lines 15828 15835 +7
Branches 3210 3212 +2
==========================================
+ Hits 12680 13295 +615
+ Misses 2479 1830 -649
- Partials 669 710 +41 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
- Fix import sorting to comply with ruff formatting rules - Break long line in pytest parametrize decorator to stay under 120 character limit 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
- Add proper blank lines between class definitions - Fix parametrize decorator formatting - Fix indentation and spacing in permissible_values list - Add blank line after Collection import - Remove trailing whitespace and fix end-of-file formatting 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
Replace modern union syntax (str | None) with typing.Union syntax to support Python 3.9 where the | operator for types was not yet available. - Add typing.Union import - Replace str | None | tuple[str, str] with Union[str, None, tuple[str, str]] - Update docstring to use Union syntax as well This fixes the TypeError: unsupported operand type(s) for |: 'type' and 'NoneType' error in Python 3.9 CI runs. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
The snapshots now include metadata (skos:definition, etc.) for enum definitions and permissible values, which is the expected behavior after the OWL generator enhancements in the previous commits. Changes reflect: - Addition of metadata properties for enum definitions - Addition of metadata properties for permissible value nodes (when URIRefs) - Proper skos:definition properties from enum and PV descriptions These changes improve the semantic richness of generated OWL output by preserving documentation and metadata from the LinkML schema. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
Add comprehensive documentation to owl.rst covering: - CLI options for controlling enum/permissible value generation - Schema-level annotations using `implements` for fine-grained control - Examples of enum-level vs per-PV control - OWL output patterns for different PV types (Class, NamedIndividual, Literal) - Mixed type enums and URI vs text-based representations - Advanced usage examples with external vocabularies The documentation now clearly explains: 1. How to use --default-permissible-value-type CLI option 2. How to use implements annotations at enum and PV level 3. The semantic differences between owl:unionOf vs owl:oneOf 4. How URIs/meanings affect the OWL representation 5. Advanced patterns for semantic web integration 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd like to remove these print statements if they aren't necessary. It might also be worthwhile to reduce the verbosity on the test doc-string but that is probably fine.
|
@cmungall just let me know if it's okay to remove those print statements and I'll do so and get this merged. |
|
go ahead and remove the prints, you can trim excess verbiage from the docstring but for nuanced combinatorial logic I favor n the side of exhaustiveness |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great! Thanks for the changes.
This commit improves the OWL generator's handling of permissible values and enums,
with better type mapping support and comprehensive test coverage for different
OWL representation strategies.
Changes
linkml/generators/owlgen.py
_permissible_value_owl_type_for()add_metadata()call in_add_enum()add_metadata()to accept PermissibleValue objectstests/test_generators/test_owlgen.py
test_permissible_values()covering:linkml/utils/schema_builder.py
add_enum()where PermissibleValue objects weren't being added to enum definitionRelated Issues
rangeand apatternresults in generated OWL that won't pass validation (like with jena riot, loading into a triplestore) #1841 for complex enum constraintsThe test suite now comprehensively validates that:
🤖 Generated with Claude Code
Co-Authored-By: Claude [email protected]