Skip to content

Commit b664564

Browse files
authored
feat: datasets api updates (#203)
# What does this PR do? - sync SDK [//]: # (If resolving an issue, uncomment and update the line below) [//]: # (Closes #[issue-number]) ## Test Plan - See llamastack/llama-stack#1573 [//]: # (## Documentation) [//]: # (- [ ] Added a Changelog entry if the change is significant)
1 parent 60fe95d commit b664564

21 files changed

+632
-726
lines changed

src/llama_stack_client/_client.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
scoring,
3535
shields,
3636
datasets,
37-
datasetio,
3837
inference,
3938
providers,
4039
telemetry,
@@ -90,7 +89,6 @@ class LlamaStackClient(SyncAPIClient):
9089
shields: shields.ShieldsResource
9190
synthetic_data_generation: synthetic_data_generation.SyntheticDataGenerationResource
9291
telemetry: telemetry.TelemetryResource
93-
datasetio: datasetio.DatasetioResource
9492
scoring: scoring.ScoringResource
9593
scoring_functions: scoring_functions.ScoringFunctionsResource
9694
benchmarks: benchmarks.BenchmarksResource
@@ -172,7 +170,6 @@ def __init__(
172170
self.shields = shields.ShieldsResource(self)
173171
self.synthetic_data_generation = synthetic_data_generation.SyntheticDataGenerationResource(self)
174172
self.telemetry = telemetry.TelemetryResource(self)
175-
self.datasetio = datasetio.DatasetioResource(self)
176173
self.scoring = scoring.ScoringResource(self)
177174
self.scoring_functions = scoring_functions.ScoringFunctionsResource(self)
178175
self.benchmarks = benchmarks.BenchmarksResource(self)
@@ -306,7 +303,6 @@ class AsyncLlamaStackClient(AsyncAPIClient):
306303
shields: shields.AsyncShieldsResource
307304
synthetic_data_generation: synthetic_data_generation.AsyncSyntheticDataGenerationResource
308305
telemetry: telemetry.AsyncTelemetryResource
309-
datasetio: datasetio.AsyncDatasetioResource
310306
scoring: scoring.AsyncScoringResource
311307
scoring_functions: scoring_functions.AsyncScoringFunctionsResource
312308
benchmarks: benchmarks.AsyncBenchmarksResource
@@ -388,7 +384,6 @@ def __init__(
388384
self.shields = shields.AsyncShieldsResource(self)
389385
self.synthetic_data_generation = synthetic_data_generation.AsyncSyntheticDataGenerationResource(self)
390386
self.telemetry = telemetry.AsyncTelemetryResource(self)
391-
self.datasetio = datasetio.AsyncDatasetioResource(self)
392387
self.scoring = scoring.AsyncScoringResource(self)
393388
self.scoring_functions = scoring_functions.AsyncScoringFunctionsResource(self)
394389
self.benchmarks = benchmarks.AsyncBenchmarksResource(self)
@@ -525,7 +520,6 @@ def __init__(self, client: LlamaStackClient) -> None:
525520
client.synthetic_data_generation
526521
)
527522
self.telemetry = telemetry.TelemetryResourceWithRawResponse(client.telemetry)
528-
self.datasetio = datasetio.DatasetioResourceWithRawResponse(client.datasetio)
529523
self.scoring = scoring.ScoringResourceWithRawResponse(client.scoring)
530524
self.scoring_functions = scoring_functions.ScoringFunctionsResourceWithRawResponse(client.scoring_functions)
531525
self.benchmarks = benchmarks.BenchmarksResourceWithRawResponse(client.benchmarks)
@@ -554,7 +548,6 @@ def __init__(self, client: AsyncLlamaStackClient) -> None:
554548
client.synthetic_data_generation
555549
)
556550
self.telemetry = telemetry.AsyncTelemetryResourceWithRawResponse(client.telemetry)
557-
self.datasetio = datasetio.AsyncDatasetioResourceWithRawResponse(client.datasetio)
558551
self.scoring = scoring.AsyncScoringResourceWithRawResponse(client.scoring)
559552
self.scoring_functions = scoring_functions.AsyncScoringFunctionsResourceWithRawResponse(
560553
client.scoring_functions
@@ -585,7 +578,6 @@ def __init__(self, client: LlamaStackClient) -> None:
585578
client.synthetic_data_generation
586579
)
587580
self.telemetry = telemetry.TelemetryResourceWithStreamingResponse(client.telemetry)
588-
self.datasetio = datasetio.DatasetioResourceWithStreamingResponse(client.datasetio)
589581
self.scoring = scoring.ScoringResourceWithStreamingResponse(client.scoring)
590582
self.scoring_functions = scoring_functions.ScoringFunctionsResourceWithStreamingResponse(
591583
client.scoring_functions
@@ -618,7 +610,6 @@ def __init__(self, client: AsyncLlamaStackClient) -> None:
618610
)
619611
)
620612
self.telemetry = telemetry.AsyncTelemetryResourceWithStreamingResponse(client.telemetry)
621-
self.datasetio = datasetio.AsyncDatasetioResourceWithStreamingResponse(client.datasetio)
622613
self.scoring = scoring.AsyncScoringResourceWithStreamingResponse(client.scoring)
623614
self.scoring_functions = scoring_functions.AsyncScoringFunctionsResourceWithStreamingResponse(
624615
client.scoring_functions

src/llama_stack_client/_models.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565
from ._constants import RAW_RESPONSE_HEADER
6666

6767
if TYPE_CHECKING:
68-
from pydantic_core.core_schema import ModelField, LiteralSchema, ModelFieldsSchema
68+
from pydantic_core.core_schema import ModelField, ModelSchema, LiteralSchema, ModelFieldsSchema
6969

7070
__all__ = ["BaseModel", "GenericModel"]
7171

@@ -646,15 +646,18 @@ def _build_discriminated_union_meta(*, union: type, meta_annotations: tuple[Any,
646646

647647
def _extract_field_schema_pv2(model: type[BaseModel], field_name: str) -> ModelField | None:
648648
schema = model.__pydantic_core_schema__
649+
if schema["type"] == "definitions":
650+
schema = schema["schema"]
651+
649652
if schema["type"] != "model":
650653
return None
651654

655+
schema = cast("ModelSchema", schema)
652656
fields_schema = schema["schema"]
653657
if fields_schema["type"] != "model-fields":
654658
return None
655659

656660
fields_schema = cast("ModelFieldsSchema", fields_schema)
657-
658661
field = fields_schema["fields"].get(field_name)
659662
if not field:
660663
return None
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
from typing import List, Generic, TypeVar, Optional
4+
from typing_extensions import override
5+
6+
from ._base_client import BasePage, PageInfo, BaseSyncPage, BaseAsyncPage
7+
8+
__all__ = ["SyncDatasetsIterrows", "AsyncDatasetsIterrows"]
9+
10+
_T = TypeVar("_T")
11+
12+
13+
class SyncDatasetsIterrows(BaseSyncPage[_T], BasePage[_T], Generic[_T]):
14+
data: List[_T]
15+
next_index: Optional[int] = None
16+
17+
@override
18+
def _get_page_items(self) -> List[_T]:
19+
data = self.data
20+
if not data:
21+
return []
22+
return data
23+
24+
@override
25+
def next_page_info(self) -> Optional[PageInfo]:
26+
next_index = self.next_index
27+
if not next_index:
28+
return None
29+
30+
return PageInfo(params={"start_index": next_index})
31+
32+
33+
class AsyncDatasetsIterrows(BaseAsyncPage[_T], BasePage[_T], Generic[_T]):
34+
data: List[_T]
35+
next_index: Optional[int] = None
36+
37+
@override
38+
def _get_page_items(self) -> List[_T]:
39+
data = self.data
40+
if not data:
41+
return []
42+
return data
43+
44+
@override
45+
def next_page_info(self) -> Optional[PageInfo]:
46+
next_index = self.next_index
47+
if not next_index:
48+
return None
49+
50+
return PageInfo(params={"start_index": next_index})

src/llama_stack_client/resources/__init__.py

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -80,14 +80,6 @@
8080
DatasetsResourceWithStreamingResponse,
8181
AsyncDatasetsResourceWithStreamingResponse,
8282
)
83-
from .datasetio import (
84-
DatasetioResource,
85-
AsyncDatasetioResource,
86-
DatasetioResourceWithRawResponse,
87-
AsyncDatasetioResourceWithRawResponse,
88-
DatasetioResourceWithStreamingResponse,
89-
AsyncDatasetioResourceWithStreamingResponse,
90-
)
9183
from .inference import (
9284
InferenceResource,
9385
AsyncInferenceResource,
@@ -300,12 +292,6 @@
300292
"AsyncTelemetryResourceWithRawResponse",
301293
"TelemetryResourceWithStreamingResponse",
302294
"AsyncTelemetryResourceWithStreamingResponse",
303-
"DatasetioResource",
304-
"AsyncDatasetioResource",
305-
"DatasetioResourceWithRawResponse",
306-
"AsyncDatasetioResourceWithRawResponse",
307-
"DatasetioResourceWithStreamingResponse",
308-
"AsyncDatasetioResourceWithStreamingResponse",
309295
"ScoringResource",
310296
"AsyncScoringResource",
311297
"ScoringResourceWithRawResponse",

0 commit comments

Comments
 (0)