1- """Cache management module for mLLMCelltype.
1+ """Cache management CLI for mLLMCelltype.
22
3- This module provides utilities for managing the mLLMCelltype cache system,
4- including cache inspection, clearing, and validation functions.
5-
6- Functions:
7- clear_mllmcelltype_cache(): Interactive cache clearing
8- clear_cache_cli(): Command-line interface for cache management
3+ Usage:
4+ python -m mllmcelltype.cache_manager # Interactive mode
5+ python -m mllmcelltype.cache_manager --clear # Clear cache without confirmation
6+ python -m mllmcelltype.cache_manager --info # Show cache information
97"""
108
11- import os
12- import shutil
13-
14- from .utils import get_cache_stats
15-
16-
17- def clear_mllmcelltype_cache ():
18- """Clear the mLLMCelltype cache directory."""
19- info = get_cache_stats (detailed = False )
20- cache_dir = info ["path" ]
21-
22- if info ["exists" ]:
23- print (f"Found cache directory: { cache_dir } " )
24- print (f"Found { info ['count' ]} cache files" )
25-
26- # Ask for confirmation
27- response = input ("Do you want to clear all cache files? (yes/no): " )
28- if response .lower () == "yes" :
29- shutil .rmtree (cache_dir )
30- os .makedirs (cache_dir , exist_ok = True )
31- print ("Cache cleared successfully!" )
32- else :
33- print ("Cache clearing cancelled." )
34- else :
35- print ("No cache directory found." )
9+ from .utils import clear_cache , get_cache_stats
3610
3711
3812def clear_cache_cli ():
@@ -42,26 +16,34 @@ def clear_cache_cli():
4216 print ("mLLMCelltype Cache Manager" )
4317 print ("-" * 30 )
4418
45- # Check for command line arguments
4619 if len (sys .argv ) > 1 and sys .argv [1 ] == "--clear" :
47- # Non-interactive mode
48- from .utils import clear_cache
49-
5020 removed = clear_cache ()
5121 print (f"\n Cleared { removed } cache files." )
22+
5223 elif len (sys .argv ) > 1 and sys .argv [1 ] == "--info" :
53- # Show cache info
5424 info = get_cache_stats (detailed = False )
5525 print (f"\n Cache directory: { info ['path' ]} " )
5626 print (f"Number of cache files: { info ['count' ]} " )
5727 print (f"Total cache size: { info ['size_mb' ]:.2f} MB" )
28+
5829 else :
5930 # Interactive mode
60- clear_mllmcelltype_cache ()
31+ info = get_cache_stats (detailed = False )
32+ if info ["exists" ]:
33+ print (f"Found cache directory: { info ['path' ]} " )
34+ print (f"Found { info ['count' ]} cache files" )
35+ response = input ("\n Do you want to clear all cache files? (yes/no): " )
36+ if response .lower () == "yes" :
37+ removed = clear_cache ()
38+ print (f"Cleared { removed } cache files." )
39+ else :
40+ print ("Cache clearing cancelled." )
41+ else :
42+ print ("No cache directory found." )
6143
6244 print ("\n Usage:" )
6345 print (" python -m mllmcelltype.cache_manager # Interactive mode" )
64- print (" python -m mllmcelltype.cache_manager --clear # Clear cache without confirmation" )
46+ print (" python -m mllmcelltype.cache_manager --clear # Clear without confirmation" )
6547 print (" python -m mllmcelltype.cache_manager --info # Show cache information" )
6648
6749
0 commit comments