Skip to content

Commit 1a15cb8

Browse files
romanlutzCopilot
andauthored
MAINT: Deprecate dead split kwarg on 8 single-split HF dataset loaders (#1901)
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 519b709 commit 1a15cb8

17 files changed

Lines changed: 169 additions & 43 deletions

pyrit/datasets/seed_datasets/remote/cbt_bench_dataset.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# Licensed under the MIT license.
33

44
import logging
5+
import warnings
56
from typing import Any
67

78
from pyrit.datasets.seed_datasets.remote.remote_dataset_loader import (
@@ -38,19 +39,28 @@ def __init__(
3839
*,
3940
source: str = "Psychotherapy-LLM/CBT-Bench",
4041
config: str = "core_fine_seed",
41-
split: str = "train",
42+
split: str | None = None,
4243
) -> None:
4344
"""
4445
Initialize the CBT-Bench dataset loader.
4546
4647
Args:
4748
source: HuggingFace dataset identifier. Defaults to "Psychotherapy-LLM/CBT-Bench".
4849
config: Dataset configuration/subset to load. Defaults to "core_fine_seed".
49-
split: Dataset split to load. Defaults to "train".
50+
split: **Deprecated.** Every config of ``Psychotherapy-LLM/CBT-Bench`` publishes
51+
only the ``"train"`` split, so this kwarg has no effect. It will be removed
52+
in v0.16.0.
5053
"""
54+
if split is not None:
55+
warnings.warn(
56+
"'split' is deprecated and will be removed in v0.16.0. "
57+
"Every config of Psychotherapy-LLM/CBT-Bench publishes only the 'train' "
58+
"split, so this kwarg has no effect.",
59+
DeprecationWarning,
60+
stacklevel=2,
61+
)
5162
self.source = source
5263
self.config = config
53-
self.split = split
5464

5565
@property
5666
def dataset_name(self) -> str:
@@ -76,7 +86,7 @@ async def fetch_dataset_async(self, *, cache: bool = True) -> SeedDataset:
7686
data = await self._fetch_from_huggingface_async(
7787
dataset_name=self.source,
7888
config=self.config,
79-
split=self.split,
89+
split="train",
8090
cache=cache,
8191
)
8292

pyrit/datasets/seed_datasets/remote/darkbench_dataset.py

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# Copyright (c) Microsoft Corporation.
22
# Licensed under the MIT license.
33

4+
import warnings
5+
46
from pyrit.datasets.seed_datasets.remote.remote_dataset_loader import (
57
_RemoteDatasetLoader,
68
)
@@ -33,19 +35,28 @@ def __init__(
3335
*,
3436
dataset_name: str = "apart/darkbench",
3537
config: str = "default",
36-
split: str = "train",
38+
split: str | None = None,
3739
) -> None:
3840
"""
3941
Initialize the DarkBench dataset loader.
4042
4143
Args:
4244
dataset_name: HuggingFace dataset identifier. Defaults to "apart/darkbench".
4345
config: Dataset configuration. Defaults to "default".
44-
split: Dataset split to load. Defaults to "train".
46+
split: **Deprecated.** Upstream ``apart/darkbench`` publishes only the
47+
``"train"`` split, so this kwarg has no effect. It will be removed in
48+
v0.16.0.
4549
"""
50+
if split is not None:
51+
warnings.warn(
52+
"'split' is deprecated and will be removed in v0.16.0. "
53+
"Upstream apart/darkbench publishes only the 'train' split, "
54+
"so this kwarg has no effect.",
55+
DeprecationWarning,
56+
stacklevel=2,
57+
)
4658
self.hf_dataset_name = dataset_name
4759
self.config = config
48-
self.split = split
4960

5061
@property
5162
def dataset_name(self) -> str:
@@ -70,7 +81,7 @@ async def fetch_dataset_async(self, *, cache: bool = True) -> SeedDataset:
7081
data = await self._fetch_from_huggingface_async(
7182
dataset_name=self.hf_dataset_name,
7283
config=self.config,
73-
split=self.split,
84+
split="train",
7485
cache=cache,
7586
data_files="darkbench.tsv",
7687
)

pyrit/datasets/seed_datasets/remote/forbidden_questions_dataset.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# Licensed under the MIT license.
33

44
import logging
5+
import warnings
56

67
from pyrit.datasets.seed_datasets.remote.remote_dataset_loader import (
78
_RemoteDatasetLoader,
@@ -34,17 +35,28 @@ def __init__(
3435
self,
3536
*,
3637
source: str = "TrustAIRLab/forbidden_question_set",
37-
split: str = "default",
38+
split: str | None = None,
3839
) -> None:
3940
"""
4041
Initialize the Forbidden Questions dataset loader.
4142
4243
Args:
4344
source: HuggingFace dataset identifier. Defaults to "TrustAIRLab/forbidden_question_set".
44-
split: Dataset split to load. Defaults to "default".
45+
split: **Deprecated.** This kwarg was misforwarded to HuggingFace as ``config``,
46+
and ``TrustAIRLab/forbidden_question_set`` publishes only one config
47+
(``"default"``) with one split (``"train"``), so it never did anything
48+
useful. It will be removed in v0.16.0.
4549
"""
50+
if split is not None:
51+
warnings.warn(
52+
"'split' is deprecated and will be removed in v0.16.0. "
53+
"It was misforwarded to HuggingFace as 'config', and "
54+
"TrustAIRLab/forbidden_question_set publishes only one config ('default') "
55+
"with one split ('train'), so this kwarg has no effect.",
56+
DeprecationWarning,
57+
stacklevel=2,
58+
)
4659
self.source = source
47-
self.split = split
4860

4961
@property
5062
def dataset_name(self) -> str:
@@ -66,7 +78,7 @@ async def fetch_dataset_async(self, *, cache: bool = True) -> SeedDataset:
6678
# Load from HuggingFace
6779
data = await self._fetch_from_huggingface_async(
6880
dataset_name=self.source,
69-
config=self.split,
81+
config="default",
7082
split="train",
7183
cache=cache,
7284
)

pyrit/datasets/seed_datasets/remote/harmful_qa_dataset.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# Licensed under the MIT license.
33

44
import logging
5+
import warnings
56

67
from pyrit.datasets.seed_datasets.remote.remote_dataset_loader import (
78
_RemoteDatasetLoader,
@@ -36,15 +37,24 @@ class _HarmfulQADataset(_RemoteDatasetLoader):
3637
def __init__(
3738
self,
3839
*,
39-
split: str = "train",
40+
split: str | None = None,
4041
) -> None:
4142
"""
4243
Initialize the HarmfulQA dataset loader.
4344
4445
Args:
45-
split: Dataset split to load. Defaults to "train".
46+
split: **Deprecated.** Upstream ``declare-lab/HarmfulQA`` publishes only the
47+
``"train"`` split, so this kwarg has no effect. It will be removed in
48+
v0.16.0.
4649
"""
47-
self.split = split
50+
if split is not None:
51+
warnings.warn(
52+
"'split' is deprecated and will be removed in v0.16.0. "
53+
"Upstream declare-lab/HarmfulQA publishes only the 'train' split, "
54+
"so this kwarg has no effect.",
55+
DeprecationWarning,
56+
stacklevel=2,
57+
)
4858

4959
@property
5060
def dataset_name(self) -> str:
@@ -65,7 +75,7 @@ async def fetch_dataset_async(self, *, cache: bool = True) -> SeedDataset:
6575

6676
data = await self._fetch_from_huggingface_async(
6777
dataset_name=self.HF_DATASET_NAME,
68-
split=self.split,
78+
split="train",
6979
cache=cache,
7080
)
7181

pyrit/datasets/seed_datasets/remote/hixstest_dataset.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
import logging
55
import os
6+
import warnings
67
from enum import Enum
78

89
from pyrit.datasets.seed_datasets.remote.remote_dataset_loader import (
@@ -68,7 +69,7 @@ def __init__(
6869
self,
6970
*,
7071
language: HiXSTestLanguage = HiXSTestLanguage.HINDI,
71-
split: str = "train",
72+
split: str | None = None,
7273
token: str | None = None,
7374
) -> None:
7475
"""
@@ -78,16 +79,25 @@ def __init__(
7879
language: Which language to use as the primary ``SeedPrompt.value``.
7980
Defaults to ``HiXSTestLanguage.HINDI`` (the dataset's intended language).
8081
Pass ``HiXSTestLanguage.ENGLISH`` to use the English translation instead.
81-
split: Dataset split to load. Defaults to "train" (the only split).
82+
split: **Deprecated.** Upstream ``walledai/HiXSTest`` publishes only the
83+
``"train"`` split, so this kwarg has no effect. It will be removed in
84+
v0.16.0.
8285
token: Hugging Face authentication token. If not provided, reads from the
8386
``HUGGINGFACE_TOKEN`` environment variable.
8487
8588
Raises:
8689
ValueError: If ``language`` is not a ``HiXSTestLanguage`` instance.
8790
"""
91+
if split is not None:
92+
warnings.warn(
93+
"'split' is deprecated and will be removed in v0.16.0. "
94+
"Upstream walledai/HiXSTest publishes only the 'train' split, "
95+
"so this kwarg has no effect.",
96+
DeprecationWarning,
97+
stacklevel=2,
98+
)
8899
self._validate_enum(language, HiXSTestLanguage, "language")
89100
self.language = language
90-
self.split = split
91101
self.token = token if token is not None else os.environ.get("HUGGINGFACE_TOKEN")
92102

93103
@property
@@ -113,7 +123,7 @@ async def fetch_dataset_async(self, *, cache: bool = True) -> SeedDataset:
113123

114124
data = await self._fetch_from_huggingface_async(
115125
dataset_name=self.HF_DATASET_NAME,
116-
split=self.split,
126+
split="train",
117127
cache=cache,
118128
token=self.token,
119129
)

pyrit/datasets/seed_datasets/remote/or_bench_dataset.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# Licensed under the MIT license.
33

44
import logging
5+
import warnings
56

67
from pyrit.datasets.seed_datasets.remote.remote_dataset_loader import (
78
_RemoteDatasetLoader,
@@ -36,14 +37,23 @@ class _ORBenchBaseDataset(_RemoteDatasetLoader):
3637
modalities: tuple[Modality, ...] = (Modality.TEXT,)
3738
tags: frozenset[str] = frozenset({"default", "safety", "refusal"})
3839

39-
def __init__(self, *, split: str = "train") -> None:
40+
def __init__(self, *, split: str | None = None) -> None:
4041
"""
4142
Initialize the OR-Bench dataset loader.
4243
4344
Args:
44-
split: Dataset split to load. Defaults to "train".
45+
split: **Deprecated.** Every config of ``bench-llm/OR-Bench`` publishes only
46+
the ``"train"`` split, so this kwarg has no effect. It will be removed in
47+
v0.16.0.
4548
"""
46-
self.split = split
49+
if split is not None:
50+
warnings.warn(
51+
"'split' is deprecated and will be removed in v0.16.0. "
52+
"Every config of bench-llm/OR-Bench publishes only the 'train' split, "
53+
"so this kwarg has no effect.",
54+
DeprecationWarning,
55+
stacklevel=2,
56+
)
4757

4858
async def fetch_dataset_async(self, *, cache: bool = True) -> SeedDataset:
4959
"""
@@ -60,7 +70,7 @@ async def fetch_dataset_async(self, *, cache: bool = True) -> SeedDataset:
6070
data = await self._fetch_from_huggingface_async(
6171
dataset_name=self.HF_DATASET_NAME,
6272
config=self.CONFIG,
63-
split=self.split,
73+
split="train",
6474
cache=cache,
6575
)
6676

pyrit/datasets/seed_datasets/remote/sgxstest_dataset.py

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
import logging
55
import os
6+
import warnings
67
from enum import Enum
78

89
from pyrit.datasets.seed_datasets.remote.remote_dataset_loader import (
@@ -74,7 +75,7 @@ def __init__(
7475
self,
7576
*,
7677
label: SGXSTestLabel = SGXSTestLabel.UNSAFE,
77-
split: str = "train",
78+
split: str | None = None,
7879
token: str | None = None,
7980
) -> None:
8081
"""
@@ -84,18 +85,26 @@ def __init__(
8485
label: Which subset of prompts to load. Defaults to ``SGXSTestLabel.UNSAFE``
8586
(the truly-harmful prompts). Use ``SGXSTestLabel.SAFE`` for the
8687
over-refusal targets or ``SGXSTestLabel.ALL`` for the full 200-prompt set.
87-
split: Dataset split to load. Defaults to "train" (the only split currently
88-
published by the upstream dataset).
88+
split: **Deprecated.** Upstream ``walledai/SGXSTest`` publishes only the
89+
``"train"`` split, so this kwarg has no effect. It will be removed in
90+
v0.16.0.
8991
token: Hugging Face authentication token. If not provided, reads from
9092
the HUGGINGFACE_TOKEN env var.
9193
9294
Raises:
9395
ValueError: If ``label`` is not an SGXSTestLabel member.
9496
"""
97+
if split is not None:
98+
warnings.warn(
99+
"'split' is deprecated and will be removed in v0.16.0. "
100+
"Upstream walledai/SGXSTest publishes only the 'train' split, "
101+
"so this kwarg has no effect.",
102+
DeprecationWarning,
103+
stacklevel=2,
104+
)
95105
self._validate_enum(value=label, enum_cls=SGXSTestLabel, label="label")
96106

97107
self.label = label
98-
self.split = split
99108
self.token = token if token is not None else os.environ.get("HUGGINGFACE_TOKEN")
100109

101110
@property
@@ -122,7 +131,7 @@ async def fetch_dataset_async(self, *, cache: bool = True) -> SeedDataset:
122131

123132
data = await self._fetch_from_huggingface_async(
124133
dataset_name=self.HF_DATASET_NAME,
125-
split=self.split,
134+
split="train",
126135
cache=cache,
127136
token=self.token,
128137
)

pyrit/datasets/seed_datasets/remote/simple_safety_tests_dataset.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# Licensed under the MIT license.
33

44
import logging
5+
import warnings
56

67
from pyrit.datasets.seed_datasets.remote.remote_dataset_loader import (
78
_RemoteDatasetLoader,
@@ -36,15 +37,24 @@ class _SimpleSafetyTestsDataset(_RemoteDatasetLoader):
3637
def __init__(
3738
self,
3839
*,
39-
split: str = "test",
40+
split: str | None = None,
4041
) -> None:
4142
"""
4243
Initialize the SimpleSafetyTests dataset loader.
4344
4445
Args:
45-
split: Dataset split to load. Defaults to "test".
46+
split: **Deprecated.** Upstream ``Bertievidgen/SimpleSafetyTests`` publishes
47+
only the ``"test"`` split, so this kwarg has no effect. It will be
48+
removed in v0.16.0.
4649
"""
47-
self.split = split
50+
if split is not None:
51+
warnings.warn(
52+
"'split' is deprecated and will be removed in v0.16.0. "
53+
"Upstream Bertievidgen/SimpleSafetyTests publishes only the 'test' "
54+
"split, so this kwarg has no effect.",
55+
DeprecationWarning,
56+
stacklevel=2,
57+
)
4858

4959
@property
5060
def dataset_name(self) -> str:
@@ -65,7 +75,7 @@ async def fetch_dataset_async(self, *, cache: bool = True) -> SeedDataset:
6575

6676
data = await self._fetch_from_huggingface_async(
6777
dataset_name=self.HF_DATASET_NAME,
68-
split=self.split,
78+
split="test",
6979
cache=cache,
7080
)
7181

0 commit comments

Comments
 (0)