Skip to content

Commit e608291

Browse files
Merge pull request trustyai-explainability#143 from trustyai-explainability/sdg-cache-control
2 parents 6fe663b + 2c712eb commit e608291

File tree

4 files changed

+17
-2
lines changed

4 files changed

+17
-2
lines changed

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ fsspec==2026.2.0
128128
# torch
129129
ftfy==6.3.1
130130
# via garak
131-
garak==0.14.1+rhaiv.5
131+
garak==0.14.1+rhaiv.6
132132
# via llama-stack-provider-trustyai-garak (pyproject.toml)
133133
google-api-core==2.30.0
134134
# via

src/llama_stack_provider_trustyai_garak/evalhub/garak_adapter.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
parse_digest_from_report_content,
6060
parse_generations_from_report_content,
6161
)
62-
from ..utils import get_scan_base_dir
62+
from ..utils import get_scan_base_dir, as_bool
6363
from ..constants import (
6464
DEFAULT_TIMEOUT,
6565
DEFAULT_MODEL_TYPE,
@@ -550,12 +550,14 @@ def _run_via_kfp(
550550
if model_auth_secret:
551551
pipeline_args["model_auth_secret_name"] = model_auth_secret
552552

553+
disable_cache = as_bool(ip.get("disable_cache", False))
553554
run = kfp_client.create_run_from_pipeline_func(
554555
evalhub_garak_pipeline,
555556
arguments=pipeline_args,
556557
run_name=f"evalhub-garak-{config.id}",
557558
namespace=kfp_config.namespace,
558559
experiment_name=kfp_config.experiment_name,
560+
enable_caching=not disable_cache,
559561
)
560562

561563
kfp_run_id = run.run_id
@@ -931,6 +933,7 @@ def _build_config_from_spec(
931933
"intents_s3_key": benchmark_config.get("intents_s3_key", profile.get("intents_s3_key", "")),
932934
"intents_format": benchmark_config.get("intents_format", profile.get("intents_format", "csv")),
933935
"sdg_flow_id": benchmark_config.get("sdg_flow_id", profile.get("sdg_flow_id", DEFAULT_SDG_FLOW_ID)),
936+
"disable_cache": as_bool(benchmark_config.get("disable_cache", False)),
934937
}
935938

936939
if art_intents:

src/llama_stack_provider_trustyai_garak/remote/garak_remote_eval.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
from ..base_eval import GarakEvalBase
2222
from llama_stack_provider_trustyai_garak import shield_scan
2323
from ..errors import GarakError, GarakConfigError, GarakValidationError
24+
from ..utils import as_bool
2425
from dotenv import load_dotenv
2526

2627
load_dotenv()
@@ -179,6 +180,7 @@ async def run_eval(self, request: RunEvalRequest) -> Job:
179180

180181
sanitised_config = redact_api_keys(cmd_config)
181182

183+
disable_cache = as_bool(provider_params.get("disable_cache", False))
182184
run = self.kfp_client.create_run_from_pipeline_func(
183185
garak_scan_pipeline,
184186
arguments={
@@ -200,6 +202,7 @@ async def run_eval(self, request: RunEvalRequest) -> Job:
200202
run_name=f"garak-{benchmark_id.split('::')[-1]}-{job_id.removeprefix(JOB_ID_PREFIX)}",
201203
namespace=self._config.kubeflow_config.namespace,
202204
experiment_name=experiment_name,
205+
enable_caching=not disable_cache,
203206
)
204207

205208
async with self._jobs_lock:

src/llama_stack_provider_trustyai_garak/utils.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,15 @@
44
from pathlib import Path
55
from .constants import XDG_CACHE_HOME, XDG_DATA_HOME, XDG_CONFIG_HOME
66

7+
_FALSY_STRINGS = frozenset({"false", "0", "no", "off", ""})
8+
9+
10+
def as_bool(value: object) -> bool:
11+
"""Coerce a value to bool, treating string ``'false'``/``'0'``/``'no'``/``'off'`` as False."""
12+
if isinstance(value, str):
13+
return value.strip().lower() not in _FALSY_STRINGS
14+
return bool(value)
15+
716

817
def _ensure_xdg_vars() -> None:
918
"""

0 commit comments

Comments
 (0)