fix(neutral-atoms): fix channel serialization using QUAM reference strings#89
Open
sebastianorbell-qm wants to merge 1 commit intofeat/neutral_atomsfrom
Open
Conversation
…rings Channels were being registered in two places simultaneously — in BaseQuamNA._channels and inside AOD/Sensor as direct object references. QUAM enforces exclusive parent ownership, so json.dump failed with "Object of type SingleChannel is not JSON serializable". Fix by storing all channels exclusively in a root channels dict and having drivers/sensors reference them via QUAM path strings (channel.get_reference()), which are transparently resolved on access. Changes: - base_quam_na: _channels list → channels Dict[str, Channel]; add get_serialiser(); update register_channel()/get_channel() - aod: replace tuple annotation with channel_x/channel_y fields typed as SingleChannel (hold reference strings); fix enable/disable/move - sensor: fix channel type annotation DigitalOutputChannel → SingleChannel - ghz.py: register all channels before constructing drivers; use channel.get_reference() at call sites; fix save path; fix tuple arithmetic for position offset; fix typo initial_postion; remove stray nv_center import
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.
Summary
qpu.save()was failing withTypeError: Object of type SingleChannel is not JSON serializablebecause channels were being stored in two places in the QUAM hierarchy simultaneously (BaseQuamNA._channelsandAOD.channels/Sensor.channel). QUAM enforces exclusive parent ownership, so the duplicate reference could not be serialized.channels: Dict[str, Channel]dict and having drivers/sensors hold QUAM reference strings (channel.get_reference()) instead of direct object references. These strings are transparently resolved on attribute access via QUAM's built-in reference mechanism.AODfield annotations and method bodies, fixedSensorchannel type, cleaned upghz.py(save path, position arithmetic, stale import, typo).Test plan
python tests/neutral_atoms/GHZ/ghz.pycompletes without error and writesquam_state/state.jsonaod.channel_x/aod.channel_yresolve correctly toSingleChannelobjects at runtimeqpu.save()/BaseQuamNA.load()round-trip preserves all channel references