Commit ae57ebd5 authored by Lluis Gifre Renom's avatar Lluis Gifre Renom
Browse files

Tests - Tools - SIMAP AI Engine:

- Refactored component to remove word Analytics
- Added fixes to ensure component builds and starts properly
parent 14d73e5b
Loading
Loading
Loading
Loading
+6 −6
Original line number Diff line number Diff line
@@ -24,7 +24,7 @@ WORKDIR /app

# Copy common requirements and AI engine requirements
COPY common_requirements_py313.in /app/common_requirements.in
COPY src/tests/mwc26-f5ga/AI_analytics_engine/requirements.in /app/ai_requirements.in
COPY src/tests/tools/simap_ai_engine/ai_engine/requirements.in /app/ai_requirements.in

# Install Python dependencies
RUN pip install --no-cache-dir pip-tools && \
@@ -34,10 +34,10 @@ RUN pip install --no-cache-dir pip-tools && \
# Copy minimal TFS common module (required for Settings, etc.)
COPY src/common /app/src/common

# Copy AI Analytics Engine module
COPY src/tests/mwc26-f5ga/AI_analytics_engine /app/src/tests/mwc26-f5ga/AI_analytics_engine
# Copy AI Engine module
COPY src/tests/tools/simap_ai_engine/ai_engine /app/ai_engine

# Set PYTHONPATH to include src directory
# Set PYTHONPATH to include repo modules and the AI engine package
ENV PYTHONPATH=/app/src

# Expose default REST API port
@@ -52,5 +52,5 @@ ENV LOG_LEVEL=INFO
# Note: SIMAP_DATASTORE_ADDRESS, SIMAP_DATASTORE_PORT, SIMAP_DATASTORE_USERNAME,
# and SIMAP_DATASTORE_PASSWORD should be provided at runtime via --env flags

# Run the AI Analytics Engine
CMD ["python", "-m", "tests.mwc26-f5ga.AI_analytics_engine"]
# Run the AI Engine
CMD ["python", "-m", "ai_engine"]
+7 −7
Original line number Diff line number Diff line
@@ -13,7 +13,7 @@
# limitations under the License.

"""
AI Analytics Engine module.
AI Engine module.

Provides REST API for AI-driven SLA policy analysis and violation detection
using data from SIMAP (network topology/devices) and InfluxDB (telemetry metrics).
@@ -26,29 +26,29 @@ Module Structure:
    - tests: Test suite

Public API:
    - AIAnalyticsEngineAPI: Main orchestrator and Flask application
    - AIEngineAPI: Main orchestrator and Flask application
    - AIModelProcessor: AI/ML analysis engine
    - SLAPolicyConfig: SLA policy configuration data model
    - SimapDataFetcher: SIMAP client for device/topology data
    - InfluxDBFetcher: InfluxDB client for telemetry metrics
    - DecisionEngineClient: Decision engine notification client
    - create_ai_analytics_blueprint: Flask blueprint factory
    - create_ai_engine_blueprint: Flask blueprint factory
"""

from .ai_model.ai_processor import AIModelProcessor
from .api.api_blueprint import create_ai_analytics_blueprint
from .engine import AIAnalyticsEngineAPI
from .api.api_blueprint import create_ai_engine_blueprint
from .engine import AIEngineAPI
from .clients.decision_client import DecisionEngineClient
from .clients.influxdb_fetcher import InfluxDBFetcher
from .clients.simap_fetcher import SimapDataFetcher
from .ai_model.sla_policy import SLAPolicyConfig

__all__ = [
    'AIAnalyticsEngineAPI',
    'AIEngineAPI',
    'AIModelProcessor',
    'DecisionEngineClient',
    'InfluxDBFetcher',
    'SimapDataFetcher',
    'SLAPolicyConfig',
    'create_ai_analytics_blueprint',
    'create_ai_engine_blueprint',
]
+8 −8
Original line number Diff line number Diff line
@@ -13,9 +13,9 @@
# limitations under the License.

"""
AI Analytics Engine main entry point.
AI Engine main entry point.

This module provides the entry point for running the AI Analytics Engine REST API.
This module provides the entry point for running the AI Engine REST API.
"""

# Standard library imports
@@ -23,14 +23,14 @@ import logging
import sys

# Local imports
from .engine import AIAnalyticsEngineAPI
from .engine import AIEngineAPI

# Module-level logger
LOGGER = logging.getLogger(__name__)


def main() -> None:
    """Main entry point for the AI Analytics Engine."""
    """Main entry point for the AI Engine."""
    # Configure logging
    logging.basicConfig(
        level=logging.DEBUG,
@@ -39,17 +39,17 @@ def main() -> None:
    logging.getLogger('werkzeug').setLevel(logging.DEBUG)

    try:
        LOGGER.info("Starting AI Analytics Engine")
        engine = AIAnalyticsEngineAPI()
        LOGGER.info("Starting AI Engine")
        engine = AIEngineAPI()

        logging.getLogger('werkzeug').setLevel(logging.DEBUG)

        engine.run()
    except KeyboardInterrupt:
        LOGGER.info("AI Analytics Engine stopped by user")
        LOGGER.info("AI Engine stopped by user")
        sys.exit(0)
    except Exception as e:
        LOGGER.exception(f"AI Analytics Engine failed to start: {e}")
        LOGGER.exception(f"AI Engine failed to start: {e}")
        sys.exit(1)


+7 −7
Original line number Diff line number Diff line
@@ -13,9 +13,9 @@
# limitations under the License.

"""
Flask Blueprint for AI Analytics Engine REST API.
Flask Blueprint for AI Engine REST API.

Defines the REST API endpoints for the AI Analytics Engine.
Defines the REST API endpoints for the AI Engine.
"""

import logging
@@ -34,17 +34,17 @@ from ..ai_model.sla_policy import SLAPolicyConfig
LOGGER = logging.getLogger(__name__)


def create_ai_analytics_blueprint(
def create_ai_engine_blueprint(
    simap_fetcher: SimapDataFetcher,
    influxdb_fetcher: InfluxDBFetcher,
    ai_processor: AIModelProcessor,
    decision_client: DecisionEngineClient
) -> Blueprint:
    """
    Create the Flask Blueprint for the AI Analytics Engine REST API.
    Create the Flask Blueprint for the AI Engine REST API.

    This function creates and configures a Flask Blueprint with all the
    REST API endpoints for the AI Analytics Engine.
    REST API endpoints for the AI Engine.

    Args:
        simap_fetcher: Initialized SimapDataFetcher instance.
@@ -58,7 +58,7 @@ def create_ai_analytics_blueprint(
            - GET /api/v1/health: Health check endpoint
            - GET /api/v1/config: Get current configuration
    """
    blueprint = Blueprint('ai_analytics', __name__, url_prefix='/api/v1')
    blueprint = Blueprint('ai_engine', __name__, url_prefix='/api/v1')

    @blueprint.route('/analyze', methods=['POST'])
    def analyze():
@@ -169,7 +169,7 @@ def create_ai_analytics_blueprint(
        LOGGER.debug("Health check requested")
        return jsonify({
            'status': 'healthy',
            'service': 'AI Analytics Engine',
            'service': 'AI Engine',
            'timestamp': datetime.now(UTC).isoformat()
        }), 200

+1 −1
Original line number Diff line number Diff line
@@ -13,7 +13,7 @@
# limitations under the License.

"""
Configuration module for the AI Analytics Engine.
Configuration module for the AI Engine.

This module defines environment variables for SIMAP server, InfluxDB,
and REST API configuration using the TFS get_setting pattern.
Loading