Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@cmungall
Copy link
Member

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

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

Co-Authored-By: Claude [email protected]

…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
Copy link

codecov bot commented Oct 17, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 83.95%. Comparing base (86e9c5f) to head (f95345f).
⚠️ Report is 11 commits behind head on main.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

cmungall and others added 8 commits October 17, 2025 13:27
- 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]>
Copy link
Contributor

@amc-corey-cox amc-corey-cox left a 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.

@amc-corey-cox
Copy link
Contributor

@cmungall just let me know if it's okay to remove those print statements and I'll do so and get this merged.

@cmungall
Copy link
Member Author

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

Copy link
Contributor

@amc-corey-cox amc-corey-cox left a 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.

@amc-corey-cox amc-corey-cox merged commit 0e914a7 into main Oct 21, 2025
23 checks passed
@amc-corey-cox amc-corey-cox deleted the owlgen-pv-options branch October 21, 2025 15:39
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