mirror of
https://github.com/meta-llama/llama-stack.git
synced 2025-12-03 09:53:45 +00:00
Some checks failed
Integration Tests (Replay) / generate-matrix (push) Successful in 3s
SqlStore Integration Tests / test-postgres (3.12) (push) Failing after 0s
Integration Auth Tests / test-matrix (oauth2_token) (push) Failing after 1s
SqlStore Integration Tests / test-postgres (3.13) (push) Failing after 0s
Test External Providers Installed via Module / test-external-providers-from-module (venv) (push) Has been skipped
Test Llama Stack Build / generate-matrix (push) Successful in 5s
Python Package Build Test / build (3.12) (push) Failing after 4s
API Conformance Tests / check-schema-compatibility (push) Successful in 12s
Test llama stack list-deps / generate-matrix (push) Successful in 29s
Test Llama Stack Build / build-single-provider (push) Successful in 33s
Test llama stack list-deps / list-deps-from-config (push) Successful in 32s
UI Tests / ui-tests (22) (push) Successful in 39s
Test Llama Stack Build / build (push) Successful in 39s
Test llama stack list-deps / show-single-provider (push) Successful in 46s
Python Package Build Test / build (3.13) (push) Failing after 44s
Test External API and Providers / test-external (venv) (push) Failing after 44s
Vector IO Integration Tests / test-matrix (push) Failing after 56s
Test llama stack list-deps / list-deps (push) Failing after 47s
Unit Tests / unit-tests (3.12) (push) Failing after 1m42s
Unit Tests / unit-tests (3.13) (push) Failing after 1m55s
Test Llama Stack Build / build-ubi9-container-distribution (push) Successful in 2m0s
Test Llama Stack Build / build-custom-container-distribution (push) Successful in 2m2s
Integration Tests (Replay) / Integration Tests (, , , client=, ) (push) Failing after 2m42s
Pre-commit / pre-commit (push) Successful in 5m17s
# What does this PR do? the directory structure was src/llama-stack-api/llama_stack_api instead it should just be src/llama_stack_api to match the other packages. update the structure and pyproject/linting config --------- Signed-off-by: Charlie Doern <cdoern@redhat.com> Co-authored-by: Ashwin Bharambe <ashwin.bharambe@gmail.com>
113 lines
3.7 KiB
Python
113 lines
3.7 KiB
Python
# Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
# All rights reserved.
|
|
#
|
|
# This source code is licensed under the terms described in the LICENSE file in
|
|
# the root directory of this source tree.
|
|
|
|
from typing import Any
|
|
|
|
import aiohttp
|
|
|
|
from llama_stack_api import URL, Dataset, PaginatedResponse, ParamType
|
|
|
|
from .config import NvidiaDatasetIOConfig
|
|
|
|
|
|
class NvidiaDatasetIOAdapter:
|
|
"""Nvidia NeMo DatasetIO API."""
|
|
|
|
def __init__(self, config: NvidiaDatasetIOConfig):
|
|
self.config = config
|
|
self.headers = {}
|
|
|
|
async def _make_request(
|
|
self,
|
|
method: str,
|
|
path: str,
|
|
headers: dict[str, Any] | None = None,
|
|
params: dict[str, Any] | None = None,
|
|
json: dict[str, Any] | None = None,
|
|
**kwargs,
|
|
) -> dict[str, Any]:
|
|
"""Helper method to make HTTP requests to the Customizer API."""
|
|
url = f"{self.config.datasets_url}{path}"
|
|
request_headers = self.headers.copy()
|
|
|
|
# Set default Content-Type for JSON requests
|
|
if json is not None:
|
|
request_headers["Content-Type"] = "application/json"
|
|
|
|
if headers:
|
|
request_headers.update(headers)
|
|
|
|
async with aiohttp.ClientSession(headers=request_headers) as session:
|
|
async with session.request(method, url, params=params, json=json, **kwargs) as response:
|
|
if response.status != 200:
|
|
error_data = await response.json()
|
|
raise Exception(f"API request failed: {error_data}")
|
|
return await response.json()
|
|
|
|
async def register_dataset(
|
|
self,
|
|
dataset_def: Dataset,
|
|
) -> Dataset:
|
|
"""Register a new dataset.
|
|
|
|
Args:
|
|
dataset_def [Dataset]: The dataset definition.
|
|
dataset_id [str]: The ID of the dataset.
|
|
source [DataSource]: The source of the dataset.
|
|
metadata [Dict[str, Any]]: The metadata of the dataset.
|
|
format [str]: The format of the dataset.
|
|
description [str]: The description of the dataset.
|
|
Returns:
|
|
Dataset
|
|
"""
|
|
# add warnings for unsupported params
|
|
request_body = {
|
|
"name": dataset_def.identifier,
|
|
"namespace": self.config.dataset_namespace,
|
|
"files_url": dataset_def.source.uri,
|
|
"project": self.config.project_id,
|
|
}
|
|
if dataset_def.metadata:
|
|
request_body["format"] = dataset_def.metadata.get("format")
|
|
request_body["description"] = dataset_def.metadata.get("description")
|
|
await self._make_request(
|
|
"POST",
|
|
"/v1/datasets",
|
|
json=request_body,
|
|
)
|
|
return dataset_def
|
|
|
|
async def update_dataset(
|
|
self,
|
|
dataset_id: str,
|
|
dataset_schema: dict[str, ParamType],
|
|
url: URL,
|
|
provider_dataset_id: str | None = None,
|
|
provider_id: str | None = None,
|
|
metadata: dict[str, Any] | None = None,
|
|
) -> None:
|
|
raise NotImplementedError("Not implemented")
|
|
|
|
async def unregister_dataset(
|
|
self,
|
|
dataset_id: str,
|
|
) -> None:
|
|
await self._make_request(
|
|
"DELETE",
|
|
f"/v1/datasets/{self.config.dataset_namespace}/{dataset_id}",
|
|
headers={"Accept": "application/json", "Content-Type": "application/json"},
|
|
)
|
|
|
|
async def iterrows(
|
|
self,
|
|
dataset_id: str,
|
|
start_index: int | None = None,
|
|
limit: int | None = None,
|
|
) -> PaginatedResponse:
|
|
raise NotImplementedError("Not implemented")
|
|
|
|
async def append_rows(self, dataset_id: str, rows: list[dict[str, Any]]) -> None:
|
|
raise NotImplementedError("Not implemented")
|