Skip to content

Integrate KPI calculation into simulator-worker#63

Open
jarsarasty wants to merge 1 commit intomainfrom
feature/kpi-calculator-integration
Open

Integrate KPI calculation into simulator-worker#63
jarsarasty wants to merge 1 commit intomainfrom
feature/kpi-calculator-integration

Conversation

@jarsarasty
Copy link

@jarsarasty jarsarasty commented Oct 16, 2025

This PR integrates the KPI calculator functionality into the simulator-worker using the published PyPI package.

Changes

Dependencies

  • Added kpi-calculator>=0.2.0 from PyPI to pyproject.toml
  • Updated requirements.txt with kpi-calculator 0.2.0

KPI Integration

  • Integrated KPI calculation into the simulation workflow in simulator_worker.py
  • Uses load_from_esdl_string() method (new in v0.2.0) to load ESDL directly from string content without temp files
  • Added utility functions in utils.py for converting simulator output format to KPI calculator format
  • KPI calculation runs after simulation completes and adds KPI results to the output ESDL
  • Graceful error handling: simulation continues and returns results even if KPI calculation fails

Testing

  • Added test_kpi_integration.py with integration tests. End-to-end integration test (requires InfluxDB, skipped in CI)
  • Unit tests for convert_simulator_to_kpi_format utility function

@jarsarasty jarsarasty marked this pull request as draft October 16, 2025 08:51
@jarsarasty jarsarasty marked this pull request as ready for review October 16, 2025 11:25
@jarsarasty jarsarasty force-pushed the feature/kpi-calculator-integration branch 3 times, most recently from a713153 to 685a0eb Compare January 8, 2026 12:41
@jarsarasty jarsarasty marked this pull request as draft January 9, 2026 09:16
@jarsarasty jarsarasty force-pushed the feature/kpi-calculator-integration branch 9 times, most recently from 5617f0c to 2122d49 Compare January 15, 2026 10:57
@jarsarasty jarsarasty requested a review from Copilot January 15, 2026 10:59
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR integrates KPI calculation functionality into the simulator-worker by adding the kpi-calculator package from PyPI. The integration adds KPI computation to the simulation workflow while maintaining graceful error handling to ensure simulations can complete even if KPI calculation fails.

Changes:

  • Added kpi-calculator>=0.1.1 dependency and updated urllib3 to 2.6.3
  • Integrated KPI calculation into simulator_worker.py after simulation completion
  • Added convert_simulator_to_kpi_format utility function to transform simulator output format to KPI calculator format
  • Added comprehensive integration tests for KPI functionality

Reviewed changes

Copilot reviewed 5 out of 6 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
pyproject.toml Added kpi-calculator dependency and updated pytest configuration to include new test file
dev-requirements.txt Updated urllib3 dependency version
src/simulator_worker/simulator_worker.py Integrated KPI calculation workflow with error handling
src/simulator_worker/utils.py Added utility function to convert simulator DataFrame format to KPI calculator format
unit_test/test_kpi_integration.py Added comprehensive integration tests for KPI functionality

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@jarsarasty jarsarasty force-pushed the feature/kpi-calculator-integration branch from 2122d49 to 7ae989c Compare January 15, 2026 14:56
@jarsarasty jarsarasty marked this pull request as ready for review January 15, 2026 15:01
@jarsarasty jarsarasty marked this pull request as draft January 15, 2026 16:02
@jarsarasty jarsarasty marked this pull request as ready for review January 29, 2026 15:49
After create_output_esdl() writes InfluxDB profile references, call
KpiManager.load_from_simulator() on the output ESDL so that profiles
and KPIs coexist in the final result. System lifetime is read from
workflow_config with a safe float() fallback.

KpiValidationError is caught as a warning (simulation still returned
without KPIs); unexpected failures are logged at ERROR with full traceback.

Bump kpi-calculator dependency to >=0.3.0 / ==0.3.0 in requirements.txt.
Add end-to-end integration test gated on INFLUXDB_HOSTNAME.
Remove no-op test__hello_world cookiecutter artifact.
@jarsarasty jarsarasty force-pushed the feature/kpi-calculator-integration branch from 969737b to 5ee1199 Compare February 25, 2026 16:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants