Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
combo
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Redmine
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Syntactic Tools
combo
Commits
f3f0c4a8
Commit
f3f0c4a8
authored
Jan 11, 2021
by
Mateusz Klimaszewski
Browse files
Options
Downloads
Patches
Plain Diff
Cleaner download bar.
parent
8d0fd6c9
No related branches found
No related tags found
2 merge requests
!20
Release 1.0.0b2.
,
!19
Release 1.0.0b2.
Changes
1
Show 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
logging
import
math
import
os
import
requests
...
...
@@ -23,18 +22,18 @@ def download_file(model_name, force=False):
if
os
.
path
.
exists
(
location
)
and
not
force
:
logger
.
debug
(
"
Using cached model.
"
)
return
location
chunk_size
=
1024
*
10
chunk_size
=
1024
logger
.
info
(
url
)
try
:
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
tqdm
.
tqdm
(
total
=
total_length
)
as
pbar
:
for
chunk
in
r
.
raw
.
stream
(
chunk_size
,
decode_content
=
Fals
e
):
with
pbar
:
for
chunk
in
r
.
iter_content
(
chunk_siz
e
):
if
chunk
:
f
.
write
(
chunk
)
f
.
flush
()
pbar
.
update
(
1
)
pbar
.
update
(
len
(
chunk
))
except
exceptions
.
RetryError
:
raise
ConnectionError
(
f
"
Couldn
'
t find or download model
{
model_name
}
.tar.gz.
"
"
Check if model name is correct or try again later!
"
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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