Skip to content

feat(analytics): Integrate ONNX Runtime and TensorFlow Serving (Issue #1476) - #2760

Merged
makr-code merged 4 commits into
developfrom
copilot/integrate-onnx-tensorflow-serving
Feb 24, 2026
Merged

makr-code merged 4 commits into
developfrom
copilot/integrate-onnx-tensorflow-serving

Conversation

Copilot AI commented Feb 24, 2026 •

Copy link
Copy Markdown
Contributor

Adds a production-ready ML serving abstraction to the analytics module, wiring two external inference backends — ONNX Runtime (in-process) and TensorFlow Serving (REST) — behind a single thread-safe MLServingClient API.

New files

  • include/analytics/ml_serving.h — Public API: MLTensor, MLServingRequest/Response, IMLServingBackend extension interface, ONNXServingBackend, TFServingBackend, MLServingClient
  • src/analytics/ml_serving.cpp — Implementation; graceful UNAVAILABLE degradation when backends are absent at compile time
  • tests/analytics/test_ml_serving.cpp — 36 tests; all pass regardless of which backends are compiled in

Build system

  • cmake/Dependencies.cmake — find_package(onnxruntime) → auto-sets THEMIS_HAS_ONNX=1; new THEMIS_ENABLE_TF_SERVING option for TF Serving REST backend
  • cmake/ModularBuild.cmake — ml_serving.cpp added to THEMIS_QUERY_SOURCES; conditional onnxruntime::onnxruntime dep on query module
  • cmake/CMakeLists.txt — ml_serving.cpp added to THEMIS_CORE_SOURCES; conditional target_link_libraries for onnxruntime

Key design points

  • MLBackendType::AUTO prefers ONNX Runtime, falls back to TF Serving
  • inferFromDataPoint() bridges directly to the existing DataPoint type: numeric fields sorted alphabetically → {1, N} float32 input tensor
  • TF Serving transport: libcurl POST to /v1/models/<name>:predict, optional bearer auth, configurable timeout
  • ONNX backend: lazy session loading from <model_directory>/<name>.onnx, optional CUDA EP
MLServingClient client;                              // AUTO: ONNX preferred

MLServingRequest req;
req.model_name = "fraud_detector";
req.inputs.push_back({"input", {1, 30}, features});
auto resp = client.infer(req);                       // resp.ok() → outputs[0].data

// Or use DataPoint directly
auto resp2 = client.inferFromDataPoint("fraud_detector", data_point);

Type of Change

  • Bug fix
  • New feature
  • Refactoring
  • Documentation
  • Other:

Testing

  • Unit tests added/updated
  • Integration tests added/updated
  • Manual testing performed

📚 Research & Knowledge (wenn applicable)

  • Diese PR basiert auf wissenschaftlichen Paper(s) oder Best Practices?
    • Falls JA: Research-Dateien in /docs/research/ angelegt?
    • Falls JA: Im Modul-README unter "Wissenschaftliche Grundlagen" verlinkt?
    • Falls JA: In /docs/research/implementation_influence/ eingetragen?

Relevante Quellen:

  • Paper:
  • Best Practice:
  • Architecture Decision:

Checklist

  • Code follows project style guidelines
  • Self-review completed
  • Documentation updated (if needed)
  • No new warnings introduced
Original prompt

This section details on the original issue you should resolve

<issue_title>[analytics] Integrate ONNX Runtime and TensorFlow Serving</issue_title>
<issue_description># [analytics] Integrate ONNX Runtime and TensorFlow Serving

Summary

  • Module: analytics
  • Item: Integration with external ML tools (ONNX Runtime, TensorFlow Serving)

Implementation Context

  • Roadmap section: Long-term (6-12 months)
  • Enhancement hint: # Analytics Module Implementation - Future Enhancements
  • Enhancement hint: This document outlines implementation-specific future enhancements for the Analytics module. For API-level enhancements, see [`../../include/analytics/FUTURE...
  • Enhancement hint: Line 14: Open Issues: TODOs: 0, Stubs: 1

Implementation Phases

Phase 1: Core Analytics Engine (Status: Completed )

  • OLAP engine with GROUP BY, CUBE, ROLLUP, and GROUPING SETS (analytics/olap_engine.cpp)
  • Window functions: ROW_NUMBER, SUM OVER, AVG OVER with frame specifications
  • Statistical aggregations (COUNT, SUM, AVG, MIN, MAX, STDDEV, VARIANCE, MEDIAN, PERCENTILE)
  • Hash-based aggregation with result caching
  • Columnar Arrow RecordBatch storage always available
  • JSON, CSV, Parquet, and Feather export (analytics/exporters/)
    Phase 2: Streaming & Incremental Analytics (Status: In Progress )
  • CEP full engine implementation in analytics/cep_engine.cpp (Target: Q2 2026)
  • Streaming aggregation windows (tumbling/sliding/session/hopping) in analytics/streaming_window.cpp (Target: Q2 2026)
  • Incremental materialized views (Target: Q3 2026)
    Phase 3: Distributed & ML-Augmented Analytics (Status: Planned )
  • Columnar execution engine with vectorized operator pipeline
  • LLVM-JIT compilation for hot aggregation paths
  • Distributed analytics sharding across cluster nodes
  • Predictive analytics and time-series forecasting integration
  • AutoML integration for automated model selection

Related Work

  • No direct overlap identified in pre-check.
  • Relationship is for coordination only; do not expand this issue scope.

Scope Boundary

  • In scope: implement only this roadmap item: "Integration with external ML tools (ONNX Runtime, TensorFlow Serving)"
  • Out of scope: any other roadmap checklist item, even from the same module/section
  • Related issues/PRs are references only; implementation remains isolated to this issue
  • If additional work is required, open/link a follow-up issue instead of extending this issue

Mandatory Delivery Workflow (ThemisDB Rules)

  • Phase 0: Existing code review before implementation
    • Identify existing files/symbols/interfaces and document reuse plan
    • Verify no duplicate implementation of existing functionality
    • Record affected files and integration points before coding
  • Scope gate (must pass before coding)
    • Confirm implementation target is only the single issue description
    • Confirm no additional roadmap items are implemented in this issue/PR
    • Any newly discovered work is split into separate linked issue(s)
  • Design and implementation rules reviewed from:
    • docs/analysis/IMPLEMENTATION_GUIDE.md
    • docs/analysis/GPU_ACCELERATION_ADDENDUM.md
    • docs/architecture/MODULAR_ARCHITECTURE_ROADMAP.md
    • docs/architecture/THEMIS_CORE_GUIDE.md
    • docs\de\analytics\olap_guide.md
    • docs\de\analytics\process_mining_guide.md
  • Architecture and compatibility validation
    • Confirm behavior compatibility with existing APIs unless breaking change is explicitly declared
    • Confirm telemetry/logging/metrics integration follows existing module patterns
  • Code review gate before completion
    • Self-review against roadmap acceptance criteria
    • Cross-check for overlap/duplication with existing implementations
  • Validation gate
    • Unit + integration tests updated/added
    • Performance impact measured against baseline

Implementation Tasks

  • OLAP engine with GROUP BY, CUBE, ROLLUP, and GROUPING SETS (analytics/olap_engine.cpp)
  • Window functions: ROW_NUMBER, SUM OVER, AVG OVER with frame specifications
  • Statistical aggregations (COUNT, SUM, AVG, MIN, MAX, STDDEV, VARIANCE, MEDIAN, PERCENTILE)
  • Hash-based aggregation with result caching
  • Columnar Arrow RecordBatch storage always available
  • JSON, CSV, Parquet, and Feather export (analytics/exporters/)
  • CEP full engine implementation in analytics/cep_engine.cpp (Target: Q2 2026)
  • Streaming aggregation windows (tumbling/sliding/session/hopping) in analytics/streaming_window.cpp (Target: Q2 2026)
  • Incremental materialized views (Target: Q3 2026)
  • Columnar execution engine with vectorized operator pipeline
  • LLVM-JIT compilation for hot aggregation paths
  • Distributed analytics sharding across cluster nodes
  • Predictive analytics and time-series forecasting integration
  • AutoML integration for automated model selection

Acceptance Criteria

  • Unit tests (OLAP, Arrow exp...

🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

Copilot AI and others added 2 commits February 24, 2026 09:36
…1476)

Add ml_serving.h / ml_serving.cpp implementing a unified MLServingClient
abstraction that wraps both ONNX Runtime (THEMIS_HAS_ONNX) and TensorFlow
Serving REST (THEMIS_HAS_TF_SERVING + THEMIS_HAS_CURL) backends.

Key changes:
- include/analytics/ml_serving.h: MLTensor, MLServingRequest/Response,
  IMLServingBackend, ONNXServingBackend, TFServingBackend, MLServingClient
- src/analytics/ml_serving.cpp: production implementation with graceful
  degradation when backends are absent at compile time
- cmake/Dependencies.cmake: ONNX Runtime auto-detection via find_package,
  THEMIS_ENABLE_TF_SERVING option
- tests/analytics/test_ml_serving.cpp: 30 unit tests covering both the
  available and unavailable code paths
- src/analytics/ROADMAP.md: mark Issue #1476 resolved
- src/analytics/README.md: document component #14 (ML Serving Integration)

Co-authored-by: makr-code <[email protected]>
Copilot AI changed the title [WIP] Integrate ONNX Runtime and TensorFlow Serving in analytics module feat(analytics): Integrate ONNX Runtime and TensorFlow Serving (Issue #1476) Feb 24, 2026
Copilot AI requested a review from makr-code February 24, 2026 09:40
…runtime

Code audit found that ml_serving.cpp was not wired into either build
system configuration:

- cmake/ModularBuild.cmake: add ml_serving.cpp to THEMIS_QUERY_SOURCES
  and add conditional onnxruntime::onnxruntime to query module deps
- cmake/CMakeLists.txt: add ml_serving.cpp to THEMIS_CORE_SOURCES and
  add conditional target_link_libraries for onnxruntime::onnxruntime
- tests/analytics/test_ml_serving.cpp: remove unused-variable warning
  by inlining the isBackendAvailable() call directly into EXPECT macros

Co-authored-by: makr-code <[email protected]>
@makr-code
makr-code marked this pull request as ready for review February 24, 2026 10:25
@makr-code
makr-code merged commit 09f0089 into develop Feb 24, 2026
13 of 14 checks passed
@github-actions github-actions Bot added the type:test Test-only change label Feb 24, 2026
@makr-code makr-code modified the milestones: v1.3.1, v1.2.0 Mar 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type:test Test-only change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[analytics] Integrate ONNX Runtime and TensorFlow Serving

2 participants