Right now the logic about setting up the pre-trained Hugging Face encoders lives in a protected method of the UDTube module. This probably unnecessarily extends this module, and there is basically a if/elif/else cascade to deal with special cases that's likely to get longer. Here is what I'd suggest as an alternative:
Create encoders.py and move the special casing code there.
Sort things into three (notional) lists:
Encoders we've tried (possibly with special case) and know to work; use the special case and return the encoder
Optionally, encoders we know don't work: raise an module-specific exception
For all other encoders, just look it up on Hugging Face and see if it works with we think the defaults are; try it and return it
Then, we just call into this module in the constructor for UDTube.
This is slightly cleaner and stores code with lots of special casing in a module that most users will never have to look at.
Right now the logic about setting up the pre-trained Hugging Face encoders lives in a protected method of the
UDTube
module. This probably unnecessarily extends this module, and there is basically a if/elif/else cascade to deal with special cases that's likely to get longer. Here is what I'd suggest as an alternative:encoders.py
and move the special casing code there.Then, we just call into this module in the constructor for
UDTube
.This is slightly cleaner and stores code with lots of special casing in a module that most users will never have to look at.