Consolidate on ALWRITY_ENABLED_FEATURES - remove all legacy support
Backend: - Remove all legacy env var fallbacks (ALWRITY_FEATURE_PROFILE, ALWRITY_ROUTER_PROFILE, etc) - Remove get_active_profile() from start_alwrity_backend.py - Remove _env_flag_enabled() from app.py - Use ALWRITY_ENABLED_FEATURES as single source of truth Frontend: - demoMode.ts now uses only REACT_APP_ENABLED_FEATURES - Removed all legacy fallback keys (app_mode, demo_mode, podcast_only_demo_mode) Usage: ALWRITY_ENABLED_FEATURES=podcast # Podcast only ALWRITY_ENABLED_FEATURES=all # All features (default)
This commit is contained in:
@@ -9,10 +9,8 @@ from typing import Iterable, Tuple
|
||||
from .feature_registry import FEATURE_GROUPS, PROFILE_GROUP_MAP
|
||||
|
||||
|
||||
# Consolidated env var - supports both old and new format
|
||||
ENV_FEATURE_PROFILE = "ALWRITY_ENABLED_FEATURES"
|
||||
ENV_FEATURE_PROFILE_LEGACY = "ALWRITY_FEATURE_TO_ENABLE"
|
||||
DEFAULT_PROFILE = "all"
|
||||
ENV_ENABLED_FEATURES = "ALWRITY_ENABLED_FEATURES"
|
||||
DEFAULT_FEATURES = "all"
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
@@ -24,31 +22,31 @@ class ExpandedFeatureProfile:
|
||||
|
||||
|
||||
class UnknownFeatureProfileError(ValueError):
|
||||
"""Raised when ALWRITY_ENABLED_FEATURES contains unknown profile values."""
|
||||
"""Raised when ALWRITY_ENABLED_FEATURES contains unknown feature values."""
|
||||
|
||||
|
||||
def _get_env_value() -> str:
|
||||
"""Get the feature profile value from environment - new var takes precedence."""
|
||||
return os.getenv(ENV_FEATURE_PROFILE) or os.getenv(ENV_FEATURE_PROFILE_LEGACY) or DEFAULT_PROFILE
|
||||
"""Get the enabled features value from environment."""
|
||||
return os.getenv(ENV_ENABLED_FEATURES) or DEFAULT_FEATURES
|
||||
|
||||
|
||||
def _normalize_values(raw_value: str | None) -> Tuple[str, ...]:
|
||||
if not raw_value or not raw_value.strip():
|
||||
return (DEFAULT_PROFILE,)
|
||||
return (DEFAULT_FEATURES,)
|
||||
|
||||
normalized = tuple(
|
||||
value.strip().lower()
|
||||
for value in raw_value.split(",")
|
||||
if value.strip()
|
||||
)
|
||||
return normalized or (DEFAULT_PROFILE,)
|
||||
return normalized or (DEFAULT_FEATURES,)
|
||||
|
||||
|
||||
def parse_feature_profiles(raw_value: str | None = None) -> Tuple[str, ...]:
|
||||
"""Parse and validate profile names from env/raw input.
|
||||
"""Parse and validate feature names from env/raw input.
|
||||
|
||||
Supports comma-separated profile names, e.g. `core,podcast`.
|
||||
Raises UnknownFeatureProfileError when any profile is not registered.
|
||||
Supports comma-separated feature names, e.g. `podcast,core`.
|
||||
Raises UnknownFeatureProfileError when any feature is not registered.
|
||||
"""
|
||||
|
||||
selected_profiles = _normalize_values(raw_value if raw_value is not None else _get_env_value())
|
||||
@@ -58,7 +56,7 @@ def parse_feature_profiles(raw_value: str | None = None) -> Tuple[str, ...]:
|
||||
supported = ", ".join(sorted(set(PROFILE_GROUP_MAP.keys()) | set(FEATURE_GROUPS.keys())))
|
||||
unknown_display = ", ".join(unknown)
|
||||
raise UnknownFeatureProfileError(
|
||||
f"Unknown {ENV_FEATURE_PROFILE} value(s): {unknown_display}. Supported profiles: {supported}."
|
||||
f"Unknown {ENV_ENABLED_FEATURES} value(s): {unknown_display}. Supported: {supported}."
|
||||
)
|
||||
|
||||
return selected_profiles
|
||||
|
||||
@@ -89,8 +89,6 @@ class RouterManager:
|
||||
- "all" - enable all features (default)
|
||||
- comma-separated: "podcast,blog-writer,youtube"
|
||||
- single feature: "podcast"
|
||||
|
||||
DEPRECATED: ALWRITY_FEATURE_PROFILE, ALWRITY_ROUTER_PROFILE, ALWRITY_FEATURE_TO_ENABLE
|
||||
"""
|
||||
env_value = os.getenv("ALWRITY_ENABLED_FEATURES", "all").strip().lower()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user