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
OpenDAS
dgl
Commits
02f8b6ce
Unverified
Commit
02f8b6ce
authored
Dec 21, 2023
by
Rhett Ying
Committed by
GitHub
Dec 21, 2023
Browse files
[dev] add progress bar for download() (#6800)
parent
80763d4b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
4 deletions
+11
-4
python/dgl/data/utils.py
python/dgl/data/utils.py
+11
-4
No files found.
python/dgl/data/utils.py
View file @
02f8b6ce
...
@@ -12,6 +12,7 @@ import networkx.algorithms as A
...
@@ -12,6 +12,7 @@ import networkx.algorithms as A
import
numpy
as
np
import
numpy
as
np
import
requests
import
requests
from
tqdm
import
tqdm
from
..
import
backend
as
F
from
..
import
backend
as
F
from
.graph_serialize
import
load_graphs
,
load_labels
,
save_graphs
from
.graph_serialize
import
load_graphs
,
load_labels
,
save_graphs
...
@@ -182,10 +183,16 @@ def download(
...
@@ -182,10 +183,16 @@ def download(
r
=
requests
.
get
(
url
,
stream
=
True
,
verify
=
verify_ssl
)
r
=
requests
.
get
(
url
,
stream
=
True
,
verify
=
verify_ssl
)
if
r
.
status_code
!=
200
:
if
r
.
status_code
!=
200
:
raise
RuntimeError
(
"Failed downloading url %s"
%
url
)
raise
RuntimeError
(
"Failed downloading url %s"
%
url
)
with
open
(
fname
,
"wb"
)
as
f
:
# Get the total file size.
for
chunk
in
r
.
iter_content
(
chunk_size
=
1024
):
total_size
=
int
(
r
.
headers
.
get
(
"content-length"
,
0
))
if
chunk
:
# filter out keep-alive new chunks
with
tqdm
(
f
.
write
(
chunk
)
total
=
total_size
,
unit
=
"B"
,
unit_scale
=
True
,
desc
=
fname
)
as
bar
:
with
open
(
fname
,
"wb"
)
as
f
:
for
chunk
in
r
.
iter_content
(
chunk_size
=
1024
):
if
chunk
:
# filter out keep-alive new chunks
f
.
write
(
chunk
)
bar
.
update
(
len
(
chunk
))
if
sha1_hash
and
not
check_sha1
(
fname
,
sha1_hash
):
if
sha1_hash
and
not
check_sha1
(
fname
,
sha1_hash
):
raise
UserWarning
(
raise
UserWarning
(
"File {} is downloaded but the content hash does not match."
"File {} is downloaded but the content hash does not match."
...
...
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