Tom
06/07/2024, 1:37 PMdatajoely
06/07/2024, 1:38 PMIan Whalen
06/07/2024, 2:08 PMcredentials.yml
for your keys
Another approach would just be to use a dotenv hook so they get set at runtime.
I've been liking that approach too. So your settings.py
would look like:
import logging
from dotenv import load_dotenv
from kedro.framework.hooks import hook_impl
logger = logging.getLogger(__name__)
class DotenvHook:
@hook_impl
def after_context_created(self, *args, **kwargs) -> None:
loaded = load_dotenv()
if loaded:
logger.info("Dotenv loaded successfully.")
else:
logger.warning("Dotenv not found!")
HOOKS = (DotenvHook(),)
... other settings things ...
Then you just dump in your openai keys to your .env
Not sure which one is better! Using credentials.yml
is probably more kedronic (?) and if you're using LangChain those datasets could be helpfulNok Lam Chan
06/07/2024, 2:28 PMtryfirst
argument to the hook just to make sure this get executed before anything. https://docs.kedro.org/en/stable/hooks/introduction.html#hook-execution-order
And also curious if it makes sense for Kedro to support dotenv
natively? It's actually 1 line of code because we use dynaconf
and it integrate dotenv natively (technically load_dot_env
) is also just one line of code though.Ian Whalen
06/07/2024, 2:30 PMconf/env
's and credentials.yml
I wasn't sure if dotenv
clashed with thisNok Lam Chan
06/07/2024, 2:38 PMdynaconf
https://github.com/kedro-org/kedro/discussions/3877, feel free to open a discussion to talk about how credentials should works with env var etc.