Replacing missing videos does not prompt user to save changes
Bug description
When user open a project with video paths pointed to a different location, a GUI appears to allow for interactively browsing to the new video file locations.
This does not cause the project to be in an "unsaved" state though, so training is allowed to run without saving again, resulting in errors since the SLP file on disk still has the old paths.
The workaround for now is to go to File -> Save As... and save a new copy.
Expected behaviour
Replacing video file paths at load time should trigger the unsaved state: labels.state["has_changes"] = True or context.changestack_push().
Actual behaviour
Replacing video file paths does not trigger the unsaved state.
Your personal set up
- OS: All
- Version(s): SLEAP v1.2.4
- SLEAP installation method (listed here):
- [x] Conda from package
- [x] Conda from source
- [x] pip package
- [x] M1 Macs
Environment packages
N/ALogs
``` Traceback (most recent call last): File "/Users/chapinlenthall-cleary/miniforge3/envs/sleap_m1/bin/sleap-train", line 33, inScreenshots
How to reproduce
- Import a file with non-existent paths.
- Replace paths in GUI.
- Try to train without re-saving.
Problem Analysis
SLEAP uses a class method on the Labels object to return a callable for the missing video search. We should return something from this callable to let the MainWindow or CommandContext know that some video paths were updated. The difficulty is that the video_search callable is called by Adaptor.read (which should not return anything other than the Labels object), all methods that are passed video_search are classmethods (thus, we cannot just pass an attribute to the object), and the file could be of any SLEAP-supported format (we would need to add a line of code to each adaptor format).
Relevant Code
-
Load project https://github.com/talmolab/sleap/blob/219a60fad332afb047c2d000e8bf15abcd2b7674/sleap/gui/app.py#L1425-L1459
-
Create callable https://github.com/talmolab/sleap/blob/219a60fad332afb047c2d000e8bf15abcd2b7674/sleap/gui/app.py#L1439-L1441
-
Attempt to load the file https://github.com/talmolab/sleap/blob/219a60fad332afb047c2d000e8bf15abcd2b7674/sleap/gui/app.py#L1451-L1452
-
The
Labels.load_filefunction https://github.com/talmolab/sleap/blob/219a60fad332afb047c2d000e8bf15abcd2b7674/sleap/io/dataset.py#L1931-L1944
This feature is now available in the (pre) release 1.3.0a0, to install, first uninstall and then:
conda (Windows/Linux/GPU):
conda create -y -n sleap -c sleap -c sleap/label/dev -c nvidia -c conda-forge sleap=1.3.0a0
pip (any OS except Apple Silicon):
pip install sleap==1.3.0a0
Warning: This is a pre-release! Expect bugs and strange behavior when testing.