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>
140 lines
4.6 KiB
Python
140 lines
4.6 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.
|
|
|
|
import os
|
|
from unittest.mock import patch
|
|
|
|
import pytest
|
|
|
|
from llama_stack.providers.remote.datasetio.nvidia.config import NvidiaDatasetIOConfig
|
|
from llama_stack.providers.remote.datasetio.nvidia.datasetio import NvidiaDatasetIOAdapter
|
|
from llama_stack_api import Dataset, DatasetPurpose, ResourceType, URIDataSource
|
|
|
|
|
|
@pytest.fixture
|
|
def nvidia_adapter():
|
|
"""Fixture to set up NvidiaDatasetIOAdapter with mocked requests."""
|
|
os.environ["NVIDIA_DATASETS_URL"] = "http://nemo.test/datasets"
|
|
|
|
config = NvidiaDatasetIOConfig(
|
|
datasets_url=os.environ["NVIDIA_DATASETS_URL"], dataset_namespace="default", project_id="default"
|
|
)
|
|
adapter = NvidiaDatasetIOAdapter(config)
|
|
|
|
with patch(
|
|
"llama_stack.providers.remote.datasetio.nvidia.datasetio.NvidiaDatasetIOAdapter._make_request"
|
|
) as mock_make_request:
|
|
yield adapter, mock_make_request
|
|
|
|
|
|
def _assert_request(mock_call, expected_method, expected_path, expected_json=None):
|
|
"""Helper function to verify request details in mock calls."""
|
|
call_args = mock_call.call_args
|
|
|
|
assert call_args[0][0] == expected_method
|
|
assert call_args[0][1] == expected_path
|
|
|
|
if expected_json:
|
|
for key, value in expected_json.items():
|
|
assert call_args[1]["json"][key] == value
|
|
|
|
|
|
def test_register_dataset(nvidia_adapter, run_async):
|
|
adapter, mock_make_request = nvidia_adapter
|
|
mock_make_request.return_value = {
|
|
"id": "dataset-123456",
|
|
"name": "test-dataset",
|
|
"namespace": "default",
|
|
}
|
|
|
|
dataset_def = Dataset(
|
|
identifier="test-dataset",
|
|
type=ResourceType.dataset,
|
|
provider_resource_id="",
|
|
provider_id="",
|
|
purpose=DatasetPurpose.post_training_messages,
|
|
source=URIDataSource(uri="https://example.com/data.jsonl"),
|
|
metadata={"provider_id": "nvidia", "format": "jsonl", "description": "Test dataset description"},
|
|
)
|
|
|
|
run_async(adapter.register_dataset(dataset_def))
|
|
|
|
mock_make_request.assert_called_once()
|
|
_assert_request(
|
|
mock_make_request,
|
|
"POST",
|
|
"/v1/datasets",
|
|
expected_json={
|
|
"name": "test-dataset",
|
|
"namespace": "default",
|
|
"files_url": "https://example.com/data.jsonl",
|
|
"project": "default",
|
|
"format": "jsonl",
|
|
"description": "Test dataset description",
|
|
},
|
|
)
|
|
|
|
|
|
def test_unregister_dataset(nvidia_adapter, run_async):
|
|
adapter, mock_make_request = nvidia_adapter
|
|
mock_make_request.return_value = {
|
|
"message": "Resource deleted successfully.",
|
|
"id": "dataset-81RSQp7FKX3rdBtKvF9Skn",
|
|
"deleted_at": None,
|
|
}
|
|
dataset_id = "test-dataset"
|
|
|
|
run_async(adapter.unregister_dataset(dataset_id))
|
|
|
|
mock_make_request.assert_called_once()
|
|
_assert_request(mock_make_request, "DELETE", "/v1/datasets/default/test-dataset")
|
|
|
|
|
|
def test_register_dataset_with_custom_namespace_project(run_async):
|
|
"""Test with custom namespace and project configuration."""
|
|
os.environ["NVIDIA_DATASETS_URL"] = "http://nemo.test/datasets"
|
|
|
|
custom_config = NvidiaDatasetIOConfig(
|
|
datasets_url=os.environ["NVIDIA_DATASETS_URL"],
|
|
dataset_namespace="custom-namespace",
|
|
project_id="custom-project",
|
|
)
|
|
custom_adapter = NvidiaDatasetIOAdapter(custom_config)
|
|
|
|
with patch(
|
|
"llama_stack.providers.remote.datasetio.nvidia.datasetio.NvidiaDatasetIOAdapter._make_request"
|
|
) as mock_make_request:
|
|
mock_make_request.return_value = {
|
|
"id": "dataset-123456",
|
|
"name": "test-dataset",
|
|
"namespace": "custom-namespace",
|
|
}
|
|
|
|
dataset_def = Dataset(
|
|
identifier="test-dataset",
|
|
type=ResourceType.dataset,
|
|
provider_resource_id="",
|
|
provider_id="",
|
|
purpose=DatasetPurpose.post_training_messages,
|
|
source=URIDataSource(uri="https://example.com/data.jsonl"),
|
|
metadata={"format": "jsonl"},
|
|
)
|
|
|
|
run_async(custom_adapter.register_dataset(dataset_def))
|
|
|
|
mock_make_request.assert_called_once()
|
|
_assert_request(
|
|
mock_make_request,
|
|
"POST",
|
|
"/v1/datasets",
|
|
expected_json={
|
|
"name": "test-dataset",
|
|
"namespace": "custom-namespace",
|
|
"files_url": "https://example.com/data.jsonl",
|
|
"project": "custom-project",
|
|
"format": "jsonl",
|
|
},
|
|
)
|