File tree Expand file tree Collapse file tree 3 files changed +13
-14
lines changed Expand file tree Collapse file tree 3 files changed +13
-14
lines changed Original file line number Diff line number Diff line change 88
99import requests
1010from requests import Response
11- from requests .packages .urllib3 .response import HTTPResponse
1211
1312from darwin .config import Config
1413from darwin .dataset import RemoteDataset
@@ -782,7 +781,7 @@ def instantitate_item(self, item_id: int) -> int:
782781
783782 return id
784783
785- def fetch_binary (self , url : str ) -> HTTPResponse :
784+ def fetch_binary (self , url : str ) -> Response :
786785 """
787786 Fetches binary data from the given url via a stream.
788787
@@ -793,11 +792,11 @@ def fetch_binary(self, url: str) -> HTTPResponse:
793792
794793 Returns
795794 -------
796- HTTPResponse
797- The data to be saved .
795+ Response
796+ ``request``'s Response object .
798797 """
799798 response : Response = cast (Response , self ._get_raw_from_full_url (url , stream = True ))
800- return response . raw
799+ return response
801800
802801 @classmethod
803802 def local (cls , team_slug : Optional [str ] = None ) -> "Client" :
Original file line number Diff line number Diff line change 11import datetime
2- import shutil
32from pathlib import Path
4- from typing import TYPE_CHECKING , Any , Dict , Optional
3+ from typing import Any , Dict , Optional
54
65from darwin .dataset .identifier import DatasetIdentifier
7-
8- if TYPE_CHECKING :
9- from darwin .client import Client
6+ from requests import Response
107
118
129class Release :
@@ -194,12 +191,15 @@ def download_zip(self, path: Path) -> Path:
194191 if not self .url :
195192 raise ValueError ("Release must have a valid url to download the zip." )
196193
194+ from darwin .client import Client
195+
197196 config_path : Path = Path .home () / ".darwin" / "config.yaml"
198197 client : Client = Client .from_config (config_path = config_path , team_slug = self .team_slug )
199198
200- with client .fetch_binary (self .url ) as data :
201- with open (path , "wb" ) as download_file :
202- shutil .copyfileobj (data , download_file )
199+ data : Response = client .fetch_binary (self .url )
200+ with open (path , "wb" ) as download_file :
201+ for chunk in data .iter_content (chunk_size = 8192 ):
202+ download_file .write (chunk )
203203
204204 return path
205205
Original file line number Diff line number Diff line change 1- __version__ = "0.7.8 "
1+ __version__ = "0.7.9 "
You can’t perform that action at this time.
0 commit comments