Scan a directory for cached repos and return a set of [`~CachedRepoInfo`] and warnings.
(dir: Path, repo_type: str, inplace: bool = False)
| 434 | |
| 435 | |
| 436 | def _scan_dir(dir: Path, repo_type: str, inplace: bool = False): |
| 437 | """Scan a directory for cached repos and return a set of [`~CachedRepoInfo`] and warnings.""" |
| 438 | repos = set() |
| 439 | warnings = [] |
| 440 | for owner_dir in dir.iterdir(): |
| 441 | # not extend scan the following dirs when scan current dir |
| 442 | if inplace and owner_dir.name in ['models', 'datasets', 'hub']: |
| 443 | continue |
| 444 | if not _is_valid_dir(owner_dir): |
| 445 | continue |
| 446 | # Second level directories are repo names |
| 447 | for name_dir in owner_dir.iterdir(): |
| 448 | if not _is_valid_dir(name_dir): |
| 449 | continue |
| 450 | try: |
| 451 | info = _scan_cached_repo(name_dir, repo_type=repo_type) |
| 452 | if info is not None: |
| 453 | repos.add(info) |
| 454 | except CorruptedCacheException as e: |
| 455 | warnings.append(e) |
| 456 | return repos, warnings |
| 457 | |
| 458 | |
| 459 | def _scan_cached_repo(repo_path: Path, |
no test coverage detected
searching dependent graphs…