Kacper Leśniara
05/16/2024, 10:53 AMOmegaConfigLoader
?Juan Luis
05/16/2024, 11:56 AMKacper Leśniara
05/16/2024, 12:09 PMSajid Alam
05/16/2024, 2:47 PMsettings.py
to use OmegaConfigLoader
and validate parameters using the model there. You'll then have to update the nodes to use these typed parameters.Kacper Leśniara
05/17/2024, 8:44 AMOmegaConfigLoader
, what do you mean by "validate parameters using the model there"?Sajid Alam
05/17/2024, 11:28 AMfrom pydantic import ValidationError
from YOUR_PYDANTIC_MODEL import MyConfig
def load_and_validate_parameters(config_loader):
config_data = config_loader.get("parameters*")
try:
return MyConfig(**config_data)
except ValidationError as e:
raise ValueError(f"Invalid configuration: {e}")
from kedro.framework.context import KedroContext
class ProjectContext(KedroContext):
def _load_parameters(self):
config_loader = self.config_loader
return load_and_validate_parameters(config_loader)
CONTEXT_CLASS = ProjectContext
Kacper Leśniara
05/17/2024, 11:30 AM