Skip to content
Merged
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
9 changes: 4 additions & 5 deletions darwin/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

import requests
from requests import Response
from requests.packages.urllib3.response import HTTPResponse

from darwin.config import Config
from darwin.dataset import RemoteDataset
Expand Down Expand Up @@ -782,7 +781,7 @@ def instantitate_item(self, item_id: int) -> int:

return id

def fetch_binary(self, url: str) -> HTTPResponse:
def fetch_binary(self, url: str) -> Response:
"""
Fetches binary data from the given url via a stream.

Expand All @@ -793,11 +792,11 @@ def fetch_binary(self, url: str) -> HTTPResponse:

Returns
-------
HTTPResponse
The data to be saved.
Response
``request``'s Response object.
"""
response: Response = cast(Response, self._get_raw_from_full_url(url, stream=True))
return response.raw
return response

@classmethod
def local(cls, team_slug: Optional[str] = None) -> "Client":
Expand Down
16 changes: 8 additions & 8 deletions darwin/dataset/release.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
import datetime
import shutil
from pathlib import Path
from typing import TYPE_CHECKING, Any, Dict, Optional
from typing import Any, Dict, Optional

from darwin.dataset.identifier import DatasetIdentifier

if TYPE_CHECKING:
from darwin.client import Client
from requests import Response


class Release:
Expand Down Expand Up @@ -194,12 +191,15 @@ def download_zip(self, path: Path) -> Path:
if not self.url:
raise ValueError("Release must have a valid url to download the zip.")

from darwin.client import Client

config_path: Path = Path.home() / ".darwin" / "config.yaml"
client: Client = Client.from_config(config_path=config_path, team_slug=self.team_slug)

with client.fetch_binary(self.url) as data:
with open(path, "wb") as download_file:
shutil.copyfileobj(data, download_file)
data: Response = client.fetch_binary(self.url)
with open(path, "wb") as download_file:
for chunk in data.iter_content(chunk_size=8192):
download_file.write(chunk)

return path

Expand Down
2 changes: 1 addition & 1 deletion darwin/version/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.7.8"
__version__ = "0.7.9"