diff --git a/modelscope/hub/api.py b/modelscope/hub/api.py index 4cf0c02e..dabc97eb 100644 --- a/modelscope/hub/api.py +++ b/modelscope/hub/api.py @@ -2304,12 +2304,11 @@ class HubApi: allow_patterns = allow_patterns if allow_patterns else None ignore_patterns = ignore_patterns if ignore_patterns else None - # Ignore .git folder + # Ignore .git .cache folders if ignore_patterns is None: - ignore_patterns = [] + ignore_patterns = DEFAULT_IGNORE_PATTERNS elif isinstance(ignore_patterns, str): ignore_patterns = [ignore_patterns] - ignore_patterns += DEFAULT_IGNORE_PATTERNS commit_message = ( commit_message if commit_message is not None else f'Upload to {repo_id} on ModelScope hub' diff --git a/modelscope/utils/repo_utils.py b/modelscope/utils/repo_utils.py index f8f5cf71..fabe0a00 100644 --- a/modelscope/utils/repo_utils.py +++ b/modelscope/utils/repo_utils.py @@ -30,8 +30,6 @@ DEFAULT_IGNORE_PATTERNS = [ '*/.cache', '**/.cache/**', ] -# Forbidden to commit these folders -FORBIDDEN_FOLDERS = ['.git', '.cache'] UploadMode = Literal['lfs', 'normal'] @@ -555,11 +553,7 @@ def _validate_path_in_repo(path_in_repo: str) -> str: f"Invalid `path_in_repo` in CommitOperation: '{path_in_repo}'") if path_in_repo.startswith('./'): path_in_repo = path_in_repo[2:] - for forbidden in FORBIDDEN_FOLDERS: - if any(part == forbidden for part in path_in_repo.split('/')): - raise ValueError( - f"Invalid `path_in_repo` in CommitOperation: cannot update files under a '{forbidden}/' folder (path:" - f" '{path_in_repo}').") + return path_in_repo