Skip to content

Use qcodes.dataset.get_db_overview when available#462

Merged
astafan8 merged 4 commits into
masterfrom
astafan8/qcodes-db-overview
Jul 3, 2026
Merged

Use qcodes.dataset.get_db_overview when available#462
astafan8 merged 4 commits into
masterfrom
astafan8/qcodes-db-overview

Conversation

@astafan8

@astafan8 astafan8 commented Jul 3, 2026

Copy link
Copy Markdown
Collaborator

Summary

The fast SQL database-overview implementation used by inspectr
(plottr.data.qcodes_db_overview.get_db_overview) has been upstreamed to
QCoDeS (see companion PR microsoft/Qcodes#8266).

This PR makes plottr prefer the QCoDeS implementation when it is available,
falling back to the local implementation for older QCoDeS versions that do not
yet expose qcodes.dataset.get_db_overview.

Changes

  • plottr/data/qcodes_db_overview.py
    • At import time, try from qcodes.dataset import get_db_overview; on
      ImportError (older QCoDeS) keep the local implementation.
    • The local implementation is generalized to match the upstreamed API:
      • accepts an optional existing conn in addition to path_to_db;
      • gains an extra_columns argument to pull ad-hoc metadata columns (e.g.
        inspectr_tag) into each overview entry, replacing the previously
        hard-coded inspectr_tag handling;
      • drops the sys.version_info read-only guard (plottr requires Python

        = 3.12) and uses datetime for timestamp formatting.

  • plottr/apps/inspectr.py
    • LoadDBProcess.loadDB now calls
      get_db_overview(self.path, extra_columns=['inspectr_tag']) so the
      inspectr_tag column is included regardless of which implementation is
      used.

Behaviour

The returned overview dict keys are unchanged, so inspectr behaves
identically whether the QCoDeS or the local implementation is used. Existing
tests (test/pytest/test_qcodes_data.py) exercise both the record-count
heuristics and the incremental refresh and continue to pass.

Verification

  • mypy plottr — clean.
  • pytest test/pytest/test_qcodes_data.py — 19 passed (including the
    inspectr refresh GUI test).

Verified against the currently released QCoDeS (0.58.0, which does not yet
expose get_db_overview, so the fallback path is exercised) as well as a stub
confirming the upstream path shadows the local implementation when present.


Note

This pull request was created by an agent on behalf of @astafan8.

The fast SQL database-overview implementation has been upstreamed to QCoDeS.
Prefer `qcodes.dataset.get_db_overview` when the installed QCoDeS version
exposes it, and fall back to the local implementation for older versions.

The local implementation is generalized to match the upstreamed API: it now
accepts an optional existing connection and an `extra_columns` argument for
reading ad-hoc metadata columns, replacing the hard-coded `inspectr_tag`
handling. `inspectr` requests the `inspectr_tag` column explicitly.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Mirror the review changes made to the upstreamed QCoDeS implementation: make
conn/start_run_id/extra_columns keyword-only, catch sqlite3.Error instead of
bare Exception, and drop the misleading result_counter fallback (it is the run
ordinal, not a data-point count) in favour of reporting 0 when unknown.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@astafan8 astafan8 marked this pull request as ready for review July 3, 2026 13:16
Comment thread plottr/data/qcodes_db_overview.py Outdated
Comment thread plottr/data/qcodes_db_overview.py Outdated
Mikhail Astafev and others added 2 commits July 3, 2026 15:38
Make plottr's fallback implementation an exact copy of the upstreamed QCoDeS
`get_db_overview` (same signature, docstring and body), documenting that
snapshots are not read and that the record count may be less precise than
DataSet.number_of_results.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Address review feedback on the plottr PR:
- Move the local get_db_overview implementation into a new private module
  plottr/data/_qcodes_db_overview.py (an exact copy of the upstream QCoDeS
  implementation), and reduce plottr/data/qcodes_db_overview.py to just the
  logic that imports get_db_overview/RunOverviewDict from qcodes when available
  and falls back to the vendored copy otherwise (now at the top of the module).
- Import the private QCoDeS SQLite helpers (conn_from_dbpath_or_conn,
  is_column_in_table) lazily inside get_db_overview rather than at module import
  time, since they are private QCoDeS API.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@astafan8 astafan8 requested a review from jenshnielsen July 3, 2026 14:40
@astafan8 astafan8 self-assigned this Jul 3, 2026
@astafan8 astafan8 enabled auto-merge July 3, 2026 14:41
@astafan8 astafan8 merged commit b4510b5 into master Jul 3, 2026
2 checks passed
@astafan8 astafan8 deleted the astafan8/qcodes-db-overview branch July 3, 2026 15:08
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.

2 participants