fix: accept subchannel references as stored in the OSW backend - #7
Merged
Conversation
The schema defines subchannels as an array of strings picked from the sibling data_channels by osw_id, but the controller classes narrowed the field to a list of OpcUaDataChannel objects. Loading a server from the backend therefore failed validation with "value is not a valid dict". Widen the field to accept both forms and add OpcUaServerMixin.get_channel_by_osw_id(), used by the data change handler to resolve stored references before reading them.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The OSW schema defines
subchannelsas an array of strings picked from the siblingdata_channelsbyosw_id:Codegen honours that (
_model.py:subchannels: list[str] | None), but both controller classes narrowed the field back to a list ofOpcUaDataChannelobjects. Loading a server from the backend therefore failed:_handle_datachange_notificationcallsread_channels(subchannels), which needs.node_id, so objects are still required at runtime.Change
subchannelstoOptional[List[Union[str, "OpcUaDataChannel"]]]in both the v1 and v2 controllers, so stored references load and inline objects keep working.OpcUaServerMixin.get_channel_by_osw_id(), which searches self and all subdevices and accepts both the full subobject IRI (Item:OSW<tool>#OSW<channel>) and the bareOSW<channel>suffix._handle_datachange_notificationbefore reading them.These are same-page subobject references, not cross-page ones, so
range/__iris__is not the right mechanism here: its lazy resolver loads entities by IRI, and there is no page behindItem:OSWdev#OSWchan.Tests
6 new tests covering the IRI form, resolution across the subdevice hierarchy, the bare-suffix form, the unknown-id error, and a full serialize/reload/resolve round-trip. 47 pass in
test_controller.py; flake8 and black clean.Verified against live data: loading the vac-station hierarchy from the backend now yields 6 subdevices and 90 channels, with
event_name_ebg1.subchannelsresolving tons=4;i=1222andns=4;i=1230.