Skip to content

[review] Add --exclude-metaslot option to gen-owl - #74

Open
wkp-admin wants to merge 1 commit into
mainfrom
review/4297-owlgen-exclude-metaslot
Open

wkp-admin wants to merge 1 commit into
mainfrom
review/4297-owlgen-exclude-metaslot

Conversation

@wkp-admin

@wkp-admin wkp-admin commented Nov 27, 2026 •

Copy link
Copy Markdown
Collaborator

Review copy of linkml#4297 by matentzn, same head (97285f59f). Review comments for jdsika go here first; what holds up is carried to the upstream PR.

The description below is the one on linkml#4297.

gen-owl --exclude-metaslot NAME (repeatable) leaves the values of a metamodel slot out of the element metadata, e.g. --exclude-metaslot from_schema drops skos:inScheme from every class and property. It applies to classes, slots, types, enums, permissible values and the ontology header; the annotation property declaration of an excluded predicate goes with it, and annotations: are not affected. An unknown name is an error. The default output does not change.

The docs also point to --ontology-uri-suffix "" for the skos:inScheme target not matching the ontology IRI.

Refs linkml#3549

Leaves the values of the named metamodel slots out of the element
metadata, e.g. --exclude-metaslot from_schema drops skos:inScheme.
Default output is unchanged; unknown names are an error.

Closes linkml#3549

@wkp-admin wkp-admin left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Review of linkml#4297. The change is small and in the right place: the one guard in add_metadata covers classes, slots, enums, permissible values and the header, and the annotation-property declaration disappears with it because _declare_annotation_properties derives declarations from the predicates in use. The default output is unchanged. Locally the 8 new tests pass and upstream CI is green.

The three points below are non-blocking. I checked each one by running the generator on this head (97285f59f):

  1. Types are named but have no metadata to exclude. add_type never calls add_metadata, so a type's title/description is not written with either type_objects setting. The docstring and the docs list types anyway.
  2. Some valid metaslot names do nothing. The check accepts every metamodel slot. A slot mapped into linkml: (e.g. is_a, slots) or a class-ranged one is never written, so --exclude-metaslot is_a passes the check and has no effect.
  3. A bare string is split into characters in the Python API. exclude_metaslots="from_schema" becomes frozenset of single characters, and the error lists _, a, c, e, f, ....

The test gap is small: test_exclude_applies_to_every_element covers a permissible value but not the enum node itself.

"""Names of metamodel slots whose values are left out of the element metadata.

For example ``["from_schema"]`` leaves out ``skos:inScheme`` on every class and
property. This applies to the metadata of classes, slots, types, enums, permissible

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

add_type does not call add_metadata, so types carry no dcterms:title/skos:definition with type_objects on or off. I checked a type with title and description and got neither triple. Suggest dropping "types" here and in docs/generators/owl.rst:131 (and in the PR description), so nobody expects this option to do something for types. Whether types should get metadata is a separate issue.

if self.xsd_anyuri_as_iri is not None:
deprecation_warning(XSD_ANYURI_AS_IRI_OPTION, stack_level=4)
self.exclude_metaslots = frozenset(self.exclude_metaslots)
unknown = self.exclude_metaslots - set(self.metamodel_schemaview.all_slots())

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Two small points about this check:

  • It accepts every metamodel slot, but add_metadata writes only the slots mapped outside linkml: with a non-class range. exclude_metaslots=["is_a", "slots"] passes and does nothing. That goes against the intent "an unknown name is an error, not a silent no-op". You could either check against the slots that can actually be written, or document that slots in the linkml: namespace are never written, so excluding them has no effect.
  • exclude_metaslots="from_schema" (a str is a valid Iterable[str]) is split into characters: ValueError: Not metamodel slots, cannot exclude: _, a, c, e, f, h, m, o, r, s. A one-line guard, if isinstance(self.exclude_metaslots, str): self.exclude_metaslots = [self.exclude_metaslots], or a clearer error would fix it. The CLI is not affected, because multiple=True always passes a tuple.

[
URIRef(EX + "Person"),
URIRef(EX + "age"),
URIRef(EX + "Colour#red"),

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Nit: the docs list enums, but only the permissible value is covered here. Adding URIRef(EX + "Colour") would need a title/description on Colour in SCHEMA.

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