dqm_ml_job.dataloaders.parquet
Parquet data loader for reading Parquet files.
This module contains the ParquetDataLoader and ParquetDataSelection classes for loading and iterating over Parquet file data.
logger = logging.getLogger(__name__)
module-attribute
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. |
Source code in packages/dqm-ml-job/src/dqm_ml_job/dataloaders/parquet.py
ParquetDataSelection
Bases: DataSelection
A specific selection of data from a Parquet dataset.
This class represents a filtered subset of a Parquet dataset and provides an iterator over PyArrow RecordBatches.
Attributes:
| Name | Type | Description |
|---|---|---|
name |
Name identifier for this selection. |
|
path |
Path to the Parquet file or directory. |
|
batch_size |
Number of rows per batch. |
|
threads |
Number of threads for parallel reading. |
|
filters_dict |
Optional dictionary of column filters to apply. |
|
filesystem |
Optional PyArrow filesystem for reading. |
|
sample_path |
List of sample path configs describing column path prefixes. |
|
transforms |
List of transform configs (column cast operations). |
Source code in packages/dqm-ml-job/src/dqm_ml_job/dataloaders/parquet.py
70 71 72 73 74 75 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 | |
batch_size = batch_size
instance-attribute
columns_list: list[str] | None = None
instance-attribute
dataset: pq.ParquetDataset | None = None
instance-attribute
filesystem = filesystem
instance-attribute
filters_dict = filters_dict
instance-attribute
name = name
instance-attribute
path = path
instance-attribute
sample_path = sample_path or []
instance-attribute
samples_count: int = 0
instance-attribute
threads = threads
instance-attribute
transforms = transforms or []
instance-attribute
__init__(name: str, path: str, batch_size: int = 100000, threads: int = 4, filters_dict: dict[str, Any] | None = None, filesystem: Any | None = None, sample_path: list[dict[str, Any]] | None = None, transforms: list[dict[str, Any]] | None = None)
Initialize a Parquet data selection.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Name identifier for this selection. |
required |
path
|
str
|
Path to the Parquet file or directory. |
required |
batch_size
|
int
|
Number of rows per batch (default: 100000). |
100000
|
threads
|
int
|
Number of threads for parallel reading (default: 4). |
4
|
filters_dict
|
dict[str, Any] | None
|
Optional dictionary of column filters to apply. |
None
|
filesystem
|
Any | None
|
Optional PyArrow filesystem for reading. |
None
|
sample_path
|
list[dict[str, Any]] | None
|
List of sample path configs describing column path prefixes. |
None
|
transforms
|
list[dict[str, Any]] | None
|
List of transform configs (column cast operations). |
None
|
Source code in packages/dqm-ml-job/src/dqm_ml_job/dataloaders/parquet.py
__iter__() -> Any
Source code in packages/dqm-ml-job/src/dqm_ml_job/dataloaders/parquet.py
__len__() -> int
__repr__() -> str
bootstrap(columns_list: list[str]) -> None
Initialize the parquet dataset and filter expression.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
columns_list
|
list[str]
|
Names of columns to load from the parquet file. Empty list means read all columns. |
required |
Source code in packages/dqm-ml-job/src/dqm_ml_job/dataloaders/parquet.py
get_nb_batches() -> int
Return the estimated number of batches in this selection.
Returns:
| Type | Description |
|---|---|
int
|
Number of batches based on total samples and batch size. |