Skip to content

Commit

Permalink
Prevent naming collisions with native qcodes attributes.
Browse files Browse the repository at this point in the history
This commit adapts the node tree generation to append a tailing
underscore to parameter names that colided with native qcodes
attribute on the Instrument/Node classes. Since QCoDes simply
ignores attempts to add colliding names and just raises a
warning, this change is not breaking.

Currently only the name `log` from `/zi/debug/log` is colliding
but this fix also works for future collisions.
  • Loading branch information
tobiasah committed Sep 12, 2024
1 parent ea32c28 commit 8f841b1
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# zhinst-qcodes Changelog

## Version 0.5.4
* Fix issue that cause node names to collide with native attributes. (`/zi/debug/log`
collided with the native log attribute on Nodes)

## Version 0.5.3
* Added `py.typed` type information marker file (`#63`).

Expand Down
18 changes: 12 additions & 6 deletions src/zhinst/qcodes/qcodes_adaptions.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Base modules for the Zurich Instrument specific QCoDeS driver."""

import re
from datetime import datetime
import typing as t
Expand Down Expand Up @@ -707,18 +708,23 @@ def init_nodetree(
and "Read" in info.get("Properties")
and not any(x in node.raw_tree for x in snapshot_blacklist)
)
name = name + "_" if hasattr(parent, name) else name
parent.add_parameter(
parameter_class=ZIParameter,
name=name,
docstring=info.get("Description"),
unit=info.get("Unit")
if info.get("Unit") not in ["None", "Dependent"]
else None,
unit=(
info.get("Unit")
if info.get("Unit") not in ["None", "Dependent"]
else None
),
get_cmd=node._get,
set_cmd=node._set,
vals=ComplexNumbers()
if re.match(is_complex, info.get("Node").lower())
else None,
vals=(
ComplexNumbers()
if re.match(is_complex, info.get("Node").lower())
else None
),
snapshot_value=do_snapshot,
snapshot_get=do_snapshot,
zi_node=info.get("Node"),
Expand Down

0 comments on commit 8f841b1

Please sign in to comment.