Skip to content

Commit

Permalink
fix: remove import from studio in init
Browse files Browse the repository at this point in the history
  • Loading branch information
JohannesWesch authored and MerlinKallenbornAA committed Oct 30, 2024
1 parent dc16df4 commit 99bfc5f
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 8 deletions.
1 change: 0 additions & 1 deletion src/intelligence_layer/connectors/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,5 @@
QdrantInMemoryRetriever as QdrantInMemoryRetriever,
)
from .retrievers.qdrant_in_memory_retriever import RetrieverType as RetrieverType
from .studio.studio import StudioClient as StudioClient

__all__ = [symbol for symbol in dir() if symbol and symbol[0].isupper()]
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
from intelligence_layer.connectors import (
DataClient,
SerializableDict,
StudioClient,
)
from intelligence_layer.connectors.studio.studio import StudioClient
from intelligence_layer.core import Input
from intelligence_layer.evaluation import (
Dataset,
Expand Down
2 changes: 1 addition & 1 deletion src/intelligence_layer/evaluation/run/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from typing import Generic, Optional, cast
from uuid import uuid4

from dict_hash import dict_hash # type: ignore
from dict_hash import dict_hash
from pydantic import JsonValue

from intelligence_layer.connectors.base.json_serializable import (
Expand Down
34 changes: 29 additions & 5 deletions tests/connectors/studio/test_studio.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from dotenv import load_dotenv
from pytest import fixture

from intelligence_layer.connectors import StudioClient
from intelligence_layer.connectors.studio.studio import StudioClient
from intelligence_layer.core import ExportedSpan, InMemoryTracer, Task, TaskSpan
from intelligence_layer.evaluation.dataset.domain import Example
from intelligence_layer.evaluation.dataset.in_memory_dataset_repository import (
Expand Down Expand Up @@ -60,6 +60,24 @@ def studio_client() -> StudioClient:
return client


@fixture
def examples() -> Sequence[Example[str, str]]:
return [
Example(input="input_str", expected_output="output_str"),
Example(input="input_str2", expected_output="output_str2"),
]


@fixture
def labels() -> set[str]:
return {"label1", "label2"}


@fixture
def metadata() -> dict[str, Any]:
return {"key": "value"}


def test_cannot_connect_to_non_existing_project() -> None:
project_name = "non-existing-project"
with pytest.raises(ValueError, match=project_name):
Expand Down Expand Up @@ -157,11 +175,17 @@ def test_submit_from_tracer_works_with_empty_tracer(
assert len(empty_trace_id_list) == 0


def test_can_upload_dataset(studio_client: StudioClient) -> None:
example = Example(input="input_str", expected_output="output_str")
def test_can_upload_dataset(
studio_client: StudioClient,
examples: Sequence[Example[str, str]],
labels: set[str],
metadata: dict[str, Any],
) -> None:
dataset_repo = InMemoryDatasetRepository()
dataset = dataset_repo.create_dataset(examples=[example], dataset_name="my_dataset")
result = studio_client.submit_dataset(dataset=dataset, examples=[example])
dataset = dataset_repo.create_dataset(
examples, "my_dataset", labels=labels, metadata=metadata
)
result = studio_client.submit_dataset(dataset=dataset, examples=examples)

assert result == dataset.id

Expand Down

0 comments on commit 99bfc5f

Please sign in to comment.