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

TIP-3025 Update get database #818

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
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
16 changes: 7 additions & 9 deletions src/python/dxpy/bindings/dxdatabase_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ def print_progress(bytes_downloaded, file_size, action="Downloaded"):
else:
dxdatabase = DXDatabase(dxid, project=(project if project != DXFile.NO_PROJECT_HINT else None))

do_debug("dxdatabase_functions.py _download_dxdatabasefile - dxdatabase: {}".format(dxdatabase))
do_debug("dxdatabase_functions.py _download_dxdatabasefile - dxdatabase: {}".format(dxdatabase))

if describe_output and describe_output.get("parts") is not None:
dxdatabase_desc = describe_output
Expand All @@ -195,14 +195,14 @@ def print_progress(bytes_downloaded, file_size, action="Downloaded"):
do_debug("dxdatabase_functions.py _download_dxdatabasefile - parts {}".format(parts))

# Create proper destination path, including any subdirectories needed within path.
ensure_local_dir(filename);
ensure_local_dir(filename)
dest_path = os.path.join(filename, src_filename)
dest_dir_idx = dest_path.rfind("/");
dest_dir_idx = dest_path.rfind("/")
if dest_dir_idx != -1:
dest_dir = dest_path[:dest_dir_idx]
ensure_local_dir(dest_dir)
ensure_local_dir(dest_dir)

do_debug("dxdatabase_functions.py _download_dxdatabasefile - dest_path {}".format(dest_path))
do_debug("dxdatabase_functions.py _download_dxdatabasefile - dest_path {}".format(dest_path))

if append:
fh = open(dest_path, "ab")
Expand All @@ -219,11 +219,9 @@ def get_chunk(part_id_to_get, start, end):
do_debug("dxdatabase_functions.py get_chunk - start {}, end {}, part id {}".format(start, end, part_id_to_get))
url, headers = dxdatabase.get_download_url(src_filename=src_filename, project=project, **kwargs)
# No sub ranges for database file downloads
# 'url' is the s3 URL, so read again to get data
sub_range = False
data_url = dxpy._dxhttp_read_range(url, headers, start, end, FILE_REQUEST_TIMEOUT, sub_range)
do_debug("dxdatabase_functions.py get_chunk - data_url = {}".format(data_url))
# 'data_url' is the s3 URL, so read again, just like in DNAxFileSystem
data = dxpy._dxhttp_read_range(data_url, headers, start, end, FILE_REQUEST_TIMEOUT, sub_range)
data = dxpy._dxhttp_read_range(url, headers, start, end, FILE_REQUEST_TIMEOUT, sub_range)
return part_id_to_get, data

def chunk_requests():
Expand Down