Skip to content

feat(gen-owl): honor instantiates on emitted schema resources - #4171

Open
jdsika wants to merge 1 commit into
linkml:mainfrom
ASCS-eV:feat/owlgen-permissible-value-instantiates
Open

jdsika wants to merge 1 commit into
linkml:mainfrom
ASCS-eV:feat/owlgen-permissible-value-instantiates

Conversation

@jdsika

@jdsika jdsika commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Summary

gen-owl ignored instantiates. It now asserts each declared membership as rdf:type on the emitted resource of the schema, a class, a slot, a locally emitted type, an enum or a non-literal permissible value.

enums:
  LinkCategory:
    implements: [owl:NamedIndividual]
    permissible_values:
      isLicense:
        meaning: ex:isLicense
        instantiates: [vocab:LicenseCategory]
ex:isLicense a owl:NamedIndividual, ex:LinkCategory, vocab:LicenseCategory .
vocab:LicenseCategory a owl:Class .
  • The membership types the element itself, not its data instances: no rdfs:subClassOf, no inherited slots (instantiation guide). An enum of named individuals keeps its own owl:oneOf; the external class stays open.
  • Skipped with a warning: a permissible value rendered as a literal, which can't be a subject; a resource in the OWL 2 reserved vocabulary, such as a type emitted as xsd:integer, which can't be an individual (Structural Specification §2.4); and a value that is neither a CURIE nor an IRI, which would become a relative IRI.
  • With use_native_uris=False the assertion goes on the class_uri resource, like every other axiom about the element.
  • The instantiated class is declared as owl:Class, since OWL 2 DL requires a declaration for every class a class assertion uses (§5.8.1). An OWLAPI 5.5.0 profile check of the output flagged the missing declaration.

Why

The specification (05validation.md, annotation validation) defines instantiates as a uriorcurie "that references a class that serves as a metamodel extension class". #153 asked for a way to make "instances of linkml classes … OWL classes" and was closed with "The metamodel now has instantiates". In OWL's RDF mapping a class assertion is rdf:type (OWL 2 Mapping to RDF). No new option: the schema already states the relationship.

Other generators

gen-rdf and gen-jsonld serialize the schema as metamodel data and keep linkml:instantiates, as an xsd:anyURI literal holding the CURIE, as for every uriorcurie metaslot. JSON Schema and SHACL describe data instances, which the element's metaclass doesn't type.

How was this tested?

test_owlgen.py: several memberships, minted and explicit IRIs, permissible values as individuals and as classes, every element kind with both metaclasses and type_objects values, both URI modes, the three skip cases, and gen-rdf versus gen-owl. 123 passed locally; CI on the head.

Areas of uncertainty

  • Punning under --no-metaclasses: rdf:type on a class, slot or type puns the IRI as an individual even with --no-metaclasses, the default, which keeps LinkML's own metamodel types out. OWL 2 DL permits this punning (Metamodeling), and instantiates is the author's own statement, so it is honoured regardless. Is that the reading you want, or should explicit memberships follow --metaclasses too?

Fork review: ASCS-eV#31.

Checklist

  • My code follows the contributor guidelines
  • I have added tests that prove my fix/feature works
  • Existing tests pass locally with my changes

AI Assistance

If you used AI tools while preparing this PR, you are still the author and responsible for understanding, verifying, and defending your submission. Please engage with reviewers personally rather than through your agent during feedback and revisions. See our AI Covenant for details.

@codecov

codecov Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 94.44444% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 84.86%. Comparing base (a1593d1) to head (d612aea).

Files with missing lines Patch % Lines
packages/linkml/src/linkml/generators/owlgen.py 94.44% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4171      +/-   ##
==========================================
+ Coverage   81.62%   84.86%   +3.24%     
==========================================
  Files         162      162              
  Lines       20518    20535      +17     
  Branches     4366     4371       +5     
==========================================
+ Hits        16748    17428     +680     
+ Misses       2876     2169     -707     
- Partials      894      938      +44     
Flag Coverage Δ
linkml 81.63% <94.44%> (+0.02%) ⬆️
runtime 81.61% <94.44%> (+0.02%) ⬆️

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

☔ View full report in Codecov by Harness.
📢 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.

Translate explicit instantiates declarations to rdf:type on the emitted
schema resource through one shared helper. Apply the mapping consistently
to schemas, classes, slots, types, enums, and non-literal permissible values.
Literal permissible values cannot be RDF subjects and produce a warning.

Membership types the schema element itself, not its ordinary data instances,
and does not become subclass inheritance. Existing enum representation and
OWL class/individual punning remain intact. No additional flag is needed
because the schema already declares the relationship.

Cover CURIEs, absolute and minted IRIs, literal values, representation modes,
and the distinction between gen-rdf metamodel serialization and gen-owl
ontology assertions. Document the LinkML and OWL specification references.

A resource in the OWL 2 reserved vocabulary (Structural Specification
section 2.4), such as a type emitted as xsd:integer without type objects,
cannot be an OWL 2 DL individual; its instantiates is not asserted, with
a warning. A value that is neither a CURIE nor an IRI would become a
relative IRI and is skipped with a warning too.

The instantiated class is declared as owl:Class, since OWL 2 DL requires a
declaration for every class a class assertion uses (section 5.8.1).

Signed-off-by: jdsika <carlo.van-driesten@vdl.digital>
@jdsika
jdsika force-pushed the feat/owlgen-permissible-value-instantiates branch from 1aca117 to d612aea Compare October 23, 2026 14:24

This branch has not been deployed

No deployments
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.

1 participant