Skip to content

Commit

Permalink
Structure runner loads dotenv if it exists
Browse files Browse the repository at this point in the history
  • Loading branch information
zachgiordano committed Aug 6, 2023
1 parent 05fddd8 commit def574a
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions griptape/cli/core/structure_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
import subprocess
import sys
from typing import Optional

from attr import Factory, define, field
from dotenv import load_dotenv


@define
Expand All @@ -19,6 +21,7 @@ def run(self):
try:
sys.path.append(self.app_directory)
self._install_pip_dependencies()
self._load_dotenv()
from app import init_structure

try:
Expand All @@ -34,3 +37,8 @@ def _install_pip_dependencies(self) -> None:
subprocess.check_call(
[sys.executable, "-m", "pip", "install", "-r", requirements_path]
)

def _load_dotenv(self) -> None:
dotenv_path = os.path.join(self.app_directory, ".env")
if os.path.exists(dotenv_path):
load_dotenv(dotenv_path)

0 comments on commit def574a

Please sign in to comment.