dqm_ml_job.dataloaders
Data loaders module for DQM ML Job.
This module contains classes for loading data from various sources and protocols. It provides the DataLoader and DataSelection protocols along with concrete implementations for different file formats.
Classes:
| Name | Description |
|---|---|
DataLoader |
Protocol for data loader factories. |
DataSelection |
Protocol for data subsets. |
ParquetDataLoader |
Loader for Parquet files. |
PandasDataLoader |
Loader for CSV files using Pandas. |
__all__ = ['DataLoader', 'DataSelection', 'PandasDataLoader', 'ParquetDataLoader', 'dqml_dataloaders_registry']
module-attribute
dqml_dataloaders_registry = {'parquet': ParquetDataLoader, 'csv': PandasDataLoader}
module-attribute
DataLoader
Bases: Protocol
Protocol for Data Loader factories.
A DataLoader is responsible for scanning a source (disk, DB, S3) and discovering available DataSelections based on its configuration.
Source code in packages/dqm-ml-job/src/dqm_ml_job/dataloaders/proto.py
get_selections() -> list[DataSelection]
Discover and return the list of available selections for this loader.
Returns:
| Type | Description |
|---|---|
list[DataSelection]
|
A list of initialized DataSelection instances. |
DataSelection
Bases: Protocol
Protocol for a specific subset of data discovered by a DataLoader.
A DataSelection represents a concrete set of samples (e.g., a specific folder, a filtered view of a database, or a single file) and provides an iterator over data batches.
Source code in packages/dqm-ml-job/src/dqm_ml_job/dataloaders/proto.py
name: str
instance-attribute
__iter__() -> Any
bootstrap(columns_list: list[str]) -> None
Perform initial setup for the selection before iteration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
columns_list
|
list[str]
|
List of column names to load. |
required |
get_nb_batches() -> int
Return the estimated number of batches in this selection.
Used primarily for progress bar estimation.
PandasDataLoader
Data loader for CSV files using Pandas.
This loader reads CSV files and provides DataSelections for processing by the DQM pipeline.
Attributes:
| Name | Type | Description |
|---|---|---|
type |
str
|
The loader type identifier ("csv"). |
Source code in packages/dqm-ml-job/src/dqm_ml_job/dataloaders/pandas.py
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 | |
filesystem = None
instance-attribute
filters_dict = {}
instance-attribute
id_column = config.get('id_column')
instance-attribute
name = name
instance-attribute
path = config['path']
instance-attribute
sample_path = config.get('sample_path', [])
instance-attribute
split = SplitConfig.model_validate(split) if split else None
instance-attribute
split_by = self.split.by if self.split else None
instance-attribute
split_values = self.split.values if self.split else None
instance-attribute
transforms = config.get('transform', [])
instance-attribute
type: str = 'csv'
class-attribute
instance-attribute
__init__(name: str, config: dict[str, Any] | None = None)
Initialize the Pandas data loader.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Unique name for this loader instance. |
required |
config
|
dict[str, Any] | None
|
Configuration dictionary containing: - path: Path to CSV file (required) |
None
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If required config keys are missing. |
Source code in packages/dqm-ml-job/src/dqm_ml_job/dataloaders/pandas.py
get_selections() -> list[DataSelection]
Create one or more PandasDataSelection instances based on split config.
If split is configured, returns one selection per split value. Otherwise returns a single selection for the entire CSV file.
Returns:
| Type | Description |
|---|---|
list[DataSelection]
|
A list of DataSelection instances. |
Source code in packages/dqm-ml-job/src/dqm_ml_job/dataloaders/pandas.py
ParquetDataLoader
Data loader for Parquet files that generates one or more DataSelections.
This loader can read from a single Parquet file or a directory of Parquet files, optionally splitting the data by a column value to create multiple selections.
Attributes:
| Name | Type | Description |
|---|---|---|
type |
str
|
The loader type identifier ("parquet"). |
filesystem |
Optional PyArrow filesystem for reading. |
Source code in packages/dqm-ml-job/src/dqm_ml_job/dataloaders/parquet.py
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 370 371 372 373 374 375 376 377 378 379 380 | |
batch_size = config.get('batch_size', 100000)
instance-attribute
config = config
instance-attribute
filesystem = None
instance-attribute
filters_dict = {}
instance-attribute
id_column = config.get('id_column')
instance-attribute
name = name
instance-attribute
path: str = config['path']
instance-attribute
sample_path = config.get('sample_path', [])
instance-attribute
split = SplitConfig.model_validate(split) if split else None
instance-attribute
split_by = self.split.by if self.split else None
instance-attribute
split_values = self.split.values if self.split else None
instance-attribute
storage_config = storage_config
instance-attribute
threads = config.get('threads', 4)
instance-attribute
transforms = config.get('transform', [])
instance-attribute
type: str = 'parquet'
class-attribute
instance-attribute
__init__(name: str, config: dict[str, Any] | None = None)
Initialize the Parquet data loader.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Unique name for this loader instance. |
required |
config
|
dict[str, Any] | None
|
Configuration dictionary containing: - path: Path to Parquet file or directory (required) - batch_size: Rows per batch (default: 100000) - threads: Number of threads (default: 4) - split_by: Column name to split selections by - split_values: Specific values to split on - filter.: list of filters - storage: Storage configuration (bool or dict) |
None
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If required config keys are missing. |
Source code in packages/dqm-ml-job/src/dqm_ml_job/dataloaders/parquet.py
get_selections() -> list[DataSelection]
Create one or more ParquetDataSelection instances based on configuration.
Returns:
| Type | Description |
|---|---|
list[DataSelection]
|
A list of DataSelection instances. If split_by is configured, |
list[DataSelection]
|
returns one selection per unique value. Otherwise, returns a |
list[DataSelection]
|
single selection for the entire dataset. |