From 80954bdc9a2f3cde7fc8cb42221a4935c0f28798 Mon Sep 17 00:00:00 2001 From: niv vaknin Date: Mon, 30 Dec 2024 16:13:25 +0200 Subject: [PATCH 1/5] Add dotenv support --- Quorum/.env.example | 2 ++ Quorum/config.py | 3 +++ requirements.txt | 1 + 3 files changed, 6 insertions(+) create mode 100644 Quorum/.env.example diff --git a/Quorum/.env.example b/Quorum/.env.example new file mode 100644 index 0000000..78d3364 --- /dev/null +++ b/Quorum/.env.example @@ -0,0 +1,2 @@ +export ETHSCAN_API_KEY="your_etherscan_api_key" +export ANTHROPIC_API_KEY="your_anthropic_api_key" diff --git a/Quorum/config.py b/Quorum/config.py index 6ccce67..1d0986f 100644 --- a/Quorum/config.py +++ b/Quorum/config.py @@ -1,9 +1,12 @@ import os import shutil from pathlib import Path +import dotenv import Quorum.utils.pretty_printer as pp +dotenv.load_dotenv(override=True) + main_path = os.getenv("QUORUM_PATH") if not main_path: raise ValueError("QUORUM_PATH environment variable not set") diff --git a/requirements.txt b/requirements.txt index 8c31fa6..f067aa6 100644 --- a/requirements.txt +++ b/requirements.txt @@ -11,3 +11,4 @@ jinja2 langchain-anthropic langgraph langchain_community +dotenv From 808ca1bf18cb23f223b148f2cf0d80004fcee2ab Mon Sep 17 00:00:00 2001 From: niv vaknin Date: Mon, 30 Dec 2024 16:19:22 +0200 Subject: [PATCH 2/5] Fix --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index f067aa6..db83cc1 100644 --- a/requirements.txt +++ b/requirements.txt @@ -11,4 +11,4 @@ jinja2 langchain-anthropic langgraph langchain_community -dotenv +python-dotenv From 363b983247799487c65d3e75136a124a066e6fc1 Mon Sep 17 00:00:00 2001 From: niv vaknin Date: Mon, 30 Dec 2024 17:06:30 +0200 Subject: [PATCH 3/5] Address comments --- Quorum/config.py | 3 ++- Quorum/utils/load_env.py | 27 +++++++++++++++++++++++++++ README.md | 8 ++++++++ 3 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 Quorum/utils/load_env.py diff --git a/Quorum/config.py b/Quorum/config.py index 1d0986f..90b46e9 100644 --- a/Quorum/config.py +++ b/Quorum/config.py @@ -4,8 +4,9 @@ import dotenv import Quorum.utils.pretty_printer as pp +from Quorum.utils.load_env import load_env_variables -dotenv.load_dotenv(override=True) +load_env_variables() main_path = os.getenv("QUORUM_PATH") if not main_path: diff --git a/Quorum/utils/load_env.py b/Quorum/utils/load_env.py new file mode 100644 index 0000000..c55bb4f --- /dev/null +++ b/Quorum/utils/load_env.py @@ -0,0 +1,27 @@ +import os +from dotenv import load_dotenv + +import Quorum.utils.pretty_printer as pp + +def load_env_variables(): + # Capture the environment variables before loading .env + env_before = dict(os.environ) + + # Load .env with override=True + load_dotenv(override=True) + + # Capture the environment variables after loading .env + env_after = dict(os.environ) + + # Identify overridden variables + overridden_vars = { + key: {'before': env_before[key], 'after': env_after[key]} + for key in env_before + if key in env_after and env_before[key] != env_after[key] + } + + # Print the user if any environment variables were overridden + if overridden_vars: + pp.pretty_print("The following environment variables were overridden:", pp.Colors.WARNING) + for key, values in overridden_vars.items(): + pp.pretty_print(f"{key}: {values['before']} -> {values['after']}", pp.Colors.WARNING) diff --git a/README.md b/README.md index 47f7aa5..47b2e34 100644 --- a/README.md +++ b/README.md @@ -49,6 +49,14 @@ export ANTHROPIC_API_KEY="your_anthropic_api_key" Replace `your_etherscan_api_key`, `your_anthropic_api_key` with your actual API keys. +Alternatively, you can set these environment variables in a `.env` file in the current working directory where you use the tool: + +```sh +ETHSCAN_API_KEY=your_etherscan_api_key +ANTHROPIC_API_KEY=your_anthropic_api_key +``` + + Additionally, set the `QUORUM_PATH` environment variable to specify where the repositories and diffs will be saved: ```sh From ab7e76c5b395007468d09817c48787cf56276a81 Mon Sep 17 00:00:00 2001 From: niv vaknin Date: Mon, 30 Dec 2024 17:07:45 +0200 Subject: [PATCH 4/5] Remove unnesscary import --- Quorum/config.py | 1 - 1 file changed, 1 deletion(-) diff --git a/Quorum/config.py b/Quorum/config.py index 90b46e9..32f2cb9 100644 --- a/Quorum/config.py +++ b/Quorum/config.py @@ -1,7 +1,6 @@ import os import shutil from pathlib import Path -import dotenv import Quorum.utils.pretty_printer as pp from Quorum.utils.load_env import load_env_variables From 274b0ab3ab03f2e41c648c1a41ea4aec55da4e2d Mon Sep 17 00:00:00 2001 From: Niv vaknin <122722245+nivcertora@users.noreply.github.com> Date: Tue, 31 Dec 2024 08:37:32 +0200 Subject: [PATCH 5/5] Update README.md Co-authored-by: yoav-el-certora <122207807+yoav-el-certora@users.noreply.github.com> --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 3c2965f..1507ee0 100644 --- a/README.md +++ b/README.md @@ -50,6 +50,7 @@ export ANTHROPIC_API_KEY="your_anthropic_api_key" Replace `your_etherscan_api_key`, `your_anthropic_api_key` with your actual API keys. Alternatively, you can set these environment variables in a `.env` file in the current working directory where you use the tool: +(Please review /Quorum/.env.example) ```sh ETHSCAN_API_KEY=your_etherscan_api_key