(model_name: str,
cache_dir: Optional[str] = None)
| 204 | |
| 205 | |
| 206 | def get_file_lock(model_name: str, |
| 207 | cache_dir: Optional[str] = None) -> filelock.FileLock: |
| 208 | # Hash the model name to avoid invalid characters in the lock file path |
| 209 | hashed_model_name = hashlib.sha256(model_name.encode()).hexdigest() |
| 210 | |
| 211 | cache_dir = cache_dir or temp_dir |
| 212 | os.makedirs(cache_dir, exist_ok=True) |
| 213 | |
| 214 | lock_file_path = os.path.join(cache_dir, f"{hashed_model_name}.lock") |
| 215 | |
| 216 | return filelock.FileLock(lock_file_path) |
| 217 | |
| 218 | |
| 219 | class DisabledTqdm(tqdm): |
no test coverage detected