mirror of
https://github.com/meta-llama/llama-stack.git
synced 2025-12-30 09:49:32 +00:00
refactor: Add ProviderContext for a flexible storage directory
- Introduce ProviderContext class to decouple provider storage paths from absolute paths - Add storage_dir attribute to StackRunConfig to accept CLI options - Implement storage directory resolution with prioritized fallbacks: 1. CLI option (--state-directory) 2. Environment variable (LLAMA_STACK_STATE_DIR) 3. Default distribution directory - Standardize provider signatures to follow context, config, deps pattern - Update provider implementations to use the new context-based approach - Add comprehensive tests to verify state directory resolution
This commit is contained in:
parent
dd07c7a5b5
commit
e6c9aebe47
41 changed files with 242 additions and 81 deletions
|
|
@ -6,17 +6,20 @@
|
|||
from typing import Any
|
||||
|
||||
from llama_stack.distribution.datatypes import Api
|
||||
from llama_stack.providers.datatypes import ProviderContext
|
||||
|
||||
from .config import BasicScoringConfig
|
||||
|
||||
|
||||
async def get_provider_impl(
|
||||
context: ProviderContext,
|
||||
config: BasicScoringConfig,
|
||||
deps: dict[Api, Any],
|
||||
):
|
||||
from .scoring import BasicScoringImpl
|
||||
|
||||
impl = BasicScoringImpl(
|
||||
context,
|
||||
config,
|
||||
deps[Api.datasetio],
|
||||
deps[Api.datasets],
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ from llama_stack.apis.scoring import (
|
|||
)
|
||||
from llama_stack.apis.scoring_functions import ScoringFn, ScoringFnParams
|
||||
from llama_stack.distribution.datatypes import Api
|
||||
from llama_stack.providers.datatypes import ScoringFunctionsProtocolPrivate
|
||||
from llama_stack.providers.datatypes import ProviderContext, ScoringFunctionsProtocolPrivate
|
||||
from llama_stack.providers.utils.common.data_schema_validator import (
|
||||
get_valid_schemas,
|
||||
validate_dataset_schema,
|
||||
|
|
@ -49,10 +49,12 @@ class BasicScoringImpl(
|
|||
):
|
||||
def __init__(
|
||||
self,
|
||||
context: ProviderContext,
|
||||
config: BasicScoringConfig,
|
||||
datasetio_api: DatasetIO,
|
||||
datasets_api: Datasets,
|
||||
) -> None:
|
||||
self.context = context
|
||||
self.config = config
|
||||
self.datasetio_api = datasetio_api
|
||||
self.datasets_api = datasets_api
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ from typing import Any
|
|||
from pydantic import BaseModel
|
||||
|
||||
from llama_stack.distribution.datatypes import Api
|
||||
from llama_stack.providers.datatypes import ProviderContext
|
||||
|
||||
from .config import BraintrustScoringConfig
|
||||
|
||||
|
|
@ -17,6 +18,7 @@ class BraintrustProviderDataValidator(BaseModel):
|
|||
|
||||
|
||||
async def get_provider_impl(
|
||||
context: ProviderContext,
|
||||
config: BraintrustScoringConfig,
|
||||
deps: dict[Api, Any],
|
||||
):
|
||||
|
|
|
|||
|
|
@ -6,11 +6,13 @@
|
|||
from typing import Any
|
||||
|
||||
from llama_stack.distribution.datatypes import Api
|
||||
from llama_stack.providers.datatypes import ProviderContext
|
||||
|
||||
from .config import LlmAsJudgeScoringConfig
|
||||
|
||||
|
||||
async def get_provider_impl(
|
||||
context: ProviderContext,
|
||||
config: LlmAsJudgeScoringConfig,
|
||||
deps: dict[Api, Any],
|
||||
):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue