Skip to content

Commit 149d614

Browse files
authored
Hotfix cyclical deps and zips (#358)
* fixed bug with cyclical dependencies and zip files * version bump
1 parent 61c2091 commit 149d614

File tree

3 files changed

+13
-14
lines changed

3 files changed

+13
-14
lines changed

darwin/client.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99
import requests
1010
from requests import Response
11-
from requests.packages.urllib3.response import HTTPResponse
1211

1312
from darwin.config import Config
1413
from 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":

darwin/dataset/release.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11
import datetime
2-
import shutil
32
from pathlib import Path
4-
from typing import TYPE_CHECKING, Any, Dict, Optional
3+
from typing import Any, Dict, Optional
54

65
from darwin.dataset.identifier import DatasetIdentifier
7-
8-
if TYPE_CHECKING:
9-
from darwin.client import Client
6+
from requests import Response
107

118

129
class 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

darwin/version/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "0.7.8"
1+
__version__ = "0.7.9"

0 commit comments

Comments
 (0)