Skip to content

fix(dlc): accept benign loader kwargs in DLC project/splits loaders#488

Merged
talmo merged 2 commits into
mainfrom
fix/dlc-loader-kwargs
Jun 23, 2026
Merged

fix(dlc): accept benign loader kwargs in DLC project/splits loaders#488
talmo merged 2 commits into
mainfrom
fix/dlc-loader-kwargs

Conversation

@talmo

@talmo talmo commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Problem

sio show <dlc_project> / sio show <config.yaml> crashes with an uncaught TypeError, and sio.load_file(<dlc_project>, open_videos=...) raises the same error:

TypeError: load_dlc_project() got an unexpected keyword argument 'open_videos'

load_file and sio show always forward benign loader kwargs (open_videos, lazy) to the routed loader. main.load_dlc_project (sleap_io/io/main.py:468-491) has **kwargs and forwards them to the underlying dlc.load_dlc_project, but that function (sleap_io/io/dlc.py:689) had no **kwargs and no open_videos/lazy params, so the forwarded kwargs raised a raw TypeError and exit 1.

Fix

Add accept-and-ignore **kwargs to dlc.load_dlc_project and dlc.load_dlc_splits in sleap_io/io/dlc.py. open_videos/lazy simply have no effect for DLC projects, whose videos reference per-image labeled-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_splits is not currently reachable via load_file, but **kwargs is 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_kwargsload_dlc_project(config, open_videos=False, lazy=True) returns a Labels.
  • test_load_file_routes_config_yaml_with_open_videosload_file(config.yaml, open_videos=False).
  • test_load_file_routes_dlc_project_dir_with_open_videosload_file(project_dir, open_videos=False).
  • test_load_dlc_splits_ignores_loader_kwargsdlc.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. Full tests/io/test_dlc.py → 98 passed. ruff format/ruff check clean.

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

github-actions Bot pushed a commit that referenced this pull request Jun 23, 2026
@github-actions

github-actions Bot commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Docs Preview

Preview has been removed.

@codecov

codecov Bot commented Jun 23, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.02%. Comparing base (e4c7957) to head (e258171).

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

talmo and others added 2 commits June 23, 2026 11:00
`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
@talmo talmo force-pushed the fix/dlc-loader-kwargs branch from 708771d to e258171 Compare June 23, 2026 18:01
github-actions Bot pushed a commit that referenced this pull request Jun 23, 2026
@talmo talmo merged commit 430e858 into main Jun 23, 2026
15 checks passed
@talmo talmo deleted the fix/dlc-loader-kwargs branch June 23, 2026 18:09
github-actions Bot added a commit that referenced this pull request Jun 23, 2026
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.

1 participant