Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix downloading files in windows #330

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions wfdb/io/download.py
Original file line number Diff line number Diff line change
Expand Up @@ -511,10 +511,7 @@ def dl_files(db, dl_dir, files, keep_subdirs=True, overwrite=False):
make_local_dirs(dl_dir, dl_inputs, keep_subdirs)

print('Downloading files...')
# Create multiple processes to download files.
# Limit to 2 connections to avoid overloading the server
pool = multiprocessing.Pool(processes=2)
pool.map(dl_pn_file, dl_inputs)
dl_pn_file(dl_inputs)
print('Finished downloading files')

return
19 changes: 13 additions & 6 deletions wfdb/io/record.py
Original file line number Diff line number Diff line change
Expand Up @@ -4469,7 +4469,7 @@ def is_monotonic(full_list):


def dl_database(db_dir, dl_dir, records='all', annotators='all',
keep_subdirs=True, overwrite=False):
keep_subdirs=True, overwrite=False, use_multiprocess=True):
"""
Download WFDB record (and optionally annotation) files from a
PhysioNet database. The database must contain a 'RECORDS' file in
Expand Down Expand Up @@ -4509,6 +4509,8 @@ def dl_database(db_dir, dl_dir, records='all', annotators='all',
file is smaller, the file will be assumed to be partially
downloaded and the remaining bytes will be downloaded and
appended.
use_multiprocess : bool, optional
If True, multiprocess package is used to download files.

Returns
-------
Expand All @@ -4525,7 +4527,8 @@ def dl_database(db_dir, dl_dir, records='all', annotators='all',
db_dir = posixpath.join(dir_list[0], get_version(dir_list[0]), *dir_list[1:])
else:
db_dir = posixpath.join(db_dir, get_version(db_dir))
db_url = posixpath.join(download.PN_CONTENT_URL, db_dir) + '/'

db_url = posixpath.join(download.PN_CONTENT_URL, db_dir)
# Check if the database is valid
_url.openurl(db_url, check_access=True)

Expand Down Expand Up @@ -4596,10 +4599,14 @@ def dl_database(db_dir, dl_dir, records='all', annotators='all',
download.make_local_dirs(dl_dir, dl_inputs, keep_subdirs)

print('Downloading files...')
# Create multiple processes to download files.
# Limit to 2 connections to avoid overloading the server
pool = multiprocessing.Pool(processes=2)
pool.map(download.dl_pn_file, dl_inputs)
if use_multiprocess:
# Create multiple processes to download files.
# Limit to 2 connections to avoid overloading the server
pool = multiprocessing.Pool(processes=2)
pool.map(download.dl_pn_file, dl_inputs)
else:
for input in dl_inputs:
download.dl_pn_file(input)
print('Finished downloading files')

return