From 1830b16a05d0da8d99ee7c91d8c8a27f3ba9e435 Mon Sep 17 00:00:00 2001 From: Max Chis Date: Fri, 18 Apr 2025 07:55:52 -0400 Subject: [PATCH] refactor(app): consolidate environment variable usage Consolidate environment variable usage through a centralized class, to enable easy mocking and tracking of environment variables. --- source_collectors/auto_googler/AutoGooglerCollector.py | 9 +++++---- .../integration/source_collectors/__init__.py | 0 .../source_collectors/test_example_collector.py | 0 3 files changed, 5 insertions(+), 4 deletions(-) delete mode 100644 tests/test_automated/integration/source_collectors/__init__.py delete mode 100644 tests/test_automated/integration/source_collectors/test_example_collector.py diff --git a/source_collectors/auto_googler/AutoGooglerCollector.py b/source_collectors/auto_googler/AutoGooglerCollector.py index 1748d911..01387d0b 100644 --- a/source_collectors/auto_googler/AutoGooglerCollector.py +++ b/source_collectors/auto_googler/AutoGooglerCollector.py @@ -1,13 +1,13 @@ -import asyncio from collector_manager.AsyncCollectorBase import AsyncCollectorBase from collector_manager.enums import CollectorType +from core.EnvVarManager import EnvVarManager from core.preprocessors.AutoGooglerPreprocessor import AutoGooglerPreprocessor from source_collectors.auto_googler.AutoGoogler import AutoGoogler from source_collectors.auto_googler.DTOs import AutoGooglerInputDTO, AutoGooglerInnerOutputDTO from source_collectors.auto_googler.GoogleSearcher import GoogleSearcher from source_collectors.auto_googler.SearchConfig import SearchConfig -from util.helper_functions import get_from_env, base_model_list_dump +from util.helper_functions import base_model_list_dump class AutoGooglerCollector(AsyncCollectorBase): @@ -16,14 +16,15 @@ class AutoGooglerCollector(AsyncCollectorBase): async def run_to_completion(self) -> AutoGoogler: dto: AutoGooglerInputDTO = self.dto + env_var_manager = EnvVarManager.get() auto_googler = AutoGoogler( search_config=SearchConfig( urls_per_result=dto.urls_per_result, queries=dto.queries, ), google_searcher=GoogleSearcher( - api_key=get_from_env("GOOGLE_API_KEY"), - cse_id=get_from_env("GOOGLE_CSE_ID"), + api_key=env_var_manager.google_api_key, + cse_id=env_var_manager.google_cse_id, ) ) async for log in auto_googler.run(): diff --git a/tests/test_automated/integration/source_collectors/__init__.py b/tests/test_automated/integration/source_collectors/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/tests/test_automated/integration/source_collectors/test_example_collector.py b/tests/test_automated/integration/source_collectors/test_example_collector.py deleted file mode 100644 index e69de29b..00000000