mirror of
https://github.com/LearningCircuit/local-deep-research.git
synced 2026-06-15 19:46:56 +03:00
* feat: Add pre-commit hook to enforce pathlib usage (issue #640) - Created check-pathlib-usage.py pre-commit hook using AST parsing - Detects os.path usage and suggests pathlib alternatives - Fixed os.path.normpath usage in auth/routes.py to use PurePosixPath - Added hook configuration to .pre-commit-config.yaml The hook provides helpful suggestions for replacing os.path calls with their pathlib equivalents for better cross-platform compatibility. Co-Authored-By: djpetti <djpetti@users.noreply.github.com> * feat: Add missing pathlib pre-commit hook script Co-Authored-By: djpetti <djpetti@users.noreply.github.com> * refactor: Migrate core src modules from os.path to pathlib - Fixed web/app_factory.py, config/llm_config.py, metrics/token_counter.py - Fixed utilities/es_utils.py, web/routes/benchmark_routes.py - Fixed web/routes/settings_routes.py, web_search_engines/engines/search_engine_local.py - Replaced os.path.join() with Path() / syntax - Replaced os.path.exists() with Path().exists() - Replaced os.path.basename() with Path().name - Replaced os.path.dirname() with Path().parent Part of the migration to modern pathlib API for better cross-platform compatibility and cleaner code. Co-Authored-By: djpetti <djpetti@users.noreply.github.com> * refactor: Migrate from os.path to pathlib in src and tests (issue #640) Replaced os.path usage with pathlib.Path throughout: - src/local_deep_research/benchmarks: All os.path.join, exists, dirname, basename, abspath replaced - tests directory: Complete migration of all test files - Improved cross-platform compatibility and code readability - Kept os.path.expandvars in env_settings.py (no pathlib equivalent) Part of pre-commit hook enforcement for pathlib usage. Remaining work: examples/ and scripts/ directories. Co-Authored-By: djpetti * fix: Complete migration from os.path to pathlib.Path (issue #640) Completed manual migration of all os.path usage to pathlib.Path across: - scripts/ directory (3 files) - examples/ directory (25 files total) - examples/benchmarks/ (8 files) - examples/optimization/ (16 files) - examples/show_env_vars.py - src/local_deep_research/settings/env_settings.py Changes made: - Replaced os.path.join() with Path() / syntax - Replaced os.path.exists() with Path().exists() - Replaced os.path.dirname() with Path().parent - Replaced os.path.basename() with Path().name or Path().stem - Replaced os.path.abspath() with Path().resolve() - Replaced os.makedirs() with Path().mkdir(parents=True, exist_ok=True) - Added pathlib import where needed Note: Kept os.path.expandvars in env_settings.py as there is no pathlib equivalent. Added comment explaining this limitation. This completes the pathlib migration for issue #640. Co-Authored-By: djpetti * fix: Allow os.path.expandvars in pathlib pre-commit hook Updated the check-pathlib-usage.py pre-commit hook to skip checking os.path.expandvars since it has no pathlib equivalent. Changes: - Added exception for expandvars in both visit_Attribute and visit_Call methods - Added comment in equivalents dictionary noting expandvars is allowed - This allows env_settings.py to use os.path.expandvars without failing checks This resolves the pre-commit CI failure while maintaining the pathlib enforcement for all other os.path methods. Co-Authored-By: djpetti --------- Co-authored-by: djpetti
66 lines
2.0 KiB
Python
66 lines
2.0 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
Example script showing all available environment variables for LDR configuration.
|
|
This demonstrates the centralized environment variable management in SettingsManager.
|
|
"""
|
|
|
|
import sys
|
|
import os
|
|
from pathlib import Path
|
|
|
|
# Add parent directory to path
|
|
sys.path.insert(0, str(Path(__file__).parent.parent / "src"))
|
|
|
|
from local_deep_research.settings.manager import SettingsManager
|
|
|
|
|
|
def main():
|
|
print("=== Local Deep Research Environment Variables ===\n")
|
|
|
|
all_env_vars = SettingsManager.get_all_env_vars()
|
|
|
|
for category, vars_dict in all_env_vars.items():
|
|
print(f"\n{category.upper()} VARIABLES:")
|
|
print("-" * 50)
|
|
|
|
for var_name, description in sorted(vars_dict.items()):
|
|
# Check if currently set
|
|
current_value = os.environ.get(var_name)
|
|
if current_value:
|
|
# Mask sensitive values
|
|
if any(
|
|
sensitive in var_name
|
|
for sensitive in ["KEY", "PASSWORD", "SECRET"]
|
|
):
|
|
display_value = "***SET***"
|
|
else:
|
|
display_value = current_value
|
|
status = f" [Current: {display_value}]"
|
|
else:
|
|
status = ""
|
|
|
|
print(f" {var_name}")
|
|
print(f" {description}{status}")
|
|
|
|
print("\n\n=== Environment Variable Formats ===")
|
|
print("-" * 50)
|
|
print(
|
|
"Settings can be overridden via environment variables using this format:"
|
|
)
|
|
print(" Setting key: app.host")
|
|
print(" Environment variable: LDR_APP__HOST")
|
|
print(
|
|
"\nNote: Use double underscores (__) to separate setting path components."
|
|
)
|
|
|
|
print("\n\n=== Bootstrap Variables ===")
|
|
print("-" * 50)
|
|
print("The following variables must be set before database access:")
|
|
bootstrap_vars = SettingsManager.get_bootstrap_env_vars()
|
|
for var in sorted(bootstrap_vars.keys()):
|
|
print(f" - {var}")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|