| """ |
| Installation helper utilities for ARF Demo |
| """ |
| import subprocess |
| import sys |
| import logging |
| from typing import Dict, Any, List, Optional |
|
|
| logger = logging.getLogger(__name__) |
|
|
|
|
| class InstallationHelper: |
| """Helper class for ARF package installation""" |
| |
| @staticmethod |
| def install_arf_oss() -> Dict[str, Any]: |
| """Install ARF OSS package""" |
| try: |
| logger.info("Installing ARF OSS v3.3.7...") |
| result = subprocess.run( |
| [sys.executable, "-m", "pip", "install", "agentic-reliability-framework==3.3.7"], |
| capture_output=True, |
| text=True, |
| check=True |
| ) |
| |
| return { |
| "success": True, |
| "message": "β
ARF OSS v3.3.7 installed successfully", |
| "output": result.stdout |
| } |
| |
| except subprocess.CalledProcessError as e: |
| return { |
| "success": False, |
| "message": "β Failed to install ARF OSS", |
| "error": e.stderr |
| } |
| except Exception as e: |
| return { |
| "success": False, |
| "message": f"β Installation error: {str(e)}", |
| "error": str(e) |
| } |
| |
| @staticmethod |
| def check_installation() -> Dict[str, Any]: |
| """Check ARF package installation""" |
| try: |
| import agentic_reliability_framework as arf_oss |
| oss_version = getattr(arf_oss, '__version__', 'unknown') |
| oss_installed = True |
| except ImportError: |
| oss_installed = False |
| oss_version = None |
| |
| try: |
| import arf_enterprise |
| enterprise_version = getattr(arf_enterprise, '__version__', 'unknown') |
| enterprise_installed = True |
| except ImportError: |
| enterprise_installed = False |
| enterprise_version = None |
| |
| return { |
| "oss_installed": oss_installed, |
| "oss_version": oss_version, |
| "enterprise_installed": enterprise_installed, |
| "enterprise_version": enterprise_version, |
| "recommendations": InstallationHelper.get_recommendations(oss_installed, enterprise_installed) |
| } |
| |
| @staticmethod |
| def get_recommendations(oss_installed: bool, enterprise_installed: bool) -> List[str]: |
| """Get installation recommendations""" |
| recommendations = [] |
| |
| if not oss_installed: |
| recommendations.append( |
| "Install ARF OSS: `pip install agentic-reliability-framework==3.3.7`" |
| ) |
| |
| if not enterprise_installed: |
| recommendations.append( |
| "Install ARF Enterprise: `pip install agentic-reliability-enterprise` (requires license)" |
| ) |
| |
| return recommendations |
| |
| @staticmethod |
| def get_installation_html() -> str: |
| """Get HTML for installation status display""" |
| status = InstallationHelper.check_installation() |
| |
| if status["oss_installed"]: |
| oss_html = f""" |
| <div style="padding: 10px; background: #10b981; color: white; border-radius: 8px; margin: 5px 0;"> |
| β
ARF OSS v{status['oss_version']} installed |
| </div> |
| """ |
| else: |
| oss_html = """ |
| <div style="padding: 10px; background: #f59e0b; color: white; border-radius: 8px; margin: 5px 0;"> |
| β οΈ ARF OSS not installed |
| </div> |
| """ |
| |
| if status["enterprise_installed"]: |
| enterprise_html = f""" |
| <div style="padding: 10px; background: #8b5cf6; color: white; border-radius: 8px; margin: 5px 0;"> |
| π ARF Enterprise v{status['enterprise_version']} installed |
| </div> |
| """ |
| else: |
| enterprise_html = """ |
| <div style="padding: 10px; background: #64748b; color: white; border-radius: 8px; margin: 5px 0;"> |
| π ARF Enterprise not installed |
| </div> |
| """ |
| |
| recommendations_html = "" |
| if status["recommendations"]: |
| rec_list = "\n".join([f"<li>{rec}</li>" for rec in status["recommendations"]]) |
| recommendations_html = f""" |
| <div style="margin-top: 15px; padding: 10px; background: #f1f5f9; border-radius: 8px;"> |
| <strong>π‘ Recommendations:</strong> |
| <ul style="margin: 5px 0 0 0; padding-left: 20px;"> |
| {rec_list} |
| </ul> |
| </div> |
| """ |
| |
| return f""" |
| <div style="border: 1px solid #e2e8f0; border-radius: 12px; padding: 15px; background: white;"> |
| <h4 style="margin: 0 0 10px 0; color: #1e293b;">π¦ ARF Installation Status</h4> |
| {oss_html} |
| {enterprise_html} |
| {recommendations_html} |
| </div> |
| """ |
|
|
|
|
| |
| installation_helper = InstallationHelper() |