Skip to content

auto-resolve controllers, use _raw_dict for cast#19

Merged
simontaurus merged 4 commits into
mainfrom
dev
May 11, 2026
Merged

auto-resolve controllers, use _raw_dict for cast#19
simontaurus merged 4 commits into
mainfrom
dev

Conversation

@simontaurus
Copy link
Copy Markdown
Contributor

- Add _controller_types registry alongside _types (v1 + v2)
- Controllers registered via metaclass on class definition
- resolve_type(): if exactly 1 controller for a type IRI, return it
- If >1 controllers: log info with available options, return pure model
- If controller construction fails: warn and fall back to pure model
- Enables: OpcUaServer[iri] returns controller instance directly
…tattr__

All controllers inherit private attr handling, no need for
per-mixin __setattr__ overrides.
- _raw_dict(): serialize object tree preserving inline objects at all
  depths. IRI-only fields included as strings. Replaces
  super().dict() + _recursive_object_to_iri(preserve_inline) in cast.
- cast() and __init__: use _raw_dict for reliable nested object
  preservation through reconstruction
- BaseController.__setattr__: route private attrs via object.__setattr__
- BaseController.to_jsonld: use strip approach (consistent with to_json)
- Remove _cast_to_pure (unused), remove preserve_inline parameter
- _controller_types registry, resolve_type, auto-resolution
Try Pydantic's __setattr__ first, catch ValueError/AttributeError
and warn the user to declare the field properly or use _private name.
@github-actions
Copy link
Copy Markdown
Contributor

📊 Benchmark Results

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

➖ Unchanged (within threshold):
  ➖ test_simple_dict_document_store: 0.0016s → 0.0016s (+0.5%)
  ➖ test_sqlite_document_store: 0.0017s → 0.0018s (+5.7%)
  ➖ test_local_sparql_store: 0.0369s → 0.0368s (-0.3%)
  ➖ test_oneof_subschema: 0.0518s → 0.0509s (-1.6%)
  ➖ test_enum_docstrings: 0.0419s → 0.0468s (+11.7%)
  ➖ test_subclass_inheritance: 0.0456s → 0.0450s (-1.4%)
  ➖ test_class_hierarchy: 0.0438s → 0.0477s (+8.9%)
  ➖ test_core[v1]: 0.0372s → 0.0329s (-11.5%)
  ➖ test_core[v2]: 0.0394s → 0.0399s (+1.2%)
  ➖ test_schema_generation[v1]: 0.0017s → 0.0017s (+2.9%)
  ➖ test_schema_generation[v2]: 0.0029s → 0.0029s (+1.2%)
  ➖ test_simple_json: 0.0007s → 0.0007s (+2.7%)
  ➖ test_complex_graph: 0.0015s → 0.0015s (+1.3%)

============================================================
Summary: 0 regressions, 0 improvements, 13 unchanged
============================================================

✅ No significant performance regressions

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 9a61e53 into main May 11, 2026
10 checks passed
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