|
21 | 21 |
|
22 | 22 | from pyrit.datasets import SeedDatasetProvider |
23 | 23 | from pyrit.datasets.seed_datasets.remote import ( |
| 24 | + _ComicJailbreakDataset, |
24 | 25 | _HarmBenchMultimodalDataset, |
| 26 | + _HiXSTestDataset, |
25 | 27 | _PromptIntelDataset, |
| 28 | + _SGXSTestDataset, |
26 | 29 | _SIUODataset, |
| 30 | + _SorryBenchDataset, |
| 31 | + _VLGuardDataset, |
27 | 32 | _VLSUMultimodalDataset, |
28 | 33 | ) |
29 | 34 | from pyrit.models import SeedDataset |
|
41 | 46 | # due to rate-limiting, so an empty result is expected in some environments. |
42 | 47 | _IMAGE_FETCHING_PROVIDERS: set[type] = {_HarmBenchMultimodalDataset, _SIUODataset, _VLSUMultimodalDataset} |
43 | 48 |
|
| 49 | +# Providers that produce many seeds and would otherwise exceed _TEST_TIMEOUT. |
| 50 | +# Constructed with max_examples to keep CI fast; full coverage runs are out of scope here. |
| 51 | +_LIMITED_EXAMPLES_PROVIDERS: set[type] = {_ComicJailbreakDataset, _VLSUMultimodalDataset} |
| 52 | + |
| 53 | +# Providers backed by HuggingFace-gated datasets. They require both a HUGGINGFACE_TOKEN |
| 54 | +# and that the token's account has accepted each dataset's terms; skipped when no token |
| 55 | +# is present (e.g. when running E2E locally without secrets). |
| 56 | +_HF_GATED_PROVIDERS: set[type] = { |
| 57 | + _HiXSTestDataset, |
| 58 | + _SGXSTestDataset, |
| 59 | + _SorryBenchDataset, |
| 60 | + _VLGuardDataset, |
| 61 | +} |
| 62 | + |
44 | 63 |
|
45 | 64 | def get_dataset_providers(): |
46 | 65 | """Helper to get all registered providers for parameterization.""" |
@@ -85,12 +104,14 @@ async def test_fetch_dataset(self, name, provider_cls): |
85 | 104 | # Skip providers that require credentials not available in CI |
86 | 105 | if provider_cls == _PromptIntelDataset and not os.environ.get("PROMPTINTEL_API_KEY"): |
87 | 106 | pytest.skip("PROMPTINTEL_API_KEY not set") |
| 107 | + if provider_cls in _HF_GATED_PROVIDERS and not os.environ.get("HUGGINGFACE_TOKEN"): |
| 108 | + pytest.skip(f"HUGGINGFACE_TOKEN not set (required for gated dataset used by {name})") |
88 | 109 |
|
89 | 110 | logger.info(f"Testing provider: {name}") |
90 | 111 |
|
91 | 112 | try: |
92 | | - # Limit examples for slow multimodal providers that fetch many remote images |
93 | | - provider = provider_cls(max_examples=6) if provider_cls == _VLSUMultimodalDataset else provider_cls() |
| 113 | + # Limit examples for slow providers that would otherwise exceed _TEST_TIMEOUT |
| 114 | + provider = provider_cls(max_examples=6) if provider_cls in _LIMITED_EXAMPLES_PROVIDERS else provider_cls() |
94 | 115 |
|
95 | 116 | dataset = await _fetch_with_retry(provider) |
96 | 117 | except Exception as e: |
|
0 commit comments