mirror of
https://github.com/meta-llama/llama-stack.git
synced 2025-08-12 04:50:39 +00:00
fix: Fix unit tests of datasetio providers
This commit is contained in:
parent
99b6925ad8
commit
2762404910
3 changed files with 16 additions and 15 deletions
|
@ -18,7 +18,7 @@ repos:
|
||||||
# args: ['--branch=main']
|
# args: ['--branch=main']
|
||||||
|
|
||||||
- repo: https://github.com/Lucas-C/pre-commit-hooks
|
- repo: https://github.com/Lucas-C/pre-commit-hooks
|
||||||
rev: v1.5.4
|
rev: v1.5.5
|
||||||
hooks:
|
hooks:
|
||||||
- id: insert-license
|
- id: insert-license
|
||||||
files: \.py$|\.sh$
|
files: \.py$|\.sh$
|
||||||
|
@ -27,7 +27,7 @@ repos:
|
||||||
- docs/license_header.txt
|
- docs/license_header.txt
|
||||||
|
|
||||||
- repo: https://github.com/astral-sh/ruff-pre-commit
|
- repo: https://github.com/astral-sh/ruff-pre-commit
|
||||||
rev: v0.9.4
|
rev: v0.9.9
|
||||||
hooks:
|
hooks:
|
||||||
- id: ruff
|
- id: ruff
|
||||||
args: [ --fix ]
|
args: [ --fix ]
|
||||||
|
@ -35,14 +35,14 @@ repos:
|
||||||
- id: ruff-format
|
- id: ruff-format
|
||||||
|
|
||||||
- repo: https://github.com/adamchainz/blacken-docs
|
- repo: https://github.com/adamchainz/blacken-docs
|
||||||
rev: 1.19.0
|
rev: 1.19.1
|
||||||
hooks:
|
hooks:
|
||||||
- id: blacken-docs
|
- id: blacken-docs
|
||||||
additional_dependencies:
|
additional_dependencies:
|
||||||
- black==24.3.0
|
- black==24.3.0
|
||||||
|
|
||||||
- repo: https://github.com/astral-sh/uv-pre-commit
|
- repo: https://github.com/astral-sh/uv-pre-commit
|
||||||
rev: 0.6.3
|
rev: 0.6.4
|
||||||
hooks:
|
hooks:
|
||||||
- id: uv-lock
|
- id: uv-lock
|
||||||
- id: uv-export
|
- id: uv-export
|
||||||
|
|
|
@ -44,8 +44,7 @@ def datasetio_huggingface() -> ProviderFixture:
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
DATASETIO_FIXTURES = ["localfs", "remote", "huggingface"]
|
DATASETIO_FIXTURES = ["localfs", "huggingface"]
|
||||||
|
|
||||||
|
|
||||||
@pytest_asyncio.fixture(scope="session")
|
@pytest_asyncio.fixture(scope="session")
|
||||||
async def datasetio_stack(request):
|
async def datasetio_stack(request):
|
||||||
|
|
|
@ -13,12 +13,11 @@ import pytest
|
||||||
|
|
||||||
from llama_stack.apis.common.content_types import URL
|
from llama_stack.apis.common.content_types import URL
|
||||||
from llama_stack.apis.common.type_system import ChatCompletionInputType, StringType
|
from llama_stack.apis.common.type_system import ChatCompletionInputType, StringType
|
||||||
from llama_stack.apis.datasets import Datasets
|
from llama_stack.apis.datasets import Datasets, ListDatasetsResponse
|
||||||
|
|
||||||
# How to run this test:
|
# How to run this test:
|
||||||
#
|
#
|
||||||
# pytest llama_stack/providers/tests/datasetio/test_datasetio.py
|
# pytest llama_stack/providers/tests/datasetio/test_datasetio.py
|
||||||
# -m "meta_reference"
|
|
||||||
# -v -s --tb=short --disable-warnings
|
# -v -s --tb=short --disable-warnings
|
||||||
|
|
||||||
|
|
||||||
|
@ -83,17 +82,19 @@ class TestDatasetIO:
|
||||||
# but so far we don't have an unregister API unfortunately, so be careful
|
# but so far we don't have an unregister API unfortunately, so be careful
|
||||||
_, datasets_impl = datasetio_stack
|
_, datasets_impl = datasetio_stack
|
||||||
response = await datasets_impl.list_datasets()
|
response = await datasets_impl.list_datasets()
|
||||||
assert isinstance(response, list)
|
assert isinstance(response, ListDatasetsResponse)
|
||||||
assert len(response) == 0
|
assert isinstance(response.data, list)
|
||||||
|
assert len(response.data) == 0
|
||||||
|
|
||||||
@pytest.mark.asyncio
|
@pytest.mark.asyncio
|
||||||
async def test_register_dataset(self, datasetio_stack):
|
async def test_register_dataset(self, datasetio_stack):
|
||||||
_, datasets_impl = datasetio_stack
|
_, datasets_impl = datasetio_stack
|
||||||
await register_dataset(datasets_impl)
|
await register_dataset(datasets_impl)
|
||||||
response = await datasets_impl.list_datasets()
|
response = await datasets_impl.list_datasets()
|
||||||
assert isinstance(response, list)
|
assert isinstance(response, ListDatasetsResponse)
|
||||||
assert len(response) == 1
|
assert isinstance(response.data, list)
|
||||||
assert response[0].identifier == "test_dataset"
|
assert len(response.data) == 1
|
||||||
|
assert response.data[0].identifier == "test_dataset"
|
||||||
|
|
||||||
with pytest.raises(ValueError):
|
with pytest.raises(ValueError):
|
||||||
# unregister a dataset that does not exist
|
# unregister a dataset that does not exist
|
||||||
|
@ -101,8 +102,9 @@ class TestDatasetIO:
|
||||||
|
|
||||||
await datasets_impl.unregister_dataset("test_dataset")
|
await datasets_impl.unregister_dataset("test_dataset")
|
||||||
response = await datasets_impl.list_datasets()
|
response = await datasets_impl.list_datasets()
|
||||||
assert isinstance(response, list)
|
assert isinstance(response, ListDatasetsResponse)
|
||||||
assert len(response) == 0
|
assert isinstance(response.data, list)
|
||||||
|
assert len(response.data) == 0
|
||||||
|
|
||||||
with pytest.raises(ValueError):
|
with pytest.raises(ValueError):
|
||||||
await datasets_impl.unregister_dataset("test_dataset")
|
await datasets_impl.unregister_dataset("test_dataset")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue