Skip to content

Commit

Permalink
Hotfix cyclical deps and zips (#358)
Browse files Browse the repository at this point in the history
* fixed bug with cyclical dependencies and zip files

* version bump
  • Loading branch information
Fl4m3Ph03n1x authored Feb 23, 2022
1 parent 61c2091 commit 149d614
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 14 deletions.
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"

0 comments on commit 149d614

Please sign in to comment.