Description
The EAGER_IMPORT
environment variable is a way to test that all of your lazy imports were correctly specified.
Every module that uses lazy_loader checks this and attempts to access all of its members if the envion is set.
if os.environ.get("EAGER_IMPORT", ""):
for attr in set(attr_to_modules.keys()) | submodules:
__getattr__(attr)
This is a useful feature to have, but I'm running into an issue where the huggingface library is using lazy_loader, and attempting to test my module with EAGER_IMPORT
causes failures. I just want to test my module. To avoid this I'm thinking about how the user can specify only a specific module to eager import.
Perhaps EAGER_IMPORT could be given as a pattern, and if __name__
matches the pattern, then it can trigger the case, or if it is a special code like "1", or "True", then it triggers for every module (i.e. implements the existing behavior).
Another option is to make separate environs for each module, but casing seems like it might cause confusion.