Skip to content

List databases in get_dbs through PhysioNet's API - #665

Merged
tompollard merged 2 commits into
mainfrom
get-dbs-physionet
Nov 23, 2026
Merged

tompollard merged 2 commits into
mainfrom
get-dbs-physionet

Conversation

@tompollard

Copy link
Copy Markdown
Member

Fixes #439.

PhysioNet has removed https://physionet.org/rest/database-list/, so wfdb.get_dbs() now fails with a 404 error. This lists databases through PhysioNet's API instead, with the physionet package (already a dependency), and keeps the latest version of each database. It returns the same [slug, title] pairs, sorted by slug, as before: currently 466 databases, in about 4 seconds.

Testing

  • New offline test with a mocked project list (several versions of one database, and software and challenge projects that are left out), and a network test against PhysioNet.
  • pytest -m "not network": all pass, also with --resolution lowest-direct (physionet 0.7.2). Ruff and the docs build pass.

@tompollard 🟥 red 🦥 sloth · aspen

PhysioNet has removed https://physionet.org/rest/database-list/, so get_dbs
failed with a 404 error. Use the physionet package's list of published
projects instead, keeping the latest version of each database.

Fixes #439.

@tompollard tompollard left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The database filtering looks correct. I verified the live API result: get_dbs() returned 466 unique database slugs, including the expected MIT-BIH entry. The 26 focused offline tests and all 18 PR checks pass.

One minor cleanup request in src/wfdb/io/download.py:265: get_dbs() creates a PhysioNetClient but never closes it. The client owns a requests.Session and supports a context manager, so could this use with physionet.PhysioNetClient() as client: around client.projects.list_published()? That would close the session on both success and error; the client and its projects object reference each other, so leaving cleanup to garbage collection is unpredictable.

@tompollard

Copy link
Copy Markdown
Member Author

Thanks, good catch. In e25f8b8, get_dbs() now uses with physionet.PhysioNetClient() as client:, so the session is closed after both success and error (the context manager is in physionet 0.7.2, the minimum version).

I added a check to the existing test that the client is closed once, and a new test that it's closed when list_published raises. Both fail without the with block. The get_dbs tests also pass with --resolution lowest-direct.

@tompollard tompollard left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-reviewed e25f8b8. The earlier client-cleanup finding is fixed: get_dbs() now closes its PhysioNetClient on both success and error, with tests for both paths. I found no further actionable issues, and all 27 focused offline tests pass. The updated commit's remaining CI jobs are still running; this looks good to merge once they pass.

@tompollard
tompollard merged commit a6ab2d7 into main Nov 23, 2026
18 checks passed
@tompollard
tompollard deleted the get-dbs-physionet branch November 23, 2026 22:34
tompollard added a commit that referenced this pull request Nov 24, 2026
## Summary

Bump the version from 5.1.0 to 5.2.0, and collect the 19 entries in
`changelog.d/` into `docs/changes.rst` with `towncrier build --date "Nov
2026"`, with a short summary at the top of the new section.

This is a minor release. The one change that existing code may notice is
that `rdann` and `Annotation.apply_range` now stop before `sampto`, as
`rdrecord` and `rdsamp` do, so an annotation exactly at `sampto` is no
longer included (#667). The summary calls it out, with how to get the
old result.

The release also includes:
- **Fixes for PhysioNet:** `get_dbs`, which PhysioNet's API change had
broken (#665), record names with folders in `pn_dir` (#666), and
`physionet://` and other URIs in `read_edf`, `rdedfann` and `read_wav`
(#674).
- **Robustness:**
  - headers whose base time or date is in another form (#668);
- multi-segment writes that leave no partial record after an error
(#673);
- a warning before `wrsamp` replaces another record's signal files
(#675).
- **New:** a beat-by-beat comparison of annotation files, as WFDB `bxb`
does, as a development feature (#679), and axis labels in `plot_wfdb`
(#670).
- **Smaller fixes:**
- integer overflow and precision in `find_peaks` and `normalize_bound`;
  - constant signals in `normalize_bound`;
  - multi-character custom annotation symbols;
  - format 61 signals read with `smooth_frames=False`;
  - skew written twice when rewriting records;
  - docstring examples, and more.

This will be the first release published by
`.github/workflows/publish.yml`, from the GitHub release, with
provenance.

## Checks

- `pytest -m "not network"`: 679 passed (4 skipped, the `bxb` comparison
that needs WFDB installed), also with `--python 3.11 --resolution
lowest-direct`. `pytest -m network`: 20 passed.
- Ruff and the Sphinx HTML build with warnings as errors pass.
- The wheel and source distribution build and pass `twine check`. They
have `Version: 5.2.0` and include `wfdb/processing/beat_comparison.py`.
- PyPI has no 5.2.0 release yet.

<sub>@tompollard 🟥 red 🦥 sloth · aspen</sub>
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.

https://physionet.org/rest/database-list/ is being deprecated

1 participant