Add get_db_overview for fast, lightweight run listing#8266
Merged
Conversation
Add `qcodes.dataset.sqlite.db_overview.get_db_overview`, which fetches a lightweight overview of the runs in a database via a single JOIN query on the `runs` and `experiments` tables, without instantiating a DataSet per run. This makes listing databases with many thousands of runs near-instant. The function and its return type `RunOverviewDict` are exported on the public `qcodes.dataset` namespace. An `extra_columns` argument allows reading ad-hoc metadata columns added via `DataSet.add_metadata`. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #8266 +/- ##
==========================================
+ Coverage 71.04% 71.12% +0.08%
==========================================
Files 304 305 +1
Lines 31911 32001 +90
==========================================
+ Hits 22670 22760 +90
Misses 9241 9241 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Contributor
Author
|
Companion plottr PR that consumes this API (with a local fallback for older QCoDeS): toolsforexperiments/plottr#462 |
jenshnielsen
reviewed
Jul 3, 2026
jenshnielsen
reviewed
Jul 3, 2026
jenshnielsen
reviewed
Jul 3, 2026
jenshnielsen
reviewed
Jul 3, 2026
jenshnielsen
reviewed
Jul 3, 2026
jenshnielsen
reviewed
Jul 3, 2026
…fallback - Make conn/start_run_id/extra_columns keyword-only. - Remove the leftover schema-stability note from the module docstring. - Catch sqlite3.Error rather than bare Exception around the queries. - Document why the extra_columns dict update needs a type: ignore. - Drop the result_counter fallback for the record count: result_counter is the run's ordinal within its experiment, not a data-point count, so it produced a misleading number; report 0 (unknown) instead. - Add tests for the in-progress, missing-results-table and query-error branches. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
astafan8
commented
Jul 3, 2026
astafan8
commented
Jul 3, 2026
astafan8
commented
Jul 3, 2026
astafan8
commented
Jul 3, 2026
…onfig - Document in the docstring and newsfragment that snapshots are not read (they can be large and slow) and that the record count may be less precise than DataSet.number_of_results. - Rewrite the tests to build the database via an explicit connection object (load_or_create_experiment(conn=...)/new_data_set(conn=...)) so the global QCoDeS config is not mutated, and close the connection via request.addfinalizer so it is cleaned up even if a test fails. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
jenshnielsen
approved these changes
Jul 3, 2026
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
Adds
get_db_overview, a fast, lightweight way to list the runs in a QCoDeSdatabase. It issues a single
JOINquery against therunsandexperimentstables to collect run metadata (experiment/sample names, timestamps, record
counts, guids) without instantiating a
DataSetobject per run.This avoids the expensive
experiments()+data_sets()enumeration, solisting a database with many thousands of runs becomes near-instant instead of
taking minutes. It is intended for tools that display a table of runs (dataset
browsers, e.g. plottr's
inspectr).What's included
qcodes/dataset/sqlite/db_overview.pywith:get_db_overview(path_to_db=None, conn=None, start_run_id=0, extra_columns=None)RunOverviewDict— theTypedDictdescribing each run's overview entryqcodes.datasetnamespace (added toqcodes/dataset/__init__.py__all__).tests/dataset/test_db_overview.py.Notes / design choices
recordsis a best-effort data-point count: for completed runs the rundescription
shapesare preferred (authoritative final count), falling backto the results-table row count, then
result_counter. For in-progress runsthe live results-table row count is preferred.
start_run_idsupports cheap incremental refresh (only fetch runs newer thana known
run_id).extra_columnslets callers pull ad-hoc metadata columns added viaDataSet.add_metadata(e.g. plottr'sinspectr_tag) into the overview.Columns that don't exist in the
runstable are silently skipped.path_to_db(opened read-only, then closed) or an existingconn(left open) may be supplied.
Origin
This was prototyped and battle-tested in
plottr and is being upstreamed
so it can be shared. A companion plottr PR switches to this implementation when
available and keeps a local fallback for older QCoDeS versions.
Status
Draft — opening for early feedback on the public API shape (function name,
argument names, and the
RunOverviewDictkey names). Happy to renameexperiment/samplekeys or adjust therecordsheuristic based on review.Note
This pull request was created by an agent on behalf of @astafan8.