feat: convert Datasets API to use FastAPI router (#4359)

# What does this PR do?

Convert the Datasets API from webmethod decorators to FastAPI router
pattern.

Fixes: https://github.com/llamastack/llama-stack/issues/4344

## Test Plan
CI

Signed-off-by: Sébastien Han <seb@redhat.com>
This commit is contained in:
Sébastien Han 2025-12-15 20:23:04 +01:00 committed by GitHub
parent 56f946f3f5
commit 700663028f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
13 changed files with 716 additions and 335 deletions

View file

@ -655,7 +655,7 @@ paths:
get:
responses:
'200':
description: A ListDatasetsResponse.
description: A list of dataset objects.
content:
application/json:
schema:
@ -674,13 +674,13 @@ paths:
$ref: '#/components/responses/DefaultError'
tags:
- Datasets
summary: List Datasets
summary: List all datasets.
description: List all datasets.
operationId: list_datasets_v1beta_datasets_get
post:
responses:
'200':
description: A Dataset.
description: The registered dataset object.
content:
application/json:
schema:
@ -699,7 +699,7 @@ paths:
$ref: '#/components/responses/DefaultError'
tags:
- Datasets
summary: Register Dataset
summary: Register a new dataset.
description: Register a new dataset.
operationId: register_dataset_v1beta_datasets_post
requestBody:
@ -713,26 +713,26 @@ paths:
get:
responses:
'200':
description: A Dataset.
description: The dataset object.
content:
application/json:
schema:
$ref: '#/components/schemas/Dataset'
'400':
description: Bad Request
$ref: '#/components/responses/BadRequest400'
description: Bad Request
'429':
description: Too Many Requests
$ref: '#/components/responses/TooManyRequests429'
description: Too Many Requests
'500':
description: Internal Server Error
$ref: '#/components/responses/InternalServerError500'
description: Internal Server Error
default:
description: Default Response
$ref: '#/components/responses/DefaultError'
description: Default Response
tags:
- Datasets
summary: Get Dataset
summary: Get a dataset by its ID.
description: Get a dataset by its ID.
operationId: get_dataset_v1beta_datasets__dataset_id__get
parameters:
@ -741,26 +741,28 @@ paths:
required: true
schema:
type: string
description: 'Path parameter: dataset_id'
description: The ID of the dataset to get.
title: Dataset Id
description: The ID of the dataset to get.
delete:
responses:
'400':
description: Bad Request
$ref: '#/components/responses/BadRequest400'
description: Bad Request
'429':
description: Too Many Requests
$ref: '#/components/responses/TooManyRequests429'
description: Too Many Requests
'500':
description: Internal Server Error
$ref: '#/components/responses/InternalServerError500'
description: Internal Server Error
default:
description: Default Response
$ref: '#/components/responses/DefaultError'
description: Default Response
'204':
description: Successful Response
description: The dataset was successfully unregistered.
tags:
- Datasets
summary: Unregister Dataset
summary: Unregister a dataset by its ID.
description: Unregister a dataset by its ID.
operationId: unregister_dataset_v1beta_datasets__dataset_id__delete
parameters:
@ -769,7 +771,9 @@ paths:
required: true
schema:
type: string
description: 'Path parameter: dataset_id'
description: The ID of the dataset to unregister.
title: Dataset Id
description: The ID of the dataset to unregister.
deprecated: true
/v1alpha/eval/benchmarks:
get:
@ -7396,9 +7400,11 @@ components:
type: string
const: dataset
title: Type
description: Type of resource, always 'dataset' for datasets
default: dataset
purpose:
$ref: '#/components/schemas/DatasetPurpose'
description: Purpose of the dataset indicating its intended use
source:
oneOf:
- $ref: '#/components/schemas/URIDataSource'
@ -7406,6 +7412,7 @@ components:
- $ref: '#/components/schemas/RowsDataSource'
title: RowsDataSource
title: URIDataSource | RowsDataSource
description: Data source configuration for the dataset
discriminator:
propertyName: type
mapping:
@ -7430,6 +7437,7 @@ components:
type: string
const: rows
title: Type
description: The type of data source.
default: rows
rows:
items:
@ -7437,6 +7445,7 @@ components:
type: object
type: array
title: Rows
description: 'The dataset is stored in rows. E.g. [{"messages": [{"role": "user", "content": "Hello, world!"}, {"role": "assistant", "content": "Hello, world!"}]}]'
type: object
required:
- rows
@ -7448,10 +7457,12 @@ components:
type: string
const: uri
title: Type
description: The type of data source.
default: uri
uri:
type: string
title: Uri
description: The dataset can be obtained from a URI. E.g. "https://mywebsite.com/mydata.jsonl", "lsfs://mydata.jsonl", "data:csv;base64,{base64_content}"
type: object
required:
- uri
@ -7464,6 +7475,7 @@ components:
$ref: '#/components/schemas/Dataset'
type: array
title: Data
description: List of datasets
type: object
required:
- data
@ -8461,27 +8473,37 @@ components:
properties:
purpose:
$ref: '#/components/schemas/DatasetPurpose'
description: The purpose of the dataset.
source:
anyOf:
oneOf:
- $ref: '#/components/schemas/URIDataSource'
title: URIDataSource
- $ref: '#/components/schemas/RowsDataSource'
title: RowsDataSource
title: URIDataSource | RowsDataSource
description: The data source of the dataset.
discriminator:
propertyName: type
mapping:
rows: '#/components/schemas/RowsDataSource'
uri: '#/components/schemas/URIDataSource'
metadata:
anyOf:
- additionalProperties: true
type: object
- type: 'null'
description: The metadata for the dataset.
dataset_id:
anyOf:
- type: string
- type: 'null'
description: The ID of the dataset. If not provided, an ID will be generated.
type: object
required:
- purpose
- source
title: RegisterDatasetRequest
description: Request model for registering a dataset.
RegisterBenchmarkRequest:
properties:
benchmark_id:
@ -10314,6 +10336,28 @@ components:
- items
title: ConversationItemCreateRequest
type: object
GetDatasetRequest:
description: Request model for getting a dataset by ID.
properties:
dataset_id:
description: The ID of the dataset to get.
title: Dataset Id
type: string
required:
- dataset_id
title: GetDatasetRequest
type: object
UnregisterDatasetRequest:
description: Request model for unregistering a dataset.
properties:
dataset_id:
description: The ID of the dataset to unregister.
title: Dataset Id
type: string
required:
- dataset_id
title: UnregisterDatasetRequest
type: object
Api:
description: Enumeration of all available APIs in the Llama Stack system.
enum:

View file

@ -110,7 +110,7 @@ paths:
get:
responses:
'200':
description: A ListDatasetsResponse.
description: A list of dataset objects.
content:
application/json:
schema:
@ -129,33 +129,33 @@ paths:
$ref: '#/components/responses/DefaultError'
tags:
- Datasets
summary: List Datasets
summary: List all datasets.
description: List all datasets.
operationId: list_datasets_v1beta_datasets_get
/v1beta/datasets/{dataset_id}:
get:
responses:
'200':
description: A Dataset.
description: The dataset object.
content:
application/json:
schema:
$ref: '#/components/schemas/Dataset'
'400':
description: Bad Request
$ref: '#/components/responses/BadRequest400'
description: Bad Request
'429':
description: Too Many Requests
$ref: '#/components/responses/TooManyRequests429'
description: Too Many Requests
'500':
description: Internal Server Error
$ref: '#/components/responses/InternalServerError500'
description: Internal Server Error
default:
description: Default Response
$ref: '#/components/responses/DefaultError'
description: Default Response
tags:
- Datasets
summary: Get Dataset
summary: Get a dataset by its ID.
description: Get a dataset by its ID.
operationId: get_dataset_v1beta_datasets__dataset_id__get
parameters:
@ -164,7 +164,9 @@ paths:
required: true
schema:
type: string
description: 'Path parameter: dataset_id'
description: The ID of the dataset to get.
title: Dataset Id
description: The ID of the dataset to get.
/v1alpha/eval/benchmarks:
get:
responses:
@ -6659,9 +6661,11 @@ components:
type: string
const: dataset
title: Type
description: Type of resource, always 'dataset' for datasets
default: dataset
purpose:
$ref: '#/components/schemas/DatasetPurpose'
description: Purpose of the dataset indicating its intended use
source:
oneOf:
- $ref: '#/components/schemas/URIDataSource'
@ -6669,6 +6673,7 @@ components:
- $ref: '#/components/schemas/RowsDataSource'
title: RowsDataSource
title: URIDataSource | RowsDataSource
description: Data source configuration for the dataset
discriminator:
propertyName: type
mapping:
@ -6693,6 +6698,7 @@ components:
type: string
const: rows
title: Type
description: The type of data source.
default: rows
rows:
items:
@ -6700,6 +6706,7 @@ components:
type: object
type: array
title: Rows
description: 'The dataset is stored in rows. E.g. [{"messages": [{"role": "user", "content": "Hello, world!"}, {"role": "assistant", "content": "Hello, world!"}]}]'
type: object
required:
- rows
@ -6711,10 +6718,12 @@ components:
type: string
const: uri
title: Type
description: The type of data source.
default: uri
uri:
type: string
title: Uri
description: The dataset can be obtained from a URI. E.g. "https://mywebsite.com/mydata.jsonl", "lsfs://mydata.jsonl", "data:csv;base64,{base64_content}"
type: object
required:
- uri
@ -6727,6 +6736,7 @@ components:
$ref: '#/components/schemas/Dataset'
type: array
title: Data
description: List of datasets
type: object
required:
- data
@ -7585,6 +7595,41 @@ components:
- $ref: '#/components/schemas/RowsDataSource'
title: RowsDataSource
title: URIDataSource | RowsDataSource
RegisterDatasetRequest:
properties:
purpose:
$ref: '#/components/schemas/DatasetPurpose'
description: The purpose of the dataset.
source:
oneOf:
- $ref: '#/components/schemas/URIDataSource'
title: URIDataSource
- $ref: '#/components/schemas/RowsDataSource'
title: RowsDataSource
title: URIDataSource | RowsDataSource
description: The data source of the dataset.
discriminator:
propertyName: type
mapping:
rows: '#/components/schemas/RowsDataSource'
uri: '#/components/schemas/URIDataSource'
metadata:
anyOf:
- additionalProperties: true
type: object
- type: 'null'
description: The metadata for the dataset.
dataset_id:
anyOf:
- type: string
- type: 'null'
description: The ID of the dataset. If not provided, an ID will be generated.
type: object
required:
- purpose
- source
title: RegisterDatasetRequest
description: Request model for registering a dataset.
RegisterBenchmarkRequest:
properties:
benchmark_id:
@ -9208,6 +9253,28 @@ components:
- items
title: ConversationItemCreateRequest
type: object
GetDatasetRequest:
description: Request model for getting a dataset by ID.
properties:
dataset_id:
description: The ID of the dataset to get.
title: Dataset Id
type: string
required:
- dataset_id
title: GetDatasetRequest
type: object
UnregisterDatasetRequest:
description: Request model for unregistering a dataset.
properties:
dataset_id:
description: The ID of the dataset to unregister.
title: Dataset Id
type: string
required:
- dataset_id
title: UnregisterDatasetRequest
type: object
Api:
description: Enumeration of all available APIs in the Llama Stack system.
enum:

View file

@ -9186,9 +9186,11 @@ components:
type: string
const: dataset
title: Type
description: Type of resource, always 'dataset' for datasets
default: dataset
purpose:
$ref: '#/components/schemas/DatasetPurpose'
description: Purpose of the dataset indicating its intended use
source:
oneOf:
- $ref: '#/components/schemas/URIDataSource'
@ -9196,6 +9198,7 @@ components:
- $ref: '#/components/schemas/RowsDataSource'
title: RowsDataSource
title: URIDataSource | RowsDataSource
description: Data source configuration for the dataset
discriminator:
propertyName: type
mapping:
@ -9220,6 +9223,7 @@ components:
type: string
const: rows
title: Type
description: The type of data source.
default: rows
rows:
items:
@ -9227,6 +9231,7 @@ components:
type: object
type: array
title: Rows
description: 'The dataset is stored in rows. E.g. [{"messages": [{"role": "user", "content": "Hello, world!"}, {"role": "assistant", "content": "Hello, world!"}]}]'
type: object
required:
- rows
@ -9238,10 +9243,12 @@ components:
type: string
const: uri
title: Type
description: The type of data source.
default: uri
uri:
type: string
title: Uri
description: The dataset can be obtained from a URI. E.g. "https://mywebsite.com/mydata.jsonl", "lsfs://mydata.jsonl", "data:csv;base64,{base64_content}"
type: object
required:
- uri
@ -9254,6 +9261,7 @@ components:
$ref: '#/components/schemas/Dataset'
type: array
title: Data
description: List of datasets
type: object
required:
- data
@ -9965,6 +9973,41 @@ components:
- $ref: '#/components/schemas/RowsDataSource'
title: RowsDataSource
title: URIDataSource | RowsDataSource
RegisterDatasetRequest:
properties:
purpose:
$ref: '#/components/schemas/DatasetPurpose'
description: The purpose of the dataset.
source:
oneOf:
- $ref: '#/components/schemas/URIDataSource'
title: URIDataSource
- $ref: '#/components/schemas/RowsDataSource'
title: RowsDataSource
title: URIDataSource | RowsDataSource
description: The data source of the dataset.
discriminator:
propertyName: type
mapping:
rows: '#/components/schemas/RowsDataSource'
uri: '#/components/schemas/URIDataSource'
metadata:
anyOf:
- additionalProperties: true
type: object
- type: 'null'
description: The metadata for the dataset.
dataset_id:
anyOf:
- type: string
- type: 'null'
description: The ID of the dataset. If not provided, an ID will be generated.
type: object
required:
- purpose
- source
title: RegisterDatasetRequest
description: Request model for registering a dataset.
RegisterBenchmarkRequest:
properties:
benchmark_id:
@ -11797,6 +11840,28 @@ components:
- items
title: ConversationItemCreateRequest
type: object
GetDatasetRequest:
description: Request model for getting a dataset by ID.
properties:
dataset_id:
description: The ID of the dataset to get.
title: Dataset Id
type: string
required:
- dataset_id
title: GetDatasetRequest
type: object
UnregisterDatasetRequest:
description: Request model for unregistering a dataset.
properties:
dataset_id:
description: The ID of the dataset to unregister.
title: Dataset Id
type: string
required:
- dataset_id
title: UnregisterDatasetRequest
type: object
Api:
description: Enumeration of all available APIs in the Llama Stack system.
enum:

View file

@ -3268,7 +3268,7 @@ paths:
get:
responses:
'200':
description: A ListDatasetsResponse.
description: A list of dataset objects.
content:
application/json:
schema:
@ -3287,13 +3287,13 @@ paths:
$ref: '#/components/responses/DefaultError'
tags:
- Datasets
summary: List Datasets
summary: List all datasets.
description: List all datasets.
operationId: list_datasets_v1beta_datasets_get
post:
responses:
'200':
description: A Dataset.
description: The registered dataset object.
content:
application/json:
schema:
@ -3312,7 +3312,7 @@ paths:
$ref: '#/components/responses/DefaultError'
tags:
- Datasets
summary: Register Dataset
summary: Register a new dataset.
description: Register a new dataset.
operationId: register_dataset_v1beta_datasets_post
requestBody:
@ -3326,26 +3326,26 @@ paths:
get:
responses:
'200':
description: A Dataset.
description: The dataset object.
content:
application/json:
schema:
$ref: '#/components/schemas/Dataset'
'400':
description: Bad Request
$ref: '#/components/responses/BadRequest400'
description: Bad Request
'429':
description: Too Many Requests
$ref: '#/components/responses/TooManyRequests429'
description: Too Many Requests
'500':
description: Internal Server Error
$ref: '#/components/responses/InternalServerError500'
description: Internal Server Error
default:
description: Default Response
$ref: '#/components/responses/DefaultError'
description: Default Response
tags:
- Datasets
summary: Get Dataset
summary: Get a dataset by its ID.
description: Get a dataset by its ID.
operationId: get_dataset_v1beta_datasets__dataset_id__get
parameters:
@ -3354,26 +3354,28 @@ paths:
required: true
schema:
type: string
description: 'Path parameter: dataset_id'
description: The ID of the dataset to get.
title: Dataset Id
description: The ID of the dataset to get.
delete:
responses:
'400':
description: Bad Request
$ref: '#/components/responses/BadRequest400'
description: Bad Request
'429':
description: Too Many Requests
$ref: '#/components/responses/TooManyRequests429'
description: Too Many Requests
'500':
description: Internal Server Error
$ref: '#/components/responses/InternalServerError500'
description: Internal Server Error
default:
description: Default Response
$ref: '#/components/responses/DefaultError'
description: Default Response
'204':
description: Successful Response
description: The dataset was successfully unregistered.
tags:
- Datasets
summary: Unregister Dataset
summary: Unregister a dataset by its ID.
description: Unregister a dataset by its ID.
operationId: unregister_dataset_v1beta_datasets__dataset_id__delete
parameters:
@ -3382,7 +3384,9 @@ paths:
required: true
schema:
type: string
description: 'Path parameter: dataset_id'
description: The ID of the dataset to unregister.
title: Dataset Id
description: The ID of the dataset to unregister.
deprecated: true
/v1alpha/eval/benchmarks:
get:
@ -10570,9 +10574,11 @@ components:
type: string
const: dataset
title: Type
description: Type of resource, always 'dataset' for datasets
default: dataset
purpose:
$ref: '#/components/schemas/DatasetPurpose'
description: Purpose of the dataset indicating its intended use
source:
oneOf:
- $ref: '#/components/schemas/URIDataSource'
@ -10580,6 +10586,7 @@ components:
- $ref: '#/components/schemas/RowsDataSource'
title: RowsDataSource
title: URIDataSource | RowsDataSource
description: Data source configuration for the dataset
discriminator:
propertyName: type
mapping:
@ -10604,6 +10611,7 @@ components:
type: string
const: rows
title: Type
description: The type of data source.
default: rows
rows:
items:
@ -10611,6 +10619,7 @@ components:
type: object
type: array
title: Rows
description: 'The dataset is stored in rows. E.g. [{"messages": [{"role": "user", "content": "Hello, world!"}, {"role": "assistant", "content": "Hello, world!"}]}]'
type: object
required:
- rows
@ -10622,10 +10631,12 @@ components:
type: string
const: uri
title: Type
description: The type of data source.
default: uri
uri:
type: string
title: Uri
description: The dataset can be obtained from a URI. E.g. "https://mywebsite.com/mydata.jsonl", "lsfs://mydata.jsonl", "data:csv;base64,{base64_content}"
type: object
required:
- uri
@ -10638,6 +10649,7 @@ components:
$ref: '#/components/schemas/Dataset'
type: array
title: Data
description: List of datasets
type: object
required:
- data
@ -11635,27 +11647,37 @@ components:
properties:
purpose:
$ref: '#/components/schemas/DatasetPurpose'
description: The purpose of the dataset.
source:
anyOf:
oneOf:
- $ref: '#/components/schemas/URIDataSource'
title: URIDataSource
- $ref: '#/components/schemas/RowsDataSource'
title: RowsDataSource
title: URIDataSource | RowsDataSource
description: The data source of the dataset.
discriminator:
propertyName: type
mapping:
rows: '#/components/schemas/RowsDataSource'
uri: '#/components/schemas/URIDataSource'
metadata:
anyOf:
- additionalProperties: true
type: object
- type: 'null'
description: The metadata for the dataset.
dataset_id:
anyOf:
- type: string
- type: 'null'
description: The ID of the dataset. If not provided, an ID will be generated.
type: object
required:
- purpose
- source
title: RegisterDatasetRequest
description: Request model for registering a dataset.
RegisterBenchmarkRequest:
properties:
benchmark_id:
@ -13488,6 +13510,28 @@ components:
- items
title: ConversationItemCreateRequest
type: object
GetDatasetRequest:
description: Request model for getting a dataset by ID.
properties:
dataset_id:
description: The ID of the dataset to get.
title: Dataset Id
type: string
required:
- dataset_id
title: GetDatasetRequest
type: object
UnregisterDatasetRequest:
description: Request model for unregistering a dataset.
properties:
dataset_id:
description: The ID of the dataset to unregister.
title: Dataset Id
type: string
required:
- dataset_id
title: UnregisterDatasetRequest
type: object
Api:
description: Enumeration of all available APIs in the Llama Stack system.
enum: