Add feature-profile endpoint and env-driven optional router profiles
- Add ALWRITY_FEATURE_PROFILE env var (precedence over ALWRITY_ROUTER_PROFILE) - Add OPTIONAL_MODULE_MATRIX defining 'all' and 'default' profiles - Add get_feature_profile_status() to RouterManager - Add GET /api/feature-profile/status endpoint in main.py and app.py - Returns active profile and enabled optional modules
This commit is contained in:
@@ -66,6 +66,11 @@ OPTIONAL_ROUTER_REGISTRY = [
|
||||
{"name": "today_workflow", "module": "api.today_workflow", "attr": "router", "profiles": {"all", "default"}},
|
||||
]
|
||||
|
||||
OPTIONAL_MODULE_MATRIX = {
|
||||
"all": [entry["name"] for entry in OPTIONAL_ROUTER_REGISTRY],
|
||||
"default": [entry["name"] for entry in OPTIONAL_ROUTER_REGISTRY],
|
||||
}
|
||||
|
||||
|
||||
class RouterManager:
|
||||
"""Manages FastAPI router inclusion and organization."""
|
||||
@@ -79,7 +84,7 @@ class RouterManager:
|
||||
return os.getenv("ALWRITY_VERBOSE", "false").lower() == "true"
|
||||
|
||||
def _get_profile(self) -> str:
|
||||
return os.getenv("ALWRITY_ROUTER_PROFILE", os.getenv("ALWRITY_FEATURE_TO_ENABLE", "all")).strip().lower() or "all"
|
||||
return os.getenv("ALWRITY_FEATURE_PROFILE", os.getenv("ALWRITY_ROUTER_PROFILE", os.getenv("ALWRITY_FEATURE_TO_ENABLE", "all"))).strip().lower() or "all"
|
||||
|
||||
def _should_include_router(self, registry_entry: Dict[str, Any], profile: str) -> bool:
|
||||
profiles = registry_entry.get("profiles", {"all", "default"})
|
||||
@@ -154,3 +159,14 @@ class RouterManager:
|
||||
"total_included": len(self.included_routers),
|
||||
"total_failed": len(self.failed_routers)
|
||||
}
|
||||
|
||||
def get_feature_profile_status(self) -> Dict[str, Any]:
|
||||
"""Get feature profile status and enabled modules."""
|
||||
profile = self._get_profile()
|
||||
enabled_modules = OPTIONAL_MODULE_MATRIX.get(profile, OPTIONAL_MODULE_MATRIX.get("all", []))
|
||||
|
||||
return {
|
||||
"active_profile": profile,
|
||||
"enabled_modules": enabled_modules,
|
||||
"available_profiles": list(OPTIONAL_MODULE_MATRIX.keys())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user