feat: add prominent startup warning for DEV mode

Add comprehensive warning display when server starts in development mode
to ensure users are aware of simulated AI calls and data handling.

Changes:
- Add log_dev_mode_startup_warning() function in deployment_config.py
- Display warning on main.py startup when DEPLOYMENT_MODE=DEV
- Display warning on API server startup (api/main.py)
- Warning shows AI simulation status and data persistence behavior
- Provides clear instructions for switching to PROD mode

The warning is highly visible and informs users that:
- AI API calls are simulated (no costs incurred)
- Data may be reset between runs (based on PRESERVE_DEV_DATA)
- System is using isolated dev database and paths

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-11-01 12:57:54 -04:00
parent d656dac1d0
commit b9353e34e5
3 changed files with 45 additions and 6 deletions

View File

@@ -23,7 +23,7 @@ from api.simulation_worker import SimulationWorker
from api.database import get_db_connection from api.database import get_db_connection
from api.price_data_manager import PriceDataManager from api.price_data_manager import PriceDataManager
from api.date_utils import validate_date_range, expand_date_range, get_max_simulation_days from api.date_utils import validate_date_range, expand_date_range, get_max_simulation_days
from tools.deployment_config import get_deployment_mode_dict from tools.deployment_config import get_deployment_mode_dict, log_dev_mode_startup_warning
import threading import threading
import time import time
@@ -506,4 +506,8 @@ app = create_app()
if __name__ == "__main__": if __name__ == "__main__":
import uvicorn import uvicorn
# Display DEV mode warning if applicable
log_dev_mode_startup_warning()
uvicorn.run(app, host="0.0.0.0", port=8080) uvicorn.run(app, host="0.0.0.0", port=8080)

View File

@@ -12,7 +12,8 @@ from prompts.agent_prompt import all_nasdaq_100_symbols
from tools.deployment_config import ( from tools.deployment_config import (
is_dev_mode, is_dev_mode,
get_deployment_mode, get_deployment_mode,
log_api_key_warning log_api_key_warning,
log_dev_mode_startup_warning
) )
from api.database import initialize_dev_database from api.database import initialize_dev_database
@@ -108,16 +109,13 @@ async def main(config_path=None):
# Initialize dev environment if needed # Initialize dev environment if needed
if is_dev_mode(): if is_dev_mode():
print("=" * 60) log_dev_mode_startup_warning()
print("🛠️ DEVELOPMENT MODE ACTIVE")
print("=" * 60)
log_api_key_warning() log_api_key_warning()
# Initialize dev database (reset unless PRESERVE_DEV_DATA=true) # Initialize dev database (reset unless PRESERVE_DEV_DATA=true)
from tools.deployment_config import get_db_path from tools.deployment_config import get_db_path
dev_db_path = get_db_path("data/jobs.db") dev_db_path = get_db_path("data/jobs.db")
initialize_dev_database(dev_db_path) initialize_dev_database(dev_db_path)
print("=" * 60)
# Get Agent type # Get Agent type
agent_type = config.get("agent_type", "BaseAgent") agent_type = config.get("agent_type", "BaseAgent")

View File

@@ -119,6 +119,43 @@ def log_api_key_warning() -> None:
print(" This is expected if you're testing dev mode with existing .env file") print(" This is expected if you're testing dev mode with existing .env file")
def log_dev_mode_startup_warning() -> None:
"""
Display prominent warning when server starts in DEV mode
Warns users that:
- AI calls will be simulated/mocked
- Data may not be retained between runs
- This is a development environment
"""
if not is_dev_mode():
return
preserve_data = should_preserve_dev_data()
print()
print("=" * 70)
print("⚠️ " + "DEVELOPMENT MODE WARNING".center(64) + " ⚠️")
print("=" * 70)
print()
print(" 🚧 This server is running in DEVELOPMENT mode (DEPLOYMENT_MODE=DEV)")
print()
print(" 📌 IMPORTANT:")
print(" • AI API calls will be SIMULATED (mock responses)")
print(" • No real AI model costs will be incurred")
if preserve_data:
print(" • Dev data WILL BE PRESERVED between runs (PRESERVE_DEV_DATA=true)")
else:
print(" • Dev data WILL BE RESET on each startup (PRESERVE_DEV_DATA=false)")
print(" • Using isolated dev database and data paths")
print()
print(" 💡 To use PRODUCTION mode:")
print(" Set environment variable: DEPLOYMENT_MODE=PROD")
print()
print("=" * 70)
print()
def get_deployment_mode_dict() -> dict: def get_deployment_mode_dict() -> dict:
""" """
Get deployment mode information as dictionary (for API responses) Get deployment mode information as dictionary (for API responses)