-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Fix hard-coded overwrite kwarg in pytorch analyze_videos
#3514
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+68
−3
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
175e10f
Remove hard-coded overwrite
C-Achard 3461180
Add proper overwrite kwarg to analyze_videos
C-Achard da969d4
Pass overwrite to tracklets generation as well
C-Achard c0a6b11
Avoid shuffling existing positional calls
C-Achard 7be7ca3
Fix overwrite forwarding in analyze_videos
C-Achard a897636
Harden regression test for issue #3513
deruyter92 5ea382c
improve docstring in analyze_videos
deruyter92 fd4a89f
Add regression check for overwrite in auto-track path
deruyter92 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
60 changes: 60 additions & 0 deletions
60
tests/pose_estimation_pytorch/apis/test_compat_analyze_videos.py
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| # | ||
| # DeepLabCut Toolbox (deeplabcut.org) | ||
| # © A. & M.W. Mathis Labs | ||
| # https://github.com/DeepLabCut/DeepLabCut | ||
| # | ||
| # Please see AUTHORS for contributors. | ||
| # https://github.com/DeepLabCut/DeepLabCut/blob/main/AUTHORS | ||
| # | ||
| # Licensed under GNU Lesser General Public License v3.0 | ||
| # | ||
| import inspect | ||
|
|
||
| import pytest | ||
|
|
||
| import deeplabcut.pose_estimation_pytorch.apis as pytorch_apis | ||
| import deeplabcut.pose_estimation_pytorch.apis.videos as videos_api | ||
| from deeplabcut.compat import Engine, analyze_videos | ||
|
|
||
|
|
||
| @pytest.mark.parametrize("overwrite", [True, False]) | ||
| def test_analyze_videos_forwards_overwrite(monkeypatch, overwrite): | ||
| """``overwrite`` must reach the PyTorch API rather than being pinned to False. | ||
|
|
||
| Regression for #3513: a hard-coded ``overwrite=False`` plus ``overwrite`` in | ||
| ``**torch_kwargs`` used to raise ``TypeError: got multiple values for keyword | ||
| argument 'overwrite'``. Using an explicit ``overwrite`` parameter on the mock | ||
| would still raise if the wrapper double-passed the flag. | ||
| """ | ||
| captured = {} | ||
|
|
||
| def fake_analyze_videos(config, *, overwrite=False, **kwargs): | ||
| captured["overwrite"] = overwrite | ||
| captured["kwargs"] = kwargs | ||
| return "mock-scorer" | ||
|
|
||
| monkeypatch.setattr(pytorch_apis, "analyze_videos", fake_analyze_videos) | ||
|
|
||
| result = analyze_videos( | ||
| "config.yaml", | ||
| ["video.mp4"], | ||
| engine=Engine.PYTORCH, | ||
| overwrite=overwrite, | ||
| ) | ||
|
|
||
| assert result == "mock-scorer" | ||
| assert captured["overwrite"] is overwrite | ||
| assert "overwrite" not in captured["kwargs"] | ||
|
|
||
|
|
||
| def test_analyze_videos_auto_track_forwards_overwrite(): | ||
| """PyTorch auto_track must pass ``overwrite`` through to tracklet generation. | ||
|
|
||
| Catches a hard-coded ``overwrite=False`` at the convert_detections2tracklets | ||
| call site without driving full video analysis. | ||
| """ | ||
| source = inspect.getsource(videos_api.analyze_videos) | ||
| _, _, after = source.partition("convert_detections2tracklets(") | ||
| call = after.split("stitch_tracklets(", 1)[0] | ||
| assert "overwrite=overwrite" in call | ||
| assert "overwrite=False" not in call |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.