Datasets
Modules:
Name | Description |
---|---|
dataset_config |
|
dataset_manager |
|
managers |
|
Classes:
Name | Description |
---|---|
DatasetConfig |
Configuration for a dataset. |
DatasetManager |
An abstract class for managing datasets. |
DatasetMetadata |
The metadata for a dataset. |
DatasetRecord |
A record identifying a dataset. |
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. |
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
An abstract class for managing datasets.
Attributes:
Name | Type | Description |
---|---|---|
name |
str
|
The name of the dataset. |
config |
DatasetConfig
|
The configuration for the dataset. |
version |
str
|
The used dataset version. |
splits |
list[str]
|
The dataset splits to retrieve. |
priority |
int
|
The priority of the dataset manager. |
data_path |
Path
|
The top-level directory for storing all datasets. |
dataset |
Dataset | None
|
The loaded dataset. |
Methods:
Name | Description |
---|---|
__init__ |
Initializes a new DatasetManager. |
can_handle |
Checks if the DatasetManager can handle the given dataset. |
get |
Downloads and preprocesses a dataset. |
is_retrieved |
Checks if the dataset at the specific version is already downloaded. |
load |
Loads the dataset as a HuggingFace dataset. |
load_dict |
Loads the dataset as a HuggingFace dataset dictionary. |
remove |
Deletes the dataset at the specific version from disk. |
unload |
Unloads the dataset from memory. |
unload_dict |
Unloads the dataset dictionary from memory. |
Source code in evalsense/datasets/dataset_manager.py
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 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 |
|
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,
priority: int = 10,
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
|
priority
|
int
|
The priority of the dataset manager when choosing between multiple possible managers. Recommended values range from 0 to 10, with 10 (the highest) being the default. |
10
|
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
get
Downloads and preprocesses a dataset.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
**kwargs
|
dict
|
Additional keyword arguments. |
{}
|
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
Loads the dataset as a HuggingFace dataset.
If multiple splits are specified, they are concatenated into a single
dataset. See the load_dict
method if you wish to load the dataset as a
DatasetDict
.
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
|
Returns:
Type | Description |
---|---|
Dataset
|
The loaded dataset. |
Source code in evalsense/datasets/dataset_manager.py
load_dict
load_dict(
retrieve: bool = True,
cache: bool = True,
force_retrieve: bool = False,
) -> DatasetDict
Loads the dataset as a HuggingFace dataset dictionary.
See the load
method if you wish to concatenate the splits into
a single 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
|
Returns:
Type | Description |
---|---|
DatasetDict
|
The loaded dataset dictionary. |
Source code in evalsense/datasets/dataset_manager.py
remove
unload
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
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. |