Repository navigation
Find local WFDB records with an explicit search path - #824
Conversation
tompollard
left a comment
There was a problem hiding this comment.
Thanks. Keeping this opt-in fits the "no automatic fallback" rule well. find_record returns absolute stems and archive paths that work directly with read_record, search order and dotted names behave, invalid inputs fail clearly, and the not-found error lists every directory searched. The offline suite, Ruff and the strict docs build pass locally. (The one CI failure is the Python 3.11 job's Install libsndfile step, before tests ran, so a re-run should clear it.)
One thing to fix: the WFDB C tools commonly separate path entries with whitespace (their docs use WFDB=". /usr/local/database"), and wfdb_search_path() treats such a value as a single directory named ". /usr/local/database". find_record then reports "not found", which hides the real cause. @file and URLs already raise a clear ValueError. Could an entry that contains whitespace and isn't an existing directory raise one too, saying that whitespace-separated entries aren't supported and to use os.pathsep or pass directories explicitly? Directories that genuinely contain spaces (like "my records" in the test) would still work, and a test with ". <dir>" would cover it.
Minor: when a directory has both 100.hea and 100.wfdb, the header wins, which is worth a sentence in the docs. search_path=b"/tmp" gives a cryptic not int error; adding bytes to the bare-string check would give the clear message.
|
Thanks. I addressed these in cc92a60. wfdb_search_path() now raises a clear ValueError for a whitespace-containing component that is not an existing directory, while accepting existing directories whose names contain spaces. I added the ". " regression test. find_record() also gives a clear TypeError for a bare bytes search_path, and the docs now say that a .hea file wins over a .wfdb archive in the same directory. The 9 focused tests, Ruff, and the strict docs build pass locally. The failed Linux CI job stopped during libsndfile installation, before tests ran; I will rerun it if needed after the workflow finishes. |
tompollard
left a comment
There was a problem hiding this comment.
Thanks, cc92a60 covers everything. A C-style WFDB=". <dir>" now raises the clear whitespace message, while an existing directory with a space in its name (my records) still works through os.pathsep. search_path=b"/tmp" and [b"/tmp"] give clear TypeErrors, and the header-before-archive precedence is documented and tested. The full offline suite, Ruff and the strict docs build pass locally.
Ready to merge once CI is green (and after #823, as noted in the description).
## Summary #824 merged just before the 5.12.0 release PR, so its changelog fragment is still in `changelog.d/`. Move that entry into the 5.12.0 section and mention explicit local record search in the release summary. This ensures the published release notes describe all code in 5.12.0. ## Checks - Strict Sphinx HTML build passed. - `git diff --check` passed. Merge before creating GitHub release `v5.12.0`.
Summary
wfdb.find_record()to locate a record header or local.wfdbarchive in an ordered list of directories and return its absolute path.wfdb.wfdb_search_path()so callers can explicitly use simple local directories from theWFDBenvironment variable.This does not change how
read_recordor other readers resolve a path. The helper only locates a header or archive; signal files must still be readable relative to the header. The C library's URL entries, whitespace separators, and indirect path files are outside this local-only helper's scope.Addresses #545.
Checks
This PR will be included in 5.12.0. Merge it before #823, then update the
5.12.0 release notes to include this change.