Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
chenpangpang
transformers
Commits
58c36bea
Unverified
Commit
58c36bea
authored
Aug 22, 2023
by
Joe Mifsud
Committed by
GitHub
Aug 22, 2023
Browse files
Support specifying revision in push_to_hub (#25578)
Support revision in push_to_hub
parent
450a181d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
1 deletion
+15
-1
src/transformers/utils/hub.py
src/transformers/utils/hub.py
+15
-1
No files found.
src/transformers/utils/hub.py
View file @
58c36bea
...
...
@@ -32,6 +32,7 @@ import huggingface_hub
import
requests
from
huggingface_hub
import
(
CommitOperationAdd
,
create_branch
,
create_commit
,
create_repo
,
get_hf_file_metadata
,
...
...
@@ -722,6 +723,7 @@ class PushToHubMixin:
commit_message
:
Optional
[
str
]
=
None
,
token
:
Optional
[
Union
[
bool
,
str
]]
=
None
,
create_pr
:
bool
=
False
,
revision
:
str
=
None
,
):
"""
Uploads all modified files in `working_dir` to `repo_id`, based on `files_timestamps`.
...
...
@@ -768,9 +770,17 @@ class PushToHubMixin:
CommitOperationAdd
(
path_or_fileobj
=
os
.
path
.
join
(
working_dir
,
file
),
path_in_repo
=
file
)
)
if
revision
is
not
None
:
create_branch
(
repo_id
=
repo_id
,
branch
=
revision
,
token
=
token
,
exist_ok
=
True
)
logger
.
info
(
f
"Uploading the following files to
{
repo_id
}
:
{
','
.
join
(
modified_files
)
}
"
)
return
create_commit
(
repo_id
=
repo_id
,
operations
=
operations
,
commit_message
=
commit_message
,
token
=
token
,
create_pr
=
create_pr
repo_id
=
repo_id
,
operations
=
operations
,
commit_message
=
commit_message
,
token
=
token
,
create_pr
=
create_pr
,
revision
=
revision
,
)
def
push_to_hub
(
...
...
@@ -783,6 +793,7 @@ class PushToHubMixin:
max_shard_size
:
Optional
[
Union
[
int
,
str
]]
=
"10GB"
,
create_pr
:
bool
=
False
,
safe_serialization
:
bool
=
False
,
revision
:
str
=
None
,
**
deprecated_kwargs
,
)
->
str
:
"""
...
...
@@ -811,6 +822,8 @@ class PushToHubMixin:
Whether or not to create a PR with the uploaded files or directly commit.
safe_serialization (`bool`, *optional*, defaults to `False`):
Whether or not to convert the model weights in safetensors format for safer serialization.
revision (`str`, *optional*):
Branch to push the uploaded files to.
Examples:
...
...
@@ -886,6 +899,7 @@ class PushToHubMixin:
commit_message
=
commit_message
,
token
=
token
,
create_pr
=
create_pr
,
revision
=
revision
,
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment