* Reload transformers fix form cache * add imports * add test fn for clearing import cache * ruff fix to core import logic * ruff fix to test file * fixup for imports * fixup for test * lru restore * test check * fix style changes * added documentation for usecase * fixing --------- Co-authored-by: sambhavnoobcoder <indosambahv@gmail.com>
This commit is contained in:
23
tests/utils/test_import_utils.py
Normal file
23
tests/utils/test_import_utils.py
Normal file
@@ -0,0 +1,23 @@
|
||||
import sys
|
||||
|
||||
from transformers.utils.import_utils import clear_import_cache
|
||||
|
||||
|
||||
def test_clear_import_cache():
|
||||
# Import some transformers modules
|
||||
|
||||
# Get initial module count
|
||||
initial_modules = {name: mod for name, mod in sys.modules.items() if name.startswith("transformers.")}
|
||||
|
||||
# Verify we have some modules loaded
|
||||
assert len(initial_modules) > 0
|
||||
|
||||
# Clear cache
|
||||
clear_import_cache()
|
||||
|
||||
# Check modules were removed
|
||||
remaining_modules = {name: mod for name, mod in sys.modules.items() if name.startswith("transformers.")}
|
||||
assert len(remaining_modules) < len(initial_modules)
|
||||
|
||||
# Verify we can reimport
|
||||
assert "transformers.models.auto.modeling_auto" in sys.modules
|
||||
Reference in New Issue
Block a user