Skip to content

Commit a44259d

Browse files
authored
chore: Update README and fix linting (#48)
1 parent 9aeb6c9 commit a44259d

File tree

4 files changed

+152
-110
lines changed

4 files changed

+152
-110
lines changed

.github/workflows/security.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,4 +125,4 @@ jobs:
125125
name: bandit-sarif-results
126126
path: results.sarif
127127
retention-days: 30
128-
continue-on-error: true
128+
continue-on-error: true

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# TrustyAI LM-Eval as and Out-of-Tree Llama Stack Provider
22

3-
[![PyPI version](https://img.shields.io/pypi/v/llama_stack_provider_lmeval.svg)](https://pypi.org/project/llama-stack-provider-lmeval/)
3+
[![PyPI version](https://img.shields.io/pypi/v/llama_stack_provider_lmeval.svg)](https://pypi.org/project/llama-stack-provider-lmeval/) [![pre-commit.ci](https://github.com/trustyai-explainability/llama-stack-provider-lmeval/actions/workflows/pre-commit.yml/badge.svg)](https://github.com/trustyai-explainability/llama-stack-provider-lmeval/actions/workflows/pre-commit.yml) [![Bandit](https://github.com/trustyai-explainability/llama-stack-provider-lmeval/actions/workflows/security.yml/badge.svg)](https://github.com/trustyai-explainability/llama-stack-provider-lmeval/actions/workflows/security.yml?label="Bandit") ![Llama compatibility](https://img.shields.io/badge/%F0%9F%A6%99-0.2.16-blue)
4+
45

56
## About
67
This repository implements [TrustyAI's LM-Eval](https://trustyai-explainability.github.io/trustyai-site/main/lm-eval-tutorial.html) as an out-of-tree Llama Stack remote provider.

src/llama_stack_provider_lmeval/config.py

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from __future__ import annotations
44

55
from dataclasses import dataclass, field
6-
from typing import Any, Dict, List, Optional
6+
from typing import Any
77

88
from llama_stack.apis.eval import BenchmarkConfig, EvalCandidate
99
from llama_stack.schema_utils import json_schema_type
@@ -18,8 +18,8 @@ class TLSConfig:
1818
"""TLS configuration for the LMEval provider."""
1919

2020
enable: bool
21-
cert_file: Optional[str] = None
22-
cert_secret: Optional[str] = None
21+
cert_file: str | None = None
22+
cert_secret: str | None = None
2323

2424
def __post_init__(self):
2525
"""Validate the configuration"""
@@ -30,10 +30,10 @@ def __post_init__(self):
3030
)
3131

3232
# Validate certificate file name is safe
33-
if not isinstance(self.cert_file, str) or not isinstance(self.cert_secret, str):
34-
raise LMEvalConfigError(
35-
"cert_file and cert_secret must be strings"
36-
)
33+
if not isinstance(self.cert_file, str) or not isinstance(
34+
self.cert_secret, str
35+
):
36+
raise LMEvalConfigError("cert_file and cert_secret must be strings")
3737

3838
if not self.cert_file.strip() or not self.cert_secret.strip():
3939
raise LMEvalConfigError(
@@ -48,14 +48,18 @@ def __post_init__(self):
4848

4949
# Allow only alphanumeric characters, dots, hyphens, underscores, and forward slashes
5050
# Remove allowed characters to check if remaining characters are safe
51-
safe_chars = self.cert_file.replace('.', '').replace('-', '').replace('_', '').replace('/', '')
51+
safe_chars = (
52+
self.cert_file.replace(".", "")
53+
.replace("-", "")
54+
.replace("_", "")
55+
.replace("/", "")
56+
)
5257
if not safe_chars.isalnum():
5358
raise LMEvalConfigError(
5459
f"cert_file contains potentially unsafe characters: {self.cert_file}"
5560
)
5661

5762

58-
5963
@json_schema_type
6064
@dataclass
6165
class LMEvalBenchmarkConfig(BenchmarkConfig):
@@ -74,8 +78,8 @@ class LMEvalBenchmarkConfig(BenchmarkConfig):
7478
model: str = Field(description="Name of the model")
7579
# FIXME: mode is only present temporarily and for debug purposes, it will be removed
7680
# mode: str = Field(description="Mode of the benchmark", default="production")
77-
env_vars: Optional[List[Dict[str, str]]] = None
78-
metadata: Optional[Dict[str, Any]] = None
81+
env_vars: list[dict[str, str]] | None = None
82+
metadata: dict[str, Any] | None = None
7983

8084
def __post_init__(self):
8185
"""Validate the configuration"""
@@ -89,11 +93,11 @@ class K8sLMEvalConfig:
8993
"""Configuration for Kubernetes LMEvalJob CR"""
9094

9195
model: str
92-
model_args: Optional[List[Dict[str, str]]] = field(default_factory=list)
93-
task_list: Optional[Dict[str, List[str]]] = None
96+
model_args: list[dict[str, str]] | None = field(default_factory=list)
97+
task_list: dict[str, list[str]] | None = None
9498
log_samples: bool = True
9599
namespace: str = "default"
96-
env_vars: Optional[List[Dict[str, str]]] = None
100+
env_vars: list[dict[str, str]] | None = None
97101

98102
def __post_init__(self):
99103
"""Validate the configuration"""
@@ -113,14 +117,14 @@ class LMEvalEvalProviderConfig:
113117
# FIXME: Hardcoded just for debug purposes
114118
base_url: str = "http://llamastack-service:8321"
115119
namespace: str | None = None
116-
kubeconfig_path: Optional[str] = None
120+
kubeconfig_path: str | None = None
117121
# Service account to use for Kubernetes deployment
118-
service_account: Optional[str] = None
122+
service_account: str | None = None
119123
# Default tokenizer to use when none is specified in the ModelCandidate
120124
default_tokenizer: str = "google/flan-t5-base"
121-
metadata: Optional[Dict[str, Any]] = None
125+
metadata: dict[str, Any] | None = None
122126
# TLS configuration - structured approach
123-
tls: Optional[TLSConfig] = None
127+
tls: TLSConfig | None = None
124128

125129
def __post_init__(self):
126130
"""Validate the configuration"""

0 commit comments

Comments
 (0)