Skip to content

Remove import-time print statements from OpenWebUI engine#3

Merged
achimrabus merged 5 commits intogemini-3-adjustmentsfrom
copilot/sub-pr-2
Dec 3, 2025
Merged

Remove import-time print statements from OpenWebUI engine#3
achimrabus merged 5 commits intogemini-3-adjustmentsfrom
copilot/sub-pr-2

Conversation

Copy link

Copilot AI commented Dec 3, 2025

The OpenWebUI engine was executing print statements at module import time, polluting stdout even when the engine wasn't used.

Changes:

  • Moved .env file loading from module level to _load_env_file() instance method
  • Moved dotenv import to module level with try-except (consistent with other optional dependencies)
  • Deferred execution until __init__() call

Before:

# At module level - executes on import
try:
    from dotenv import load_dotenv
    env_path = Path(__file__).parent.parent / ".env"
    if env_path.exists():
        load_dotenv(env_path)
        print(f"[OpenWebUIEngine] Loaded environment variables from {env_path}")
except ImportError:
    print("[OpenWebUIEngine] Warning: python-dotenv not installed...")

After:

# At module level - no side effects
try:
    from dotenv import load_dotenv
    DOTENV_AVAILABLE = True
except ImportError:
    DOTENV_AVAILABLE = False

# In __init__ - executes only on instantiation
def _load_env_file(self):
    """Load environment variables from project root's .env file."""
    if not DOTENV_AVAILABLE:
        return
    env_path = Path(__file__).parent.parent / ".env"
    if env_path.exists():
        load_dotenv(env_path)

Functionality unchanged - OPENWEBUI_API_KEY still loaded from .env when engine is instantiated.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 4 commits December 3, 2025 07:30
Co-authored-by: achimrabus <67736443+achimrabus@users.noreply.github.com>
Co-authored-by: achimrabus <67736443+achimrabus@users.noreply.github.com>
Co-authored-by: achimrabus <67736443+achimrabus@users.noreply.github.com>
Co-authored-by: achimrabus <67736443+achimrabus@users.noreply.github.com>
Copilot AI changed the title [WIP] Update Gemini 3 adjustments based on review comments Remove import-time print statements from OpenWebUI engine Dec 3, 2025
Copilot AI requested a review from achimrabus December 3, 2025 07:36
@achimrabus achimrabus marked this pull request as ready for review December 3, 2025 07:37
@achimrabus achimrabus merged commit e98f574 into gemini-3-adjustments Dec 3, 2025
@achimrabus achimrabus deleted the copilot/sub-pr-2 branch January 23, 2026 15:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants