Closed alexander-haller closed 4 months ago
In GitLab by @mhxion on Jun 27, 2024, 02:56
I am not requesting a review as this is mainly a refactor of !55 (section: "Robust configuration") which had been approved.
In GitLab by @mhxion on Jun 27, 2024, 02:56
approved this merge request
In GitLab by @mhxion on Jun 27, 2024, 02:56
unapproved this merge request
In GitLab by @mhxion on Jun 27, 2024, 02:52
Merges simple-config-initiation -> dev
This is mainly introduced and needed for "elAPI as a library" users. I.e., developers who will be using elAPI to write simple Python scripts, but not plugins. elAPI handles the initiation and validation of configuration for plugins itself.
reinitiate_config
replaces doing explicit configuration validation that we introduced in !55.When we run elAPI from the CLI, it handles the configuration validation for us among many other types of validations. E.g., if
export_dir: True
is defined which doesn't make sense forexport_dir
as it must be a string (directory path), elAPI, instead of throwing an error or failing, uses a fallback export directory when we need to export something. We can check which export directory elAPI is using fromelapi show-config
. However, in the same situation, if we are using elAPI in a Python script, and we try to export aGETRequest
response, elAPI will not use a fallback directory and fail. That's because no "smart" configuration validation is run automatically for scripts. This is meant to give a Python developer more control over elAPI and its behavior by making the least number of decisions. If we want to have the similar validation as elAPI does for CLI commands, we would have to just run thisreinitiate_config
function. _In other words,reinitiate_config
is necessary for Python scripts, if a strict and smart validation ofelapi.yml
is desired._