mirror of
https://github.com/meta-llama/llama-stack.git
synced 2025-06-27 18:50:41 +00:00
# What does this PR do? Implemetation of NeMO Datastore register, unregister API. Open Issues: - provider_id gets set to `localfs` in client.datasets.register() as it is specified in routing_tables.py: DatasetsRoutingTable see: #1860 Currently I have passed `"provider_id":"nvidia"` in metadata and have parsed that in `DatasetsRoutingTable` (Not the best approach, but just a quick workaround to make it work for now.) ## Test Plan - Unit test cases: `pytest tests/unit/providers/nvidia/test_datastore.py` ```bash ========================================================== test session starts =========================================================== platform linux -- Python 3.10.0, pytest-8.3.5, pluggy-1.5.0 rootdir: /home/ubuntu/llama-stack configfile: pyproject.toml plugins: anyio-4.9.0, asyncio-0.26.0, nbval-0.11.0, metadata-3.1.1, html-4.1.1, cov-6.1.0 asyncio: mode=strict, asyncio_default_fixture_loop_scope=None, asyncio_default_test_loop_scope=function collected 2 items tests/unit/providers/nvidia/test_datastore.py .. [100%] ============================================================ warnings summary ============================================================ ====================================================== 2 passed, 1 warning in 0.84s ====================================================== ``` cc: @dglogo, @mattf, @yanxi0830
61 lines
2.1 KiB
Python
61 lines
2.1 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
|
|
import warnings
|
|
from typing import Any, Dict, Optional
|
|
|
|
from pydantic import BaseModel, Field
|
|
|
|
|
|
class NvidiaDatasetIOConfig(BaseModel):
|
|
"""Configuration for NVIDIA DatasetIO implementation."""
|
|
|
|
api_key: Optional[str] = Field(
|
|
default_factory=lambda: os.getenv("NVIDIA_API_KEY"),
|
|
description="The NVIDIA API key.",
|
|
)
|
|
|
|
dataset_namespace: Optional[str] = Field(
|
|
default_factory=lambda: os.getenv("NVIDIA_DATASET_NAMESPACE", "default"),
|
|
description="The NVIDIA dataset namespace.",
|
|
)
|
|
|
|
project_id: Optional[str] = Field(
|
|
default_factory=lambda: os.getenv("NVIDIA_PROJECT_ID", "test-project"),
|
|
description="The NVIDIA project ID.",
|
|
)
|
|
|
|
datasets_url: str = Field(
|
|
default_factory=lambda: os.getenv("NVIDIA_DATASETS_URL", "http://nemo.test"),
|
|
description="Base URL for the NeMo Dataset API",
|
|
)
|
|
|
|
# warning for default values
|
|
def __post_init__(self):
|
|
default_values = []
|
|
if os.getenv("NVIDIA_PROJECT_ID") is None:
|
|
default_values.append("project_id='test-project'")
|
|
if os.getenv("NVIDIA_DATASET_NAMESPACE") is None:
|
|
default_values.append("dataset_namespace='default'")
|
|
if os.getenv("NVIDIA_DATASETS_URL") is None:
|
|
default_values.append("datasets_url='http://nemo.test'")
|
|
|
|
if default_values:
|
|
warnings.warn(
|
|
f"Using default values: {', '.join(default_values)}. \
|
|
Please set the environment variables to avoid this default behavior.",
|
|
stacklevel=2,
|
|
)
|
|
|
|
@classmethod
|
|
def sample_run_config(cls, **kwargs) -> Dict[str, Any]:
|
|
return {
|
|
"api_key": "${env.NVIDIA_API_KEY:}",
|
|
"dataset_namespace": "${env.NVIDIA_DATASET_NAMESPACE:default}",
|
|
"project_id": "${env.NVIDIA_PROJECT_ID:test-project}",
|
|
"datasets_url": "${env.NVIDIA_DATASETS_URL:http://nemo.test}",
|
|
}
|