Datasets
Modules:
Name | Description |
---|---|
dataset_config |
|
dataset_manager |
|
managers |
|
Classes:
Name | Description |
---|---|
DatasetConfig |
Configuration for a dataset. |
DatasetManager |
A protocol for managing datasets. |
DatasetManagerRegistry |
A registry for dataset managers. |
DatasetMetadata |
The metadata for a dataset. |
DatasetRecord |
A record identifying a dataset. |
FileBasedDatasetManager |
An abstract class for managing datasets. |
FileMetadata |
The metadata for a dataset file. |
LocalSource |
The local source of the dataset file(s). |
OnlineSource |
The online source of the dataset file(s). |
SplitMetadata |
The metadata for a dataset split. |
VersionMetadata |
The metadata for a dataset version. |
Functions:
Name | Description |
---|---|
manager |
Decorator to register a dataset manager. |
DatasetConfig
Configuration for a dataset.
Attributes:
Name | Type | Description |
---|---|---|
dataset_name |
str
|
The name of the dataset. |
dataset_metadata |
DatasetMetadata
|
The metadata for the dataset. |
Methods:
Name | Description |
---|---|
__init__ |
Initializes a new DatasetConfig. |
get_files |
Gets the files for the specified version and splits. |
get_splits |
Gets the dataset splits for the specified version. |
Source code in evalsense/datasets/dataset_config.py
__init__
Initializes a new DatasetConfig.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dataset_name
|
str
|
The name of the dataset. |
required |
Source code in evalsense/datasets/dataset_config.py
get_files
Gets the files for the specified version and splits.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
version
|
str
|
The name of the version. |
required |
splits
|
list[str]
|
The names of the splits. |
required |
Returns:
Type | Description |
---|---|
dict[str, FileMetadata]
|
The files for the version and splits. |
Source code in evalsense/datasets/dataset_config.py
get_splits
Gets the dataset splits for the specified version.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
version
|
str
|
The name of the version. |
required |
Returns:
Type | Description |
---|---|
dict[str, SplitMetadata]
|
The splits for the version. |
Source code in evalsense/datasets/dataset_config.py
DatasetManager
Bases: Protocol
A protocol for managing datasets.
Attributes:
Name | Type | Description |
---|---|---|
priority |
int
|
The priority of the dataset manager. Ranges from 0 (the lowest priority) to 10 (the highest priority). A class attribute. |
name |
str
|
The name of the dataset. |
version |
str
|
The used dataset version. |
splits |
list[str]
|
The dataset splits to retrieve. |
data_path |
Path
|
The top-level directory for storing all datasets. |
dataset |
Dataset | None
|
The loaded dataset. |
dataset_dict |
DatasetDict | None
|
The loaded dataset dictionary. |
Methods:
Name | Description |
---|---|
__init__ |
Initializes a new DatasetManager. |
can_handle |
Checks if the DatasetManager can handle the given dataset. |
create |
Creates a new dataset manager for the specified dataset. |
is_retrieved |
Checks if the dataset at the specific version is already downloaded. |
load |
Loads the dataset as a HuggingFace dataset. |
remove |
Deletes the dataset at the specific version from disk. |
retrieve |
Downloads and preprocesses a dataset. |
unload |
Unloads the dataset from memory. |
Source code in evalsense/datasets/dataset_manager.py
119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 |
|
dataset_path
property
The top-level directory for storing this dataset.
Returns:
Type | Description |
---|---|
Path
|
The dataset directory. |
main_data_path
property
The path for storing the preprocessed dataset files for a specific version.
Returns:
Type | Description |
---|---|
Path
|
The main dataset directory. |
record
property
Returns a record identifying the dataset.
Returns:
Type | Description |
---|---|
DatasetRecord
|
The dataset record. |
version_path
property
The directory for storing a specific version of this dataset.
Returns:
Type | Description |
---|---|
Path
|
The dataset version directory. |
__init__
__init__(
name: str,
splits: list[str],
version: str | None = None,
data_dir: str | None = None,
**kwargs: dict,
)
Initializes a new DatasetManager.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
The name of the dataset. |
required |
splits
|
list[str]
|
The dataset splits to retrieve. |
required |
version
|
str
|
The dataset version to retrieve. |
None
|
data_dir
|
str
|
The top-level directory for storing all datasets. Defaults to "datasets" in the user cache directory. |
None
|
**kwargs
|
dict
|
Additional keyword arguments. |
{}
|
Source code in evalsense/datasets/dataset_manager.py
can_handle
abstractmethod
classmethod
Checks if the DatasetManager can handle the given dataset.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
The name of the dataset. |
required |
Returns:
Type | Description |
---|---|
bool
|
True if the manager can handle the dataset, False otherwise. |
Source code in evalsense/datasets/dataset_manager.py
create
classmethod
create(
name: str,
splits: list[str],
version: str | None = None,
data_dir: str | None = None,
**kwargs: dict,
) -> DatasetManager
Creates a new dataset manager for the specified dataset.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
The name of the dataset. |
required |
splits
|
list[str]
|
The dataset splits to retrieve. |
required |
version
|
str | None
|
The dataset version to retrieve. |
None
|
data_dir
|
str | None
|
The top-level directory for storing all datasets. |
None
|
**kwargs
|
dict
|
Additional keyword arguments. |
{}
|
Returns:
Type | Description |
---|---|
DatasetManager
|
The created dataset manager. |
Source code in evalsense/datasets/dataset_manager.py
is_retrieved
Checks if the dataset at the specific version is already downloaded.
Returns:
Type | Description |
---|---|
bool
|
True if the dataset exists locally, False otherwise. |
load
load(
*,
retrieve: bool = True,
cache: bool = True,
force_retrieve: bool = False,
load_as_dict: bool = False,
) -> Dataset | DatasetDict
Loads the dataset as a HuggingFace dataset.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
retrieve
|
bool
|
Whether to retrieve the dataset if it does not exist locally. Defaults to True. |
True
|
cache
|
bool
|
Whether to cache the dataset in memory. Defaults to True. |
True
|
force_retrieve
|
bool
|
Whether to force retrieving and
reloading the dataset even if it is already cached. Overrides
the |
False
|
load_as_dict
|
bool
|
Whether to load the dataset with multiple splits as a DatasetDict. If False (the default), the selected dataset splits are concatenated into a single dataset. |
False
|
Returns:
Type | Description |
---|---|
Dataset | DatasetDict
|
The loaded dataset. |
Source code in evalsense/datasets/dataset_manager.py
remove
retrieve
abstractmethod
Downloads and preprocesses a dataset.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
**kwargs
|
dict
|
Additional keyword arguments. |
{}
|
DatasetManagerRegistry
A registry for dataset managers.
Methods:
Name | Description |
---|---|
get |
Gets the dataset manager for a specific dataset. |
register |
Registers a new dataset manager. |
Source code in evalsense/datasets/dataset_manager.py
get
classmethod
Gets the dataset manager for a specific dataset.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
The name of the dataset. |
required |
Returns:
Type | Description |
---|---|
Type[DatasetManager] | None
|
The dataset manager for the dataset, or None if not found. |
Source code in evalsense/datasets/dataset_manager.py
register
classmethod
Registers a new dataset manager.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
manager
|
Type[DatasetManager]
|
The dataset manager to be registered. |
required |
DatasetMetadata
Bases: BaseModel
The metadata for a dataset.
Attributes:
Name | Type | Description |
---|---|---|
name |
str
|
The name of the dataset |
versions |
dict[str, VersionMetadata]
|
The dataset versions |
source |
OnlineSource | LocalSource
|
The immediate source of
the dataset (use |
Methods:
Name | Description |
---|---|
get_files |
Gets the files for the specified version and splits. |
get_splits |
Gets the dataset splits for the specified version. |
Source code in evalsense/datasets/dataset_config.py
effective_source
property
The effective source of the dataset.
Returns:
Type | Description |
---|---|
OnlineSource | LocalSource
|
The effective source. |
get_files
Gets the files for the specified version and splits.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
version
|
str
|
The name of the version. |
required |
splits
|
list[str]
|
The names of the splits. |
required |
Returns:
Type | Description |
---|---|
dict[str, FileMetadata]
|
The files for the version and splits. |
Source code in evalsense/datasets/dataset_config.py
get_splits
Gets the dataset splits for the specified version.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
version
|
str
|
The name of the version. |
required |
Returns:
Type | Description |
---|---|
dict[str, SplitMetadata]
|
The splits for the version. |
Source code in evalsense/datasets/dataset_config.py
DatasetRecord
Bases: BaseModel
A record identifying a dataset.
Attributes:
Name | Type | Description |
---|---|---|
name |
str
|
The name of the dataset. |
version |
str
|
The version of the dataset. |
splits |
list[str]
|
The used dataset splits. |
Methods:
Name | Description |
---|---|
__eq__ |
Checks if this record is equal to another record. |
__hash__ |
Returns a hash of the record. |
__lt__ |
Checks if this record is less than another record. |
Source code in evalsense/datasets/dataset_manager.py
__eq__
Checks if this record is equal to another record.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
other
|
object
|
The other record to compare with. |
required |
Returns:
Type | Description |
---|---|
bool
|
True if the records are equal, False otherwise. |
Source code in evalsense/datasets/dataset_manager.py
__hash__
Returns a hash of the record.
Returns:
Type | Description |
---|---|
int
|
The hash of the record. |
__lt__
Checks if this record is less than another record.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
other
|
object
|
The other record to compare with. |
required |
Returns:
Type | Description |
---|---|
bool
|
True if this record is less than the other, False otherwise. |
Source code in evalsense/datasets/dataset_manager.py
FileBasedDatasetManager
Bases: DatasetManager
An abstract class for managing datasets.
Attributes:
Name | Type | Description |
---|---|---|
priority |
int
|
The priority of the dataset manager. Ranges from 0 (the lowest priority) to 10 (the highest priority). A class attribute. |
name |
str
|
The name of the dataset. |
version |
str
|
The used dataset version. |
splits |
list[str]
|
The dataset splits to retrieve. |
data_path |
Path
|
The top-level directory for storing all datasets. |
dataset |
Dataset | None
|
The loaded dataset. |
dataset_dict |
DatasetDict | None
|
The loaded dataset dictionary. |
config |
DatasetConfig
|
The configuration for the dataset. |
all_splits |
list[str]
|
list[str]: All available dataset splits. |
Methods:
Name | Description |
---|---|
__init__ |
Initializes a new DatasetManager. |
can_handle |
Checks if the DatasetManager can handle the given dataset. |
create |
Creates a new dataset manager for the specified dataset. |
is_retrieved |
Checks if the dataset at the specific version is already downloaded. |
load |
Loads the dataset as a HuggingFace dataset. |
remove |
Deletes the dataset at the specific version from disk. |
retrieve |
Downloads and preprocesses a dataset. |
unload |
Unloads the dataset from memory. |
Source code in evalsense/datasets/dataset_manager.py
372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 |
|
dataset_path
property
The top-level directory for storing this dataset.
Returns:
Type | Description |
---|---|
Path
|
The dataset directory. |
main_data_path
property
The path for storing the preprocessed dataset files for a specific version.
Returns:
Type | Description |
---|---|
Path
|
The main dataset directory. |
record
property
Returns a record identifying the dataset.
Returns:
Type | Description |
---|---|
DatasetRecord
|
The dataset record. |
version_path
property
The directory for storing a specific version of this dataset.
Returns:
Type | Description |
---|---|
Path
|
The dataset version directory. |
__init__
__init__(
name: str,
version: str = DEFAULT_VERSION_NAME,
splits: list[str] | None = None,
data_dir: str | None = None,
**kwargs,
)
Initializes a new DatasetManager.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
The name of the dataset. |
required |
version
|
str
|
The dataset version to retrieve. |
DEFAULT_VERSION_NAME
|
splits
|
list[str]
|
The dataset splits to retrieve. |
None
|
data_dir
|
str
|
The top-level directory for storing all datasets. Defaults to "datasets" in the user cache directory. |
None
|
**kwargs
|
dict
|
Additional keyword arguments. |
{}
|
Source code in evalsense/datasets/dataset_manager.py
can_handle
abstractmethod
classmethod
Checks if the DatasetManager can handle the given dataset.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
The name of the dataset. |
required |
Returns:
Type | Description |
---|---|
bool
|
True if the manager can handle the dataset, False otherwise. |
Source code in evalsense/datasets/dataset_manager.py
create
classmethod
create(
name: str,
splits: list[str],
version: str | None = None,
data_dir: str | None = None,
**kwargs: dict,
) -> DatasetManager
Creates a new dataset manager for the specified dataset.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
The name of the dataset. |
required |
splits
|
list[str]
|
The dataset splits to retrieve. |
required |
version
|
str | None
|
The dataset version to retrieve. |
None
|
data_dir
|
str | None
|
The top-level directory for storing all datasets. |
None
|
**kwargs
|
dict
|
Additional keyword arguments. |
{}
|
Returns:
Type | Description |
---|---|
DatasetManager
|
The created dataset manager. |
Source code in evalsense/datasets/dataset_manager.py
is_retrieved
Checks if the dataset at the specific version is already downloaded.
Returns:
Type | Description |
---|---|
bool
|
True if the dataset exists locally, False otherwise. |
load
load(
*,
retrieve: bool = True,
cache: bool = True,
force_retrieve: bool = False,
load_as_dict: bool = False,
) -> Dataset | DatasetDict
Loads the dataset as a HuggingFace dataset.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
retrieve
|
bool
|
Whether to retrieve the dataset if it does not exist locally. Defaults to True. |
True
|
cache
|
bool
|
Whether to cache the dataset in memory. Defaults to True. |
True
|
force_retrieve
|
bool
|
Whether to force retrieving and
reloading the dataset even if it is already cached. Overrides
the |
False
|
load_as_dict
|
bool
|
Whether to load the dataset with multiple splits as a DatasetDict. If False (the default), the selected dataset splits are concatenated into a single dataset. |
False
|
Returns:
Type | Description |
---|---|
Dataset | DatasetDict
|
The loaded dataset. |
Source code in evalsense/datasets/dataset_manager.py
remove
retrieve
Downloads and preprocesses a dataset.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
**kwargs
|
dict
|
Additional keyword arguments. |
{}
|
Source code in evalsense/datasets/dataset_manager.py
FileMetadata
Bases: BaseModel
The metadata for a dataset file.
Attributes:
Name | Type | Description |
---|---|---|
name |
str
|
The name of the dataset file |
hash |
str
|
The hash of the dataset file |
hash_type |
str
|
The type of hash used for the dataset file |
source |
OnlineSource | LocalSource
|
The immediate source of
the dataset file (use |
parent |
SplitMetadata
|
The parent split metadata |
Source code in evalsense/datasets/dataset_config.py
effective_source
property
The effective source of the dataset file.
Returns:
Type | Description |
---|---|
OnlineSource | LocalSource
|
The effective source. |
LocalSource
Bases: BaseModel
The local source of the dataset file(s).
Attributes:
Name | Type | Description |
---|---|---|
path |
str
|
The path to the dataset file(s) |
Source code in evalsense/datasets/dataset_config.py
OnlineSource
Bases: BaseModel
The online source of the dataset file(s).
Attributes:
Name | Type | Description |
---|---|---|
url_template |
str
|
The URL template for the dataset file(s), optionally taking a version and filename |
requires_auth |
bool
|
Whether accessing the dataset file(s) requires authentication |
Source code in evalsense/datasets/dataset_config.py
SplitMetadata
Bases: BaseModel
The metadata for a dataset split.
Attributes:
Name | Type | Description |
---|---|---|
name |
str
|
The name of the dataset split |
files |
dict[str, FileMetadata]
|
The dataset files in the split |
source |
OnlineSource | LocalSource
|
The immediate source of
the dataset split (use |
parent |
VersionMetadata
|
The parent version metadata |
Source code in evalsense/datasets/dataset_config.py
effective_source
property
The effective source of the dataset split.
Returns:
Type | Description |
---|---|
OnlineSource | LocalSource
|
The effective source. |
VersionMetadata
Bases: BaseModel
The metadata for a dataset version.
Attributes:
Name | Type | Description |
---|---|---|
name |
str
|
The name of the dataset version |
splits |
dict[str, SplitMetadata]
|
The dataset splits in the version |
files |
dict[str, FileMetadata]
|
The dataset files in the version |
source |
OnlineSource | LocalSource
|
The immediate source of
the dataset version (use |
parent |
DatasetMetadata
|
The parent dataset metadata |
Methods:
Name | Description |
---|---|
get_files |
Gets the files for the specified splits. |
Source code in evalsense/datasets/dataset_config.py
effective_source
property
The effective source of the dataset version.
Returns:
Type | Description |
---|---|
OnlineSource | LocalSource
|
The effective source. |
get_files
Gets the files for the specified splits.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
splits
|
list[str]
|
The names of the splits. |
required |
Returns:
Type | Description |
---|---|
dict[str, FileMetadata]
|
The files for the splits. |
Source code in evalsense/datasets/dataset_config.py
manager
Decorator to register a dataset manager.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
manager
|
Type[DatasetManager]
|
The dataset manager to register. |
required |
Returns:
Type | Description |
---|---|
Type[DatasetManager]
|
Type["DatasetManager"]: The registered dataset manager. |