drivendataorg / zamba

A Python package for identifying 42 kinds of animals, training custom models, and estimating distance from camera trap videos
https://zamba.drivendata.org/docs/stable/
MIT License
118 stars 27 forks source link

Make the signature of `load_video_frames` stricter #203

Open AllenDowney opened 2 years ago

AllenDowney commented 2 years ago

Currently load_video_frames can take a VideoLoaderConfig object as a parameter or, if it's missing, it gathers the kwargs and makes a VideoLoaderConfig. This permissiveness complicates the implementation if npy_cache and wastes a few cycles validating the configuration over and over. It would be better to require a validated (once and for all) VideoLoaderConfig.

To make this change, we might have to add a deprecation warning now, fix some tests that rely on the current signature, and then enforce the stricter signature in the future.

AllenDowney commented 2 years ago

Stashing this snippet:

warnings.warn(
            "Calling load_video_frames with keyword arguments is deprecated. "
            "Pass a VideoLoaderConfig as the second parameter instead.",
            DeprecationWarning,
            stacklevel=2
        )