Skip to content

Commit

Permalink
Merge branch 'main' into test_ZNLE
Browse files Browse the repository at this point in the history
  • Loading branch information
FKMalina authored Jan 15, 2025
2 parents 01ea456 + d06b5de commit 1a397fb
Show file tree
Hide file tree
Showing 12 changed files with 52 additions and 26 deletions.
2 changes: 1 addition & 1 deletion .github/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"devDependencies": {
"pyright": "1.1.391"
"pyright": "1.1.392"
}
}
8 changes: 4 additions & 4 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:

steps:
- name: Harden Runner
uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2
uses: step-security/harden-runner@c95a14d0e5bab51a9f56296a4eb0e416910cd350 # v2.10.3
with:
egress-policy: audit

Expand All @@ -39,12 +39,12 @@ jobs:

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@48ab28a6f5dbc2a99bf1e0131198dd8f1df78169 # v3.28.0
uses: github/codeql-action/init@b6a472f63d85b9c78a3ac5e89422239fc15e9b3c # v3.28.1
with:
languages: ${{ matrix.language }}

- name: Autobuild
uses: github/codeql-action/autobuild@48ab28a6f5dbc2a99bf1e0131198dd8f1df78169 # v3.28.0
uses: github/codeql-action/autobuild@b6a472f63d85b9c78a3ac5e89422239fc15e9b3c # v3.28.1

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@48ab28a6f5dbc2a99bf1e0131198dd8f1df78169 # v3.28.0
uses: github/codeql-action/analyze@b6a472f63d85b9c78a3ac5e89422239fc15e9b3c # v3.28.1
2 changes: 1 addition & 1 deletion .github/workflows/dependency-review.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Harden Runner
uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2
uses: step-security/harden-runner@c95a14d0e5bab51a9f56296a4eb0e416910cd350 # v2.10.3
with:
egress-policy: audit

Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:
SPHINX_OPTS: "-v -j 2"
steps:
- name: Harden Runner
uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2
uses: step-security/harden-runner@c95a14d0e5bab51a9f56296a4eb0e416910cd350 # v2.10.3
with:
egress-policy: audit
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
Expand All @@ -63,7 +63,7 @@ jobs:
sudo apt install pandoc
if: runner.os == 'Linux'
- name: Install pandoc on windows
uses: Wandalen/wretry.action@ffdd254f4eaf1562b8a2c66aeaa37f1ff2231179 # v3.7.3
uses: Wandalen/wretry.action@e68c23e6309f2871ca8ae4763e7629b9c258e1ea # v3.8.0
with:
action: crazy-max/[email protected]
with: |
Expand Down Expand Up @@ -98,7 +98,7 @@ jobs:
./make.bat html
if: runner.os == 'Windows'
- name: Upload build docs
uses: actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b # v4.5.0
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4.6.0
with:
name: docs_${{ matrix.python-version }}_${{ matrix.os }}
path: ${{ github.workspace }}/docs/_build/html
Expand All @@ -113,7 +113,7 @@ jobs:
steps:

- name: Harden Runner
uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2
uses: step-security/harden-runner@c95a14d0e5bab51a9f56296a4eb0e416910cd350 # v2.10.3
with:
egress-policy: audit

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
steps:

- name: Harden Runner
uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2
uses: step-security/harden-runner@c95a14d0e5bab51a9f56296a4eb0e416910cd350 # v2.10.3
with:
egress-policy: audit

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pytest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ jobs:
steps:

- name: Harden Runner
uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2
uses: step-security/harden-runner@c95a14d0e5bab51a9f56296a4eb0e416910cd350 # v2.10.3
with:
egress-policy: audit

Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/scorecards.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:

steps:
- name: Harden Runner
uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2
uses: step-security/harden-runner@c95a14d0e5bab51a9f56296a4eb0e416910cd350 # v2.10.3
with:
egress-policy: audit

Expand Down Expand Up @@ -63,14 +63,14 @@ jobs:
# Upload the results as artifacts (optional). Commenting out will disable uploads of run results in SARIF
# format to the repository Actions tab.
- name: "Upload artifact"
uses: actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b # v4.5.0
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4.6.0
with:
name: SARIF file
path: results.sarif
retention-days: 5

# Upload the results to GitHub's code scanning dashboard.
- name: "Upload to code-scanning"
uses: github/codeql-action/upload-sarif@48ab28a6f5dbc2a99bf1e0131198dd8f1df78169 # v3.28.0
uses: github/codeql-action/upload-sarif@b6a472f63d85b9c78a3ac5e89422239fc15e9b3c # v3.28.1
with:
sarif_file: results.sarif
2 changes: 1 addition & 1 deletion .github/workflows/upload_to_pypi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
id-token: write
steps:
- name: Harden Runner
uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2
uses: step-security/harden-runner@c95a14d0e5bab51a9f56296a4eb0e416910cd350 # v2.10.3
with:
egress-policy: audit

Expand Down
3 changes: 3 additions & 0 deletions docs/changes/newsfragments/6722.improved
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
When passing ``bind_to_instrument=False`` to ``InstrumentBase.add_parameter`` a warning that
recommends not doing this is now raised suggesting a better alternative.
This replaces an existing inconsistent warning which was misleading.
18 changes: 9 additions & 9 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ click==8.1.8
# via
# dask
# towncrier
cloudpickle==3.1.0
cloudpickle==3.1.1
# via dask
colorama==0.4.6
# via
Expand Down Expand Up @@ -102,7 +102,7 @@ h5py==3.12.1
# qcodes-loop
hickle==5.0.3
# via qcodes-loop
hypothesis==6.123.7
hypothesis==6.123.17
# via qcodes (pyproject.toml)
idna==3.10
# via requests
Expand Down Expand Up @@ -169,7 +169,7 @@ kiwisolver==1.4.8
# via matplotlib
lazy-loader==0.4
# via qcodes-loop
libcst==1.5.1
libcst==1.6.0
# via qcodes (pyproject.toml)
locket==1.0.0
# via partd
Expand Down Expand Up @@ -302,7 +302,7 @@ pytest==8.3.4
# pytest-mock
# pytest-rerunfailures
# pytest-xdist
pytest-asyncio==0.25.1
pytest-asyncio==0.25.2
# via qcodes (pyproject.toml)
pytest-cov==6.0.0
# via qcodes (pyproject.toml)
Expand Down Expand Up @@ -361,9 +361,9 @@ ruamel-yaml-clib==0.2.12
# via ruamel-yaml
schema==0.7.7
# via broadbean
scipy==1.15.0
scipy==1.15.1
# via qcodes (pyproject.toml)
setuptools==75.7.0
setuptools==75.8.0
# via incremental
six==1.17.0
# via
Expand Down Expand Up @@ -457,7 +457,7 @@ types-pywin32==308.0.0.20241221
# via qcodes (pyproject.toml)
types-requests==2.32.0.20241016
# via qcodes (pyproject.toml)
types-setuptools==75.6.0.20241223
types-setuptools==75.8.0.20250110
# via qcodes (pyproject.toml)
types-tabulate==0.9.0.20241207
# via qcodes (pyproject.toml)
Expand Down Expand Up @@ -502,12 +502,12 @@ websockets==14.1
# qcodes
widgetsnbextension==4.0.13
# via ipywidgets
wrapt==1.17.0
wrapt==1.17.2
# via
# qcodes (pyproject.toml)
# deprecated
# qcodes
xarray==2025.1.0
xarray==2025.1.1
# via
# qcodes (pyproject.toml)
# cf-xarray
Expand Down
12 changes: 11 additions & 1 deletion src/qcodes/instrument/instrument_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,16 @@ def add_parameter(
if "bind_to_instrument" not in kwargs.keys():
kwargs["bind_to_instrument"] = True

bind_to_instrument = kwargs["bind_to_instrument"]

if bind_to_instrument is False:
warnings.warn(
f"Parameter {name} passed to `add_parameter` "
"on instrument {self.full_name} with `bind_to_instrument=False`. "
"This is not recommended as it results in inconsistent behavior. "
"To disable snapshotting of the parameter set `snapshot_exclude=True`."
)

try:
param = parameter_class(name=name, instrument=self, **kwargs)
except TypeError:
Expand All @@ -180,7 +190,7 @@ def add_parameter(
param = parameter_class(name=name, instrument=self, **kwargs)

existing_parameter = self.parameters.get(name, None)
if not existing_parameter:
if not existing_parameter and bind_to_instrument:
warnings.warn(
f"Parameter {name} did not correctly register itself on instrument"
f" {self.name}. Please check that `instrument` argument is passed "
Expand Down
13 changes: 13 additions & 0 deletions tests/parameter/test_parameter_registration.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,16 @@ def test_parameter_registration_with_non_kwargs_passing_parameter(
# (bind_to_instrument specifically)
# to the baseclass it will still be registered on the instr
assert "brokenparameter2" in dummy_attr_instr.parameters.keys()


def test_parameter_registration_bind_to_instrument_false(
dummy_attr_instr: DummyAttrInstrument,
) -> None:
with pytest.warns(UserWarning, match="passed to `add_parameter`"):
dummy_attr_instr.add_parameter(
name="non_binding_parameter",
set_cmd=None,
get_cmd=None,
bind_to_instrument=False,
)
assert "non_binding_parameter" not in dummy_attr_instr.parameters.keys()

0 comments on commit 1a397fb

Please sign in to comment.