Skip to content

Commit

Permalink
IL-407 raise error on non existent datasets
Browse files Browse the repository at this point in the history
  • Loading branch information
FelixFehseTNG committed Mar 27, 2024
1 parent 5005b18 commit 653621b
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def examples(
input_type: type[Input],
expected_output_type: type[ExpectedOutput],
) -> Iterable[Example[Input, ExpectedOutput]]:
if dataset_id not in self._datasets_and_examples:
if dataset_id not in self._datasets_and_examples.keys():
raise ValueError(
f"Repository does not contain a dataset with id: {dataset_id}"
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ def example_tracer(self, run_id: str, example_id: str) -> Tracer:
def example_outputs(
self, run_id: str, output_type: type[Output]
) -> Iterable[ExampleOutput[Output]]:
if run_id not in self._run_overviews.keys():
raise ValueError(f"Repository does not contain a run with id: {run_id}")

return (
cast(ExampleOutput[Output], example_output)
for example_output in sorted(
Expand Down
9 changes: 9 additions & 0 deletions tests/connectors/argilla/test_argilla_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@
from typing import Callable, Iterable, Sequence, TypeVar
from uuid import uuid4

import pytest
from dotenv import load_dotenv
from pydantic import BaseModel
from pytest import fixture
from requests import HTTPError

from intelligence_layer.connectors.argilla.argilla_client import (
ArgillaClient,
Expand Down Expand Up @@ -110,6 +112,13 @@ def long_qa_records(
return records


def test_error_on_non_existent_dataset(
argilla_client: DefaultArgillaClient,
) -> None:
with pytest.raises(HTTPError):
list(argilla_client.records("non_existent_dataset_id"))


def test_records_returns_records_previously_added(
argilla_client: DefaultArgillaClient,
qa_dataset_id: str,
Expand Down
7 changes: 3 additions & 4 deletions tests/evaluation/test_hugging_face_dataset_repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,10 @@ def test_examples_returns_an_empty_list_for_not_existing_dataset_id(
def test_example_returns_none_for_not_existing_ids(
hugging_face_dataset_repository: HuggingFaceDatasetRepository,
) -> None:
assert (
with pytest.raises(ValueError):
hugging_face_dataset_repository.example(
"not-existing-dataset-id", "not-existing-example-id", str, str
)
is None
)


def test_delete_dataset_does_not_fail_for_not_existing_dataset_id(
Expand Down Expand Up @@ -165,7 +163,8 @@ def test_hugging_face_repository_supports_all_operations_for_created_dataset(

# deleting an existing dataset works
hugging_face_repository_.delete_dataset(dataset.id)
assert hugging_face_repository_.examples(dataset.id, str, str) == []
with pytest.raises(ValueError):
hugging_face_repository_.examples(dataset.id, str, str)
assert hugging_face_repository_.dataset(dataset.id) is None


Expand Down

0 comments on commit 653621b

Please sign in to comment.