Repository: v7labs/darwin-py

Issue:
darwin-py 0.7.11 causing `MissingConfig` issues
When I try using 0.7.11, I am getting an error when I run `dataset.pull`

It appears to be something with the release.py `download_zip` code passing config.yaml.  I checked my .darwin folder and I don't see a config.yaml so I'm sure that's why it's causing an issue, but not sure where that is supposed to come from.  

Here's a reproducible version you should be able to use
```
import darwin; print(darwin.__version__)
from darwin.client import Client

API_KEY = *your_key_here*
client = Client.from_api_key(API_KEY)

datasets={d.name:d for d in client.list_remote_datasets()}
dataset=datasets["kevin-tmp"]

release = dataset.get_release()
dataset.pull(release=release)
```

stack trace in 0.7.11: 
```
---------------------------------------------------------------------------
MissingConfig                             Traceback (most recent call last)
/tmp/ipykernel_277/279924910.py in <module>
     10 
     11 release = dataset.get_release()
---> 12 dataset.pull(release=release)

/opt/conda/lib/python3.7/site-packages/darwin/dataset/remote_dataset.py in pull(self, release, blocking, multi_threaded, only_annotations, force_replace, remove_extra, subset_filter_annotations_function, subset_folder_name, use_folders, video_frames)
    309             tmp_dir = Path(tmp_dir_str)
    310             # Download the release from Darwin
--> 311             zip_file_path = release.download_zip(tmp_dir / "dataset.zip")
    312             with zipfile.ZipFile(zip_file_path) as z:
    313                 # Extract annotations

/opt/conda/lib/python3.7/site-packages/darwin/dataset/release.py in download_zip(self, path)
    195 
    196         config_path: Path = Path.home() / ".darwin" / "config.yaml"
--> 197         client: Client = Client.from_config(config_path=config_path, team_slug=self.team_slug)
    198 
    199         data: Response = client.fetch_binary(self.url)

/opt/conda/lib/python3.7/site-packages/darwin/client.py in from_config(cls, config_path, team_slug)
    836         """
    837         if not config_path.exists():
--> 838             raise MissingConfig()
    839         config = Config(config_path)
    840 

MissingConfig:
```


Discussion:
Just did a little more testing and I actually can't run my code after v0.7.7 (0.7.7 works, but nothing after that does currently)
Hi @kevin-b1rd, thank you so much for opening this issue, which we have now triaged. 🙏 
We will keep you posted as soon as we have any updates! 🙂 

Resolving patch:
diff --git a/darwin/dataset/release.py b/darwin/dataset/release.py
--- a/darwin/dataset/release.py
+++ b/darwin/dataset/release.py
@@ -1,9 +1,10 @@
 import datetime
+import shutil
 from pathlib import Path
 from typing import Any, Dict, Optional
 
+import requests
 from darwin.dataset.identifier import DatasetIdentifier
-from requests import Response
 
 
 class Release:
@@ -191,15 +192,9 @@ 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)
-
-        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)
+        with requests.get(self.url, stream=True) as response:
+            with open(path, "wb") as download_file:
+                shutil.copyfileobj(response.raw, download_file)
 
         return path
 
diff --git a/darwin/version/__init__.py b/darwin/version/__init__.py
--- a/darwin/version/__init__.py
+++ b/darwin/version/__init__.py
@@ -1 +1 @@
-__version__ = "0.7.11"
+__version__ = "0.7.12"


Test patch:
diff --git a/tests/darwin/dataset/release_test.py b/tests/darwin/dataset/release_test.py
new file mode 100644
--- /dev/null
+++ b/tests/darwin/dataset/release_test.py
@@ -0,0 +1,32 @@
+import shutil
+from unittest.mock import patch
+
+import requests
+from darwin.dataset.release import Release
+from tests.fixtures import *
+
+
+@pytest.fixture
+def release(dataset_slug: str, team_slug: str) -> Release:
+    return Release(
+        dataset_slug=dataset_slug,
+        team_slug=team_slug,
+        version="latest",
+        name="test",
+        url="http://test.v7labs.com/",
+        export_date="now",
+        image_count=None,
+        class_count=None,
+        available=True,
+        latest=True,
+        format="darwin",
+    )
+
+
+def describe_release():
+    def it_downloads_zip(release: Release, tmp_path: Path):
+        with patch.object(requests, "get") as get:
+            with patch.object(shutil, "copyfileobj") as copyfileobj:
+                release.download_zip(tmp_path / "test.zip")
+                get.assert_called_once_with("http://test.v7labs.com/", stream=True)
+                copyfileobj.assert_called_once()