MCPcopy Index your code
hub / github.com/modelscope/modelscope / _scan_dir

Function _scan_dir

modelscope/hub/cache_manager.py:436–456  ·  view source on GitHub ↗

Scan a directory for cached repos and return a set of [`~CachedRepoInfo`] and warnings.

(dir: Path, repo_type: str, inplace: bool = False)

Source from the content-addressed store, hash-verified

434
435
436def _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
459def _scan_cached_repo(repo_path: Path,

Callers 1

scan_cache_dirFunction · 0.85

Calls 4

_is_valid_dirFunction · 0.85
_scan_cached_repoFunction · 0.85
addMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…