Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions hf_download.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@
type=str,
help="model name in huggingface, e.g., baichuan-inc/Baichuan2-7B-Chat",
)
parser.add_argument(
"--revision",
"-R",
default=None,
type=str,
help="An optional Git revision id which can be a branch name, a tag, or a commit hash.",
)
parser.add_argument(
"--token",
"-T",
Expand Down Expand Up @@ -93,6 +100,10 @@
os.environ["HF_ENDPOINT"] = "https://hf-mirror.com"
print("export HF_ENDPOINT=", os.getenv("HF_ENDPOINT")) # https://hf-mirror.com

if args.revision is not None:
revision_option = "--revision %s" % args.revision
else:
revision_option = ""

if args.token is not None:
token_option = "--token %s" % args.token
Expand Down Expand Up @@ -125,8 +136,8 @@
save_dir_option = "--local-dir %s" % save_path

download_shell = (
"huggingface-cli download %s %s %s --local-dir-use-symlinks False --resume-download %s %s"
% (token_option, include_option, exclude_option, args.model, save_dir_option)
"huggingface-cli download %s %s %s %s --local-dir-use-symlinks False --resume-download %s %s"
% (token_option, include_option, exclude_option, revision_option, args.model, save_dir_option)
)
os.system(download_shell)

Expand All @@ -145,7 +156,7 @@
save_dir_option = "--local-dir %s" % save_path

download_shell = (
"huggingface-cli download %s %s %s --local-dir-use-symlinks False --resume-download --repo-type dataset %s %s"
% (token_option, include_option, exclude_option, args.dataset, save_dir_option)
"huggingface-cli download %s %s %s %s --local-dir-use-symlinks False --resume-download --repo-type dataset %s %s"
% (token_option, include_option, exclude_option, revision_option, args.dataset, save_dir_option)
)
os.system(download_shell)