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: updated file downloading to download only files that do not exis… #74

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from __future__ import annotations

import shutil
import tempfile
from concurrent.futures import ThreadPoolExecutor
from functools import partial
from itertools import repeat
Expand Down Expand Up @@ -258,17 +259,21 @@ def download_dataset_file(
Path: local file path
"""
local_path = output_directory.joinpath(foundry_file_path)

local_path.parent.mkdir(exist_ok=True, parents=True)
if local_path.exists():
return local_path
resp = self.api_get_file_in_view(
dataset_rid,
view,
foundry_file_path,
stream=True,
)
with local_path.open(mode="wb+") as out_file:

with tempfile.NamedTemporaryFile(mode='wb+') as out_file:
resp.raw.decode_content = True
shutil.copyfileobj(resp.raw, out_file)

shutil.move(out_file.name, local_path)
return local_path

def download_dataset_files(
Expand Down