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
51ae2032
Unverified
Commit
51ae2032
authored
Dec 10, 2019
by
Thomas Wolf
Committed by
GitHub
Dec 10, 2019
Browse files
Merge pull request #2129 from leopd/master
Progress indicator improvements when downloading pre-trained models.
parents
6a733827
58d75aa3
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
2 additions
and
2 deletions
+2
-2
transformers/file_utils.py
transformers/file_utils.py
+2
-2
No files found.
transformers/file_utils.py
View file @
51ae2032
...
@@ -21,7 +21,7 @@ import boto3
...
@@ -21,7 +21,7 @@ import boto3
from
botocore.config
import
Config
from
botocore.config
import
Config
from
botocore.exceptions
import
ClientError
from
botocore.exceptions
import
ClientError
import
requests
import
requests
from
tqdm
import
tqdm
from
tqdm
.auto
import
tqdm
from
contextlib
import
contextmanager
from
contextlib
import
contextmanager
logger
=
logging
.
getLogger
(
__name__
)
# pylint: disable=invalid-name
logger
=
logging
.
getLogger
(
__name__
)
# pylint: disable=invalid-name
...
@@ -245,7 +245,7 @@ def http_get(url, temp_file, proxies=None, resume_size=0):
...
@@ -245,7 +245,7 @@ def http_get(url, temp_file, proxies=None, resume_size=0):
return
return
content_length
=
response
.
headers
.
get
(
'Content-Length'
)
content_length
=
response
.
headers
.
get
(
'Content-Length'
)
total
=
resume_size
+
int
(
content_length
)
if
content_length
is
not
None
else
None
total
=
resume_size
+
int
(
content_length
)
if
content_length
is
not
None
else
None
progress
=
tqdm
(
unit
=
"B"
,
total
=
total
,
initial
=
resume_size
)
progress
=
tqdm
(
unit
=
"B"
,
unit_scale
=
True
,
total
=
total
,
initial
=
resume_size
,
desc
=
"Downloading"
)
for
chunk
in
response
.
iter_content
(
chunk_size
=
1024
):
for
chunk
in
response
.
iter_content
(
chunk_size
=
1024
):
if
chunk
:
# filter out keep-alive new chunks
if
chunk
:
# filter out keep-alive new chunks
progress
.
update
(
len
(
chunk
))
progress
.
update
(
len
(
chunk
))
...
...
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