fix(dlc): accept benign loader kwargs in DLC project/splits loaders#488
Merged
Conversation
Contributor
Docs PreviewPreview has been removed. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #488 +/- ##
==========================================
+ Coverage 92.99% 93.02% +0.03%
==========================================
Files 54 54
Lines 19492 19492
Branches 4407 4407
==========================================
+ Hits 18126 18132 +6
+ Misses 651 647 -4
+ Partials 715 713 -2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
`load_file(<dlc_project>)` and `sio show <config.yaml>` always forward benign loader kwargs (open_videos, lazy) to the routed loader. The main.load_dlc_project wrapper forwards **kwargs to the underlying dlc.load_dlc_project, but that function (and dlc.load_dlc_splits) had no **kwargs, so the forwarded kwargs raised an uncaught TypeError: load_dlc_project() got an unexpected keyword argument 'open_videos'. Add accept-and-ignore **kwargs to dlc.load_dlc_project and dlc.load_dlc_splits. open_videos/lazy have no effect for DLC projects (their videos reference per-image folders, not openable video files). Regression tests in tests/io/test_dlc.py assert load_dlc_project, load_file(config.yaml / project dir), and load_dlc_splits all tolerate open_videos/lazy without raising. The four new tests fail before the fix. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01YHwWuvFdH5W539AgSjuTxV
…jabs/analysis_h5/csv loaders `load_file` (and `sio show`) always forward benign loader kwargs (open_videos, lazy) to the routed format loader. The wrappers for nwb, alphatracker, labelstudio, jabs, analysis_h5, and csv lacked **kwargs, so forwarding raised an uncaught TypeError: load_<fmt>() got an unexpected keyword argument 'open_videos'. Add accept-and-ignore **kwargs to those six wrappers (matching the DLC fix in this PR). The kwargs are absorbed at the wrapper level only and are not forwarded into the underlying readers, which do not accept them. Regression tests in tests/io/test_main.py assert load_file(..., open_videos= False) returns Labels for each format (nwb gated on pynwb/ndx_pose), plus a parametrized contract test asserting each wrapper exposes **kwargs. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01A6ZBs7Yww49sCmFF6XSSHs
708771d to
e258171
Compare
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.
Problem
sio show <dlc_project>/sio show <config.yaml>crashes with an uncaughtTypeError, andsio.load_file(<dlc_project>, open_videos=...)raises the same error:load_fileandsio showalways forward benign loader kwargs (open_videos,lazy) to the routed loader.main.load_dlc_project(sleap_io/io/main.py:468-491) has**kwargsand forwards them to the underlyingdlc.load_dlc_project, but that function (sleap_io/io/dlc.py:689) had no**kwargsand noopen_videos/lazyparams, so the forwarded kwargs raised a rawTypeErrorand exit 1.Fix
Add accept-and-ignore
**kwargstodlc.load_dlc_projectanddlc.load_dlc_splitsinsleap_io/io/dlc.py.open_videos/lazysimply have no effect for DLC projects, whose videos reference per-imagelabeled-data/<video>/folders rather than openable video files. Docstrings updated to note the ignored extra kwargs. No other behavior changes; the real parameters are untouched.load_dlc_splitsis not currently reachable viaload_file, but**kwargsis added for symmetry / future-proofing.Regression tests
Added to
tests/io/test_dlc.py(all four fail before the fix, pass after):test_load_dlc_project_ignores_loader_kwargs—load_dlc_project(config, open_videos=False, lazy=True)returns aLabels.test_load_file_routes_config_yaml_with_open_videos—load_file(config.yaml, open_videos=False).test_load_file_routes_dlc_project_dir_with_open_videos—load_file(project_dir, open_videos=False).test_load_dlc_splits_ignores_loader_kwargs—dlc.load_dlc_splits(config, open_videos=False, lazy=True)smoke.uv run pytest tests/io/test_dlc.py tests/io/test_main.py -p no:cacheprovider -q -k dlc→ 98 passed. Fulltests/io/test_dlc.py→ 98 passed.ruff format/ruff checkclean.Notes
This PR is scoped to the DLC crash (release blocker B6). The same "forwarded kwargs hit a loader without
**kwargs" pattern may exist for other formats (e.g. JABS / Label Studio variants); those are pre-existing and intentionally out of scope here.🤖 Generated with Claude Code
https://claude.ai/code/session_01YHwWuvFdH5W539AgSjuTxV