Skip to content

Commit 771c2b3

Browse files
committed
feat: enhance AutoConfig to support path-based model configuration
1 parent 4bfb4a6 commit 771c2b3

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

cccv/auto/config.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import importlib.util
22
import json
3+
import warnings
34
from pathlib import Path
45
from typing import Any, Optional, Union
56

@@ -24,8 +25,10 @@ def from_pretrained(
2425
:return:
2526
"""
2627
if "pretrained_model_name" in kwargs:
27-
print(
28-
"[CCCV] warning: 'pretrained_model_name' is deprecated, please use 'pretrained_model_name_or_path' instead."
28+
warnings.warn(
29+
"[CCCV] 'pretrained_model_name' is deprecated, please use 'pretrained_model_name_or_path' instead.",
30+
DeprecationWarning,
31+
stacklevel=2,
2932
)
3033
pretrained_model_name_or_path = kwargs.pop("pretrained_model_name")
3134

cccv/util/remote.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import hashlib
22
import os
3+
import shutil
34
import subprocess
45
import sys
6+
import warnings
57
from pathlib import Path
68
from typing import Any, Optional, Union
79

@@ -123,6 +125,13 @@ def git_clone(git_url: str, model_dir: Optional[Union[Path, str]] = None, **kwar
123125
:param **kwargs: Additional git options (branch, commit_hash, etc.)
124126
:return: Path to the cloned repository
125127
"""
128+
if not shutil.which("git"):
129+
warnings.warn(
130+
"[CCCV] git is not installed or not in the system's PATH. "
131+
"Please install git to use models from remote git repositories.",
132+
stacklevel=2,
133+
)
134+
126135
model_dir = get_cache_dir(model_dir)
127136
# get repo name from url
128137
repo_name = git_url.split("/")[-1].replace(".git", "")

0 commit comments

Comments
 (0)