Skip to content

Commit 6dab9f2

Browse files
romanlutzCopilot
andauthored
FIX VLGuard review fixes: document subcategory mapping, move import to top (#1649)
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent e58473f commit 6dab9f2

2 files changed

Lines changed: 11 additions & 4 deletions

File tree

pyrit/datasets/seed_datasets/remote/vlguard_dataset.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
from enum import Enum
1010
from pathlib import Path
1111

12+
from huggingface_hub import hf_hub_download
13+
1214
from pyrit.common.path import DB_DATA_PATH
1315
from pyrit.datasets.seed_datasets.remote.remote_dataset_loader import (
1416
_RemoteDatasetLoader,
@@ -37,7 +39,14 @@ class VLGuardCategory(Enum):
3739

3840

3941
class VLGuardSubcategory(Enum):
40-
"""Subcategories in the VLGuard dataset, nested under the main categories."""
42+
"""
43+
Subcategories in the VLGuard dataset. Each subcategory belongs to a specific category.
44+
45+
privacy: personal data
46+
risky behavior: professional advice, political, sexually explicit, violence
47+
deception: disinformation
48+
discrimination: sex, race, other
49+
"""
4150

4251
PERSONAL_DATA = "personal data"
4352
PROFESSIONAL_ADVICE = "professional advice"
@@ -263,8 +272,6 @@ async def _download_dataset_files_async(self, *, cache: bool = True) -> tuple[li
263272
Returns:
264273
tuple[list[dict], Path]: Tuple of (metadata list, image directory path).
265274
"""
266-
from huggingface_hub import hf_hub_download
267-
268275
cache_dir = DB_DATA_PATH / "seed-prompt-entries" / "vlguard"
269276
cache_dir.mkdir(parents=True, exist_ok=True)
270277

tests/unit/datasets/test_vlguard_dataset.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,7 @@ def mock_hf_download(*, repo_id, filename, repo_type, local_dir, token):
409409

410410
with (
411411
patch("pyrit.datasets.seed_datasets.remote.vlguard_dataset.DB_DATA_PATH", tmp_path),
412-
patch("huggingface_hub.hf_hub_download", side_effect=mock_hf_download),
412+
patch("pyrit.datasets.seed_datasets.remote.vlguard_dataset.hf_hub_download", side_effect=mock_hf_download),
413413
):
414414
metadata, result_dir = await loader._download_dataset_files_async(cache=False)
415415

0 commit comments

Comments
 (0)