Skip to content

fix: register a class only under the type IRIs it introduces - #104

Merged
simontaurus merged 1 commit into
mainfrom
fix/register-only-own-cls-iri
Aug 6, 2026
Merged

fix: register a class only under the type IRIs it introduces#104
simontaurus merged 1 commit into
mainfrom
fix/register-only-own-cls-iri

Conversation

@simontaurus

Copy link
Copy Markdown
Contributor

Problem

get_cls_iri() may read a schema $id/iri, a uuid, or the default of the type field. All three are inherited: pydantic merges json_schema_extra from the base, and a subclass that only narrows a field keeps the base's type default. Such a subclass therefore reports its parent's IRI and, being defined later, replaced the parent in _types.

Observed with generated models where a default_unit override produces a narrowing subclass:

IRI resolved to (before)
Pressure ProductionGasPressureUpperLimit (default millibar)
Time DurationEqualizationAfterEvacuation
Temperature NominalTemperature...HeatingPlates
EvacuationProcessDocumentation EvacuationSubprocessDocumentation

Consequences: a data channel typed as Pressure resolved to a class whose default unit is millibar, so values converted to their base unit no longer matched the field default and serialization kept a redundant, non-canonical unit. Independently, loading a process documentation by IRI returned its subprocess class.

Change

Subtract the IRIs the base classes already report, so a class registers only the identity it introduces. The check stays generic: no assumption about how a hierarchy spells its identity, which keeps opensemantic's uuid convention out of oold.

Controllers are untouched: they are collected in a list and never shadow a data model.

Verification

  • the four IRIs above now resolve to Pressure, Time, Temperature, EvacuationProcessDocumentation
  • _types still holds 1081 entries and _controller_types 4, so no registration is lost
  • 95 passed, 2 skipped (uv run --group dev pytest, excluding the panel UI suite)
  • ruff check and ruff format clean

- get_cls_iri() reads a schema id, a uuid or the type default, all inherited,
  so a narrowing subclass replaced its parent in the type registry
- Pressure then resolved to a millibar subclass and the process documentation
  IRI to its subprocess class
- subtract the IRIs the bases already report; controllers are unaffected
@github-actions

github-actions Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Release preview

Merging this PR would release v0.16.4 (current: v0.16.3).

Changelog preview (truncated)
## v0.16.4 (2026-08-06)

### Bug Fixes

- Register a class only under the type IRIs it introduces
  ([`7ca1b85`](https://github.com/OO-LD/oold-python/commit/7ca1b85e37ed93ca2447ececfa11dc11a2265283))

### Chores

- License fix
  ([`daa8d8c`](https://github.com/OO-LD/oold-python/commit/daa8d8cfa325a3745c851c845b9fae7b5e51a0cc))

### Continuous Integration

- **release**: Add whats-changed notes with changelog link for zenodo
  ([`147d70f`](https://github.com/OO-LD/oold-python/commit/147d70fbf1c5da070f3cb9055fbe96e831fe8eaa))

- **release**: Update on title and authors
  ([`996c4de`](https://github.com/OO-LD/oold-python/commit/996c4dee6b4f07b6ec994e87cb341155a12e955c))

Preview via python-semantic-release and conventional commits.

@github-actions

github-actions Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

📊 Benchmark Results

Click to see benchmark comparison
📊 Benchmark Comparison (threshold: 1.3x)
============================================================

⚠️  Performance Regressions:
  ❌ test_subclass_inheritance: 0.0460s → 0.0733s (+59.4%, ratio: 1.59x)

➖ Unchanged (within threshold):
  ➖ test_simple_dict_document_store: 0.0015s → 0.0015s (+2.6%)
  ➖ test_sqlite_document_store: 0.0016s → 0.0016s (+0.1%)
  ➖ test_local_sparql_store: 0.0325s → 0.0324s (-0.5%)
  ➖ test_oneof_subschema: 0.0500s → 0.0543s (+8.5%)
  ➖ test_enum_docstrings: 0.0434s → 0.0533s (+23.0%)
  ➖ test_class_hierarchy: 0.0449s → 0.0443s (-1.2%)
  ➖ test_core[v1]: 0.0317s → 0.0346s (+9.3%)
  ➖ test_core[v2]: 0.0364s → 0.0367s (+0.7%)
  ➖ test_schema_generation[v1]: 0.0015s → 0.0015s (-1.4%)
  ➖ test_schema_generation[v2]: 0.0025s → 0.0025s (-1.7%)
  ➖ test_simple_json: 0.0006s → 0.0006s (-1.4%)
  ➖ test_complex_graph: 0.0013s → 0.0013s (+0.2%)

============================================================
Summary: 1 regressions, 0 improvements, 12 unchanged
============================================================

⚠️  Regressions detected but not failing build (informational only)

Threshold: 1.3x (30% slower triggers a regression warning)

Note: Benchmarks are informational only and won't fail the build.

💡 Tip: Download the benchmark-results artifact for detailed JSON data

@simontaurus
simontaurus merged commit 06852a2 into main Aug 6, 2026
19 checks passed
@codecov

codecov Bot commented Aug 6, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 91.66667% with 2 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/oold/model/__init__.py 91.6% 2 Missing ⚠️

📢 Thoughts on this report? Let us know!

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