Loading
Functions to load the logged data from experiments and their repetitions and the structure of the generated experiments.
The functions can be accessed under the module: exputils.data
Usually the data is loaded in Jupyter notebook using the ExperimentDataLoaderWidget
.
The following loading functions can be used if data should be loaded for a custom analysis or plots.
load_experiment_descriptions
Loads and returns descriptions of experiments from a specified experiments directory.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
experiments_directory
|
str
|
Path to the experiments directory. Defaults to "..\DEFAULT_EXPERIMENTS_DIRECTORY". |
None
|
allowed_experiments_id_list
|
list
|
List of experiment IDs to be loaded. Cannot be used with denied_experiments_id_list. Default: All experiments are considered. |
None
|
denied_experiments_id_list
|
list
|
List of experiment IDs to be excluded. Cannot be used with allowed_experiments_id_list. Default: All experiments are considered. |
None
|
experiment_directory_template
|
str
|
Template string for the name of experiment directories. The template should include a placeholder for the experiment id. Example: 'experiment_{:06d}' for experiment folders with ids with at least six digits. Defaults to EXPERIMENT_DIRECTORY_TEMPLATE. |
None
|
repetition_directory_template
|
str
|
Template string for the name of experiment directories. The template should include a placeholder for the repetition id. Example: 'repetition_{:06d}' for repetition folders with ids with at least six digits. Defaults to REPETITION_DIRECTORY_TEMPLATE. |
None
|
Returns:
Name | Type | Description |
---|---|---|
AttrDict |
AttrDict
|
A dictionary containing descriptions of the experiments. |
AttrDict
|
The keys are the experiment ids and the values are dictionaries with the follwing properties:
|
Source code in exputils/data/loading.py
load_experiment_data
Loads logged data from experiments and their repetitions in form of nested dictionaries and numpy arrays.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
experiment_descriptions
|
AttrDict
|
Predefined descriptions of the experiments.
The descriptions contain the paths to all experiments and their repetitions that should be loaded.
See |
None
|
experiments_directory
|
str
|
Path to the experiments directory.
Defaults to |
None
|
allowed_experiments_id_list
|
list
|
List of allowed experiment IDs. Only these will be loaded. Can not be set together with denied_experiments_id_list. |
None
|
denied_experiments_id_list
|
list
|
List of denied experiment IDs. All experiments besides these will be loaded. Can not be set together with allowed_experiments_id_list. |
None
|
data_directory
|
str
|
Relative path of the data directories under the experiments and repetitions.
Defaults to |
None
|
is_load_repetition_data
|
bool
|
Flag to indicate if repetition data should be loaded.
Defaults to |
True
|
pre_allowed_data_filter
|
list
|
List of datasources that will be loaded before the loading callback functions
(see |
None
|
pre_denied_data_filter
|
list
|
List of datasources that will NOT be loaded before the loading callback functions
(see |
None
|
post_allowed_data_filter
|
list
|
List of datasources that will be added to the data dictionary that is returned after
loading and the loading callback functions (see |
None
|
post_denied_data_filter
|
list
|
List of datasources that will NOT be added to the data dictionary that is returned after
loading and the loading callback functions (see |
None
|
on_experiment_data_loaded
|
list
|
List of callback functions executed when experiment data is loaded. Can be used to modify the data by changing or adding elements. Form of the functions: func(exp_id: int, exp_data: AttrDict) -> AttrDict. |
None
|
on_repetition_data_loaded
|
list
|
List of callback functions executed when repetition data is loaded. Can be used to modify the data by changing or adding elements. Form of the functions: func(exp_id: int, exp_data: AttrDict) -> AttrDict. |
None
|
allow_pickle
|
bool
|
Indicates if loading of pickled objects is allowed.
Defaults to True. |
True
|
Returns:
Name | Type | Description |
---|---|---|
data |
AttrDict
|
Loaded data. |
experiment_descriptions |
AttrDict
|
Experiment descriptions of the loaded data.
See |
Source code in exputils/data/loading.py
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 |
|
load_single_experiment_data
Loads data for a single experiment which includes all its repetition data.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
experiment_directory
|
str
|
Path to the experiment directory. |
required |
data_directory
|
str
|
Relative path of the data directories under the experiments and repetitions.
Defaults to |
None
|
allowed_data_filter
|
list
|
List of datasource names (strings) that will be loaded. If defined then only these datasources will be loaded. |
None
|
denied_data_filter
|
list
|
List of datasource names (strings) that will NOT be loaded. If defined then all datasources besides the specified ones will be loaded. |
None
|
allow_pickle
|
bool
|
Indicates if loading of pickled objects is allowed.
Defaults to True. |
True
|
Returns:
Name | Type | Description |
---|---|---|
data |
AttrDict
|
A dictionary containing the loaded data. |
Source code in exputils/data/loading.py
load_experiment_data_single_object
Loads single object that was logged via the add_single_object. function and saved as a dill file. The file that is either located under the experiments, or a single experiment or repetition directory.
This could allow arbitrary code execution. Only load files you trust!
Example
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
The name of the object which is the name of the dill file with or without extension. |
required |
experiment_id
|
int
|
An optional identifier for a specific experiment. If not provided, then the object is loaded from the experiments directory. |
None
|
repetition_id
|
int
|
An optional identifier for a specific repetition of the experiment. If not provided, then the object is loaded from the experiments or experiment directory. |
None
|
experiments_directory
|
str
|
The root directory where all experiments are stored.
Defaults to |
None
|
data_directory
|
str
|
Relative path of the data directories under the experiments and repetitions.
Defaults to |
None
|
experiment_directory_template
|
str
|
Name template of experiment directories.
Defaults to |
None
|
repetition_directory_template
|
str
|
Template for constructing the repetition directory. Defaults to None.
Name template of repetition directories.
Defaults to |
None
|
add_execution_directory_to_sys_path
|
bool
|
Whether to add the execution directory to the system path temporailly while loading the object. This can be necessary if the object has relational import statements. By adding the directory where the object is located temporailly to the python path, these import statments can be processed correctly. Defaults to True. |
True
|
Returns:
Name | Type | Description |
---|---|---|
object |
object
|
The loaded experiment data object. |
Source code in exputils/data/loading.py
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 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 |
|
load_experiment_python_module
Loads a Python module dynamically that is either located under the experiments, or a single experiment or repetition directory. This can be used to load for example the configuration file of a repetition.
Example
This could allow arbitrary code execution. Only load files you trust!
Parameters:
Name | Type | Description | Default |
---|---|---|---|
module_path
|
str
|
The realtive path to the python module file either under the experiments, experiment, or repetition directory. Which level depends on if an experiment_id and a repetition_id are provided or not. |
required |
experiment_id
|
int
|
An optional identifier for a specific experiment. If not provided, then the module is loaded from the experiments directory. |
None
|
repetition_id
|
int
|
An optional identifier for a specific repetition of the experiment. If not provided, then the module is loaded from the experiments or experiment directory. |
None
|
experiments_directory
|
str
|
The root directory where all experiments are stored.
Defaults to |
None
|
exec_module
|
bool
|
If True, the module will be executed after being loaded which means it will be imported. Defaults to True. |
True
|
experiment_directory_template
|
str
|
Name template of experiment directories.
Defaults to |
None
|
repetition_directory_template
|
str
|
Template for constructing the repetition directory. Defaults to None.
Name template of repetition directories.
Defaults to |
None
|
add_execution_directory_to_sys_path
|
bool
|
If True, the script's execution directory will be added to sys.path. Defaults to True. |
True
|
Returns:
Name | Type | Description |
---|---|---|
module |
ModuleType
|
The loaded Python module object. |
Source code in exputils/data/loading.py
457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 |
|