Sneha Kumari
10/23/2024, 3:47 AMdatajoely
10/23/2024, 7:01 AMVishal Pandey
10/23/2024, 11:02 AMLaurens Vijnck
10/23/2024, 11:53 AM"""Custom resolvers for Kedro project."""
import os
from typing import Dict, Optional
from copy import deepcopy
from dotenv import load_dotenv
load_dotenv()
def env(key: str, default: str = None) -> Optional[str]:
"""Load a variable from the environment.
See <https://omegaconf.readthedocs.io/en/latest/custom_resolvers.html#custom-resolvers>
Args:
key (str): Key to load.
default (str): Default value to use instead
Returns:
str: Value of the key
"""
try:
value = os.environ.get(key, default)
if value is None:
raise KeyError()
return value
except KeyError:
raise KeyError(f"Environment variable '{key}' not found or default value {default} is None")
Vishal Pandey
10/23/2024, 12:20 PMLaurens Vijnck
10/23/2024, 12:28 PMLaurens Vijnck
10/23/2024, 12:29 PMVishal Pandey
10/23/2024, 12:32 PMLaurens Vijnck
10/23/2024, 12:58 PM