Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rename dataset.urls to dataset.download_urls #284

Merged
merged 2 commits into from
Aug 17, 2023
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 4.20.2
- [#284] (https://github.com/cohere-ai/cohere-python/pull/284)
- Rename dataset urls to download_urls

## 4.20.1
- [#279] (https://github.com/cohere-ai/cohere-python/pull/279)
- Fix dataset listing key error
Expand Down
14 changes: 7 additions & 7 deletions cohere/responses/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class BaseDataset(CohereObject, JobWithStatus):
validation_error: Optional[str]
created_at: datetime
updated_at: datetime
urls: List[str]
download_urls: List[str]
size_bytes: int
_wait_fn: Callable[[], "Dataset"]

Expand All @@ -34,7 +34,7 @@ def __init__(
created_at: str,
updated_at: str,
validation_error: str = None,
urls: List[str] = None,
download_urls: List[str] = None,
wait_fn=None,
) -> None:
self.id = id
Expand All @@ -43,15 +43,15 @@ def __init__(
self.validation_status = validation_status
self.created_at = parse_datetime(created_at)
self.updated_at = parse_datetime(updated_at)
self.urls = urls
self.download_urls = download_urls
self._wait_fn = wait_fn
self.validation_error = validation_error

@classmethod
def from_dict(cls, data: Dict[str, Any], wait_fn) -> "Dataset":
urls = []
download_urls = []
if data["validation_status"] == "validated":
urls = [part.get("url") for part in data["dataset_parts"] if part.get("url")]
download_urls = [part.get("url") for part in data["dataset_parts"] if part.get("url")]

return cls(
id=data["id"],
Expand All @@ -60,7 +60,7 @@ def from_dict(cls, data: Dict[str, Any], wait_fn) -> "Dataset":
validation_status=data["validation_status"],
created_at=data["created_at"],
updated_at=data["updated_at"],
urls=urls,
download_urls=download_urls,
wait_fn=wait_fn,
validation_error=data.get("validation_error"),
)
Expand All @@ -74,7 +74,7 @@ def await_validation(self, timeout: Optional[float] = None, interval: float = 10
def open(self):
if self.validation_status != "validated":
raise CohereError(message="cannot open non-validated dataset")
for url in self.urls:
for url in self.download_urls:
resp = requests.get(url, stream=True)
for record in reader(resp.raw):
yield record
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "cohere"
version = "4.20.1"
version = "4.20.2"
description = ""
authors = ["Cohere"]
readme = "README.md"
Expand Down
2 changes: 1 addition & 1 deletion tests/async/test_async_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def check_result(dataset: AsyncDataset, status: Optional[str] = None):
assert dataset.validation_status == status

if status == "validated":
assert dataset.urls
assert dataset.download_urls
for row in dataset.open():
assert row

Expand Down
2 changes: 1 addition & 1 deletion tests/sync/test_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def check_result(self, dataset: Dataset, status: Optional[str] = None):
assert dataset.validation_status == status

if status == "validated":
assert dataset.urls
assert dataset.download_urls
for row in dataset.open():
assert row

Expand Down
Loading