Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TKW] Bug: cache tests fail if cache already exists #420

Open
GMNGeoffrey opened this issue Jan 27, 2025 · 2 comments
Open

[TKW] Bug: cache tests fail if cache already exists #420

GMNGeoffrey opened this issue Jan 27, 2025 · 2 comments

Comments

@GMNGeoffrey
Copy link
Contributor

The cache tests are supposed to reset the cache before they run by calling reset_cache_manager, but that method just returns early if the cache hasn't been initialized without deleting the cache directory:

def reset_cache_manager() -> WaveCacheManager:
if not "_global_cache_manager" in globals():
return
if os.path.exists(CACHE_BASE_DIR):
shutil.rmtree(CACHE_BASE_DIR)
global _global_cache_manager
del _global_cache_manager

so if you run them once and create a cache entry and then run them again, the check that the first call wasn't cached fails:

assert isinstance(
mb, tk.compiler.builder.ModuleBuilder
), "Expected first call to not be cached."

@GMNGeoffrey
Copy link
Contributor Author

Either reset_cache_manager should delete the cache directory regardless, the tests should first initialize the cache manager before resetting it (seems a bit weird), or there should be a separate method for clearing the cache independent of resetting the cache manager. Given that the cache tests are the only users of reset_cache_manager AFAICT, I think option 1 makes the most sense.

@GMNGeoffrey
Copy link
Contributor Author

It's also maybe a bit aggressive to have the cache tests reset someone's entire cache. Maybe they should use a private cache in a temporary directory instead? That solves both problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant