Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
combo
Manage
Activity
Members
Labels
Plan
Issues
20
Issue boards
Milestones
Wiki
Redmine
Code
Merge requests
2
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Syntactic Tools
combo
Commits
f3f0c4a8
Commit
f3f0c4a8
authored
4 years ago
by
Mateusz Klimaszewski
Browse files
Options
Downloads
Patches
Plain Diff
Cleaner download bar.
parent
8d0fd6c9
Branches
Branches containing commit
Tags
Tags containing commit
2 merge requests
!20
Release 1.0.0b2.
,
!19
Release 1.0.0b2.
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
combo/utils/download.py
+6
-7
6 additions, 7 deletions
combo/utils/download.py
with
6 additions
and
7 deletions
combo/utils/download.py
+
6
−
7
View file @
f3f0c4a8
import
errno
import
errno
import
logging
import
logging
import
math
import
os
import
os
import
requests
import
requests
...
@@ -23,18 +22,18 @@ def download_file(model_name, force=False):
...
@@ -23,18 +22,18 @@ def download_file(model_name, force=False):
if
os
.
path
.
exists
(
location
)
and
not
force
:
if
os
.
path
.
exists
(
location
)
and
not
force
:
logger
.
debug
(
"
Using cached model.
"
)
logger
.
debug
(
"
Using cached model.
"
)
return
location
return
location
chunk_size
=
1024
*
10
chunk_size
=
1024
logger
.
info
(
url
)
logger
.
info
(
url
)
try
:
try
:
with
_requests_retry_session
(
retries
=
2
).
get
(
url
,
stream
=
True
)
as
r
:
with
_requests_retry_session
(
retries
=
2
).
get
(
url
,
stream
=
True
)
as
r
:
total_length
=
math
.
ceil
(
int
(
r
.
headers
.
get
(
"
content-length
"
))
/
chunk_size
)
pbar
=
tqdm
.
tqdm
(
unit
=
"
B
"
,
total
=
int
(
r
.
headers
.
get
(
"
content-length
"
)),
unit_divisor
=
chunk_size
,
unit_scale
=
True
)
with
open
(
location
,
"
wb
"
)
as
f
:
with
open
(
location
,
"
wb
"
)
as
f
:
with
tqdm
.
tqdm
(
total
=
total_length
)
as
pbar
:
with
pbar
:
for
chunk
in
r
.
raw
.
stream
(
chunk_size
,
decode_content
=
Fals
e
):
for
chunk
in
r
.
iter_content
(
chunk_siz
e
):
if
chunk
:
if
chunk
:
f
.
write
(
chunk
)
f
.
write
(
chunk
)
f
.
flush
()
pbar
.
update
(
len
(
chunk
))
pbar
.
update
(
1
)
except
exceptions
.
RetryError
:
except
exceptions
.
RetryError
:
raise
ConnectionError
(
f
"
Couldn
'
t find or download model
{
model_name
}
.tar.gz.
"
raise
ConnectionError
(
f
"
Couldn
'
t find or download model
{
model_name
}
.tar.gz.
"
"
Check if model name is correct or try again later!
"
)
"
Check if model name is correct or try again later!
"
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment