Commit Graph

490 Commits

Author SHA1 Message Date
PedroHMCosme
4e3b5756be feat(simple_metrics): thread thresholds config from model_config to activity
Reads optional simple_metrics_thresholds from model_config and passes
to calculate_simple_metrics. Threshold schema: {rmse_max, r2_min, ...}.
None when not configured (no alerting, no crash).

Updates workflow tests to expect the new key in the activity-call dict.

SIENTIAPDE-1986

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-08-19 11:25:49 -03:00
PedroHMCosme
666188a7b3 test(simple_metrics): rewrite tests against RegressionMetrics dispatch
Rewrites 8 existing tests to mock RegressionMetrics instead of verifying
manual numpy math. Adds 2 new tests:
- r2 excluded + warning when model_type is non-linear
- r2 included when model_type is absent (backward compat)

Replaces silent-discard test with ValueError propagation test.

SIENTIAPDE-1986
2026-08-19 11:17:59 -03:00
PedroHMCosme
b7fdcebc15 feat(simple_metrics): rewrite calculate_simple_metrics to use RegressionMetrics
Replaces manual numpy if/elif chain with RegressionMetrics from
sientia_model. Fixes 3 known bugs in one pass:
- NaN now handled via _align_dropna (was silently propagated)
- r2 zero-variance uses sklearn r2_score (was divergent, pinned at 0.0)
- Unknown metric names raise ValueError (were silently dropped)

Also adds r2 lock: when model_type is known and non-linear,
r2 is excluded from calculation with a WARNING notification.

Drops the now-unused `numpy` import (the manual math it backed is gone,
and no other method in this file references it).

SIENTIAPDE-1986
2026-08-19 11:13:08 -03:00
PedroHMCosme
33b4ae8406 feat(simple_metrics): thread model_type from model_config to activity
Extracts model_type from model_config (optional, defaults to None when
absent) and passes it to calculate_simple_metrics. Required for the r2
lock - is_r2_supported() needs model_type to decide whether to compute r2.

Updates workflow tests to expect the new key in the activity-call dict.
2026-08-19 11:08:07 -03:00
PedroHMCosme
3b55072ab4 chore(deps): bump sientia_model>=0.12.0, local pin to 0.13.1
RegressionMetrics class (needed for SIENTIAPDE-1986) was introduced in
sientia-model-library 0.12.0. The previous local pin (@0.10.0) predates
the class.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-08-19 10:57:42 -03:00
vitor-aignosi
272e02dadc SIENTIAPDE-1646
SIENTIAPDE-1646 Refactor MLFlow tests and update artifact handling

- Enhanced test cases for MLFlow to improve clarity and accuracy in data handling.
- Updated references in tests to use 'evaluation_data.csv' and 'test_data.csv' instead of 'retrain_input.csv' and 'train_data.csv'.
- Introduced a new helper function for creating prediction frames to streamline test setup.
2026-06-11 13:34:25 -03:00
vitor-aignosi
19c8a028d2 SIENTIAPDE-1646
SIENTIAPDE-1646 Update prediction data handling in MLFlow

- Renamed the prediction column in the MLFlow retraining process to improve clarity and consistency in the output data.
2026-06-11 10:02:11 -03:00
vitor-aignosi
11691398da SIENTIAPDE-1646
Update worker.py to set runtime parameter to 'core' for worker preparation
2026-06-11 08:58:09 -03:00
vitor-aignosi
054dcbfa50 SIENTIAPDE-1646
SIENTIAPDE-1646 Enhance MLFlow retraining process and evaluation data handling

- Updated the MLFlow class to merge prediction data with retrain data for improved evaluation.
- Renamed target column to "target" and added a timestamp column to the evaluation data.
- Logged both retrain input and evaluation data as artifacts in MLFlow.
2026-06-11 08:51:17 -03:00
vitor-aignosi
e393263ddf SIENTIAPDE-1646
Update MLFlow reference artifact candidates to include 'evaluation_data.csv' instead of 'retrain_input.csv'
2026-06-11 08:18:42 -03:00
vitor-aignosi
11224537d3 SIENTIAPDE-1646
Update MLFlow reference artifact candidates to include 'test_data.csv' instead of 'train_data.csv'
2026-06-11 08:03:30 -03:00
vitor-aignosi
26502b5274 SIENTIAPDE-1646
Enhance MLFlow reference data handling and testing

- Updated the artifact handling in MLFlow to prioritize 'retrain_input.csv' over 'train_data.csv' when resolving reference data.
- Introduced new methods for resolving artifact names and locating downloaded CSV files.
- Modified the `get_reference_data` method to improve artifact resolution and error handling.
- Expanded unit tests to cover scenarios for missing artifacts and preference logic between retrain and train data CSVs.
2026-06-10 16:50:07 -03:00
vitor-aignosi
ad4da333a0 SIENTIAPDE-1646
Update values.yaml to add MLFLOW environment variables

- Added MLFLOW_HOST and MLFLOW_PORT environment variables to values.yaml for tracking configuration.
2026-05-25 16:35:41 -03:00
vitor-aignosi
a4594997e8 SIENTIAPDE-1646
Update values.yaml and connectors_config.py for runtime and environment variable changes

- Renamed the runtime entry from "single" to "legacy" in values.yaml for clarity.
- Updated the helm upgrade command comment in values.yaml to reflect the correct path for deployment.
- Changed the environment variable name from "MLFLOW_HOST" and "MLFLOW_PORT" to "MLFLOW_URL" in connectors_config.py for consistency.
2026-05-25 16:07:10 -03:00
vitor-aignosi
e53e792e79 SIENTIAPDE-1646
Update values.yaml and worker.py for runtime installation logic

- Updated helm upgrade command version in values.yaml from 0.6.1 to 0.6.5 for deployment reference.
- Modified worker.py to adjust runtime installation logic, ensuring 'legacy' runtime is set to 'single' for compatibility.
2026-05-25 14:39:19 -03:00
vitor-aignosi
6c4095825d SIENTIAPDE-1646
Update values.yaml to change runtime configurations and GitHub branch

- Renamed runtime entries from list format to key-value pairs for "basic" and "single".
- Updated the GITHUB_BRANCH environment variable from "feature/SIENTIAPDE-1646-legacy-laborious-worker" to "main".
- Added a helm upgrade command comment for deployment reference.
2026-05-22 16:22:15 -03:00
vitor-aignosi
7a776066ec SIENTIAPDE-1646
Update requirements and enhance OPC communication handling

- Updated `requirements-local.txt` to use the latest versions of `sientia-dataops-library` (1.12.1) and `sientia-model-library` (0.10.0).
- Improved documentation in `opc-communication.md` to clarify the transition from async to sync implementation and added details on error classification and reconnection behavior.
- Refactored `init_opc` method in `opc.py` to enhance connection handling and logging, ensuring independent server initialization.
- Enhanced validation and writing methods in `opc.py` to provide better feedback and error handling for OPC server operations.
- Updated `opc_repository.py` to improve error payload construction and session management metrics.
2026-05-19 16:43:20 -03:00
vitor-aignosi
c919713075 SIENTIAPDE-1646
SIENTIAPDE-1646 Enhance OPC integration and E2E testing framework

- Updated .gitignore to exclude '.cursor/*' for better file management.
- Added new marker in pyproject.toml for E2E tests using OPC.
- Introduced async OPC server fixtures and improved connection handling in conftest.py.
- Enhanced error handling in OPC activities and added metrics for session management in metrics.py.
- Updated E2E tests to cover new OPC scenarios, including session errors and reconnect handling.
- Refactored helper functions to improve prediction assertion logic in helpers.py.
- Documented new OPC scenarios in scenarios.md for clarity on expected outcomes.
2026-05-19 14:45:23 -03:00
vitor-aignosi
ee9c71cbbb SIENTIAPDE-1646
Refactor ModelMetrics to utilize DriftAnalysis for drift detection

- Replaced ModelAnalysis with DriftAnalysis in the ModelMetrics class to enhance drift detection capabilities.
- Updated method signatures and documentation to reflect the changes in target_name and return values.
- Adjusted data handling to ensure compatibility with the new analysis methods and improved clarity in the drift metrics dataframe preparation.
2026-05-19 14:45:23 -03:00
vitor-aignosi
c9ac25ea80 SIENTIAPDE-1646
Update README, requirements, and E2E tests for improved configuration and functionality

- Enhanced the README with updated model configuration examples, including the addition of an alias for production.
- Removed the `requirements-light.txt` file and updated `requirements-local.txt` and `requirements.txt` to replace `asyncua` with `opcua`.
- Refactored E2E test scenarios to utilize scenario input files for better maintainability and clarity.
- Improved test coverage for MinIO offload functionality and added new helper functions for loading scenario inputs.
- Updated `values.yaml` to reflect new global configurations and environment variables for the laborious worker.
2026-05-19 14:45:22 -03:00
vitor-aignosi
0c9bea54c0 SIENTIAPDE-1811
Update .gitignore, requirements, and enhance OPC UA error handling

- Added new entries to .gitignore for openspec and cursor directories.
- Updated sientia-dataops-library dependency version in requirements-light.txt from 1.10.4 to 1.12.0.
- Enhanced OPC UA communication by refining reconnect logic and error handling in opc_repository.py, including the introduction of a reconnect flag and improved session management.
- Updated tests to cover new reconnect scenarios and ensure robust error handling for protocol states.
2026-05-19 14:45:21 -03:00
vitor-aignosi
c2e2a8ff7a SIENTIAPDE-1811
Update values.yaml to rename worker references and adjust GitHub branch for SIENTIAPDE-1811. Changed nameOverride, fullnameOverride, and service account name to "sientia-laborious-legacy-worker" and updated the GITHUB_BRANCH value to "fix/SIENTIAPDE-1811".
2026-05-19 14:45:20 -03:00
vitor-aignosi
7bf7848a93 SIENTIAPDE-1811
Enhance OPC UA communication and metrics tracking

- Updated README.md to include new OPC UA Communication section and detailed metrics for session and write diagnostics.
- Added new metrics in laborious/metrics.py for tracking OPC UA session states and write attempts.
- Refactored OPC activity in laborious/activities/opc.py to handle session errors and improve error reporting.
- Updated e2e tests to cover new scenarios for OPC session/channel errors and reconnect handling.
- Modified .gitignore to include relatorio files and mlruns directory.
- Added ipykernel to requirements-dev.txt for Jupyter notebook support.
2026-05-19 14:45:20 -03:00
vitor-aignosi
4edf70c4a0 SIENTIAPDE-1646
SIENTIAPDE-1646 Add new runtime configuration for single environment in values.yaml

- Introduced a new runtime named "single" with a replica count of 1.
- Added an environment variable "GITHUB_BRANCH" set to "0.4.2" for the new runtime.
2026-05-19 14:06:36 -03:00
vitor-aignosi
83d3a4482c SIENTIAPDE-1646
SIENTIAPDE-1646 Enhance OPC integration and E2E testing framework

- Updated .gitignore to exclude '.cursor/*' for better file management.
- Added new marker in pyproject.toml for E2E tests using OPC.
- Introduced async OPC server fixtures and improved connection handling in conftest.py.
- Enhanced error handling in OPC activities and added metrics for session management in metrics.py.
- Updated E2E tests to cover new OPC scenarios, including session errors and reconnect handling.
- Refactored helper functions to improve prediction assertion logic in helpers.py.
- Documented new OPC scenarios in scenarios.md for clarity on expected outcomes.
2026-05-18 16:40:56 -03:00
vitor-aignosi
b37ec60b5d SIENTIAPDE-1646
Update .gitignore and input_sample.json for improved configuration management

- Added new patterns to .gitignore to exclude 'mlruns/', 'relatorio*', and 'openspec/*' directories from version control.
- Updated the 'updated_at' date in input_sample.json to reflect a new timestamp for better tracking of schedule states.
2026-05-18 13:03:39 -03:00
vitor-aignosi
00cf8a2ad6 SIENTIAPDE-1646
Refactor OPC and OpcRepository classes to remove logger dependency and streamline logging calls

- Removed logger attribute from OPC and OpcRepository classes, replacing direct logger calls with class methods for logging.
- Updated write_data method signatures to eliminate logger parameter, simplifying the interface.
- Adjusted related tests to reflect changes in method signatures and logging behavior.
2026-05-13 10:36:35 -03:00
vitor-aignosi
84e6501063 SIENTIAPDE-1646
Implement new scheduling configurations for model retraining and drift analysis in input_sample.json

- Added three new schedule configurations: `minimal-retrain-test-runtime`, `drift-test-runtime`, and `simple-metrics-test-runtime`.
- Each configuration includes parameters such as model ID, workflow type, frequency, and specific queries for data retrieval.
- Enhanced the structure to support active status and updated timestamps for better tracking of schedule states.
2026-05-12 08:31:50 -03:00
vitor-aignosi
4989cfcb3c SIENTIAPDE-1646
SIENTIAPDE-1646 Add new scheduling configurations and remove outdated documentation

- Introduced new scheduling configurations for minimal retrain, drift analysis, and simple metrics in `input_sample.json`.
- Removed obsolete documentation files related to drift analysis and E2E test reports to streamline project resources.
- Updated E2E tests for minimal retrain to enhance reporting and error handling during model retraining processes.
2026-05-11 17:02:08 -03:00
vitor-aignosi
16ea436e45 SIENTIAPDE-1646
Refactor MLflow configuration to use environment variable for tracking URL

- Removed the `_build_mlflow_tracking_url` function and replaced its usage with `getenv` to directly retrieve the `MLFLOW_URL` environment variable.
- This change simplifies the configuration process by allowing users to specify the tracking URL directly through an environment variable.
2026-05-11 13:28:37 -03:00
vitor-aignosi
02913e341d SIENTIAPDE-1646
Update sientia_model dependency in requirements.txt to allow for any version greater than or equal to 0.8.2
2026-05-11 12:49:13 -03:00
vitor-aignosi
d26e89aa98 SIENTIAPDE-1646
Update sientia_do dependency to version 1.12.1 in requirements.txt
2026-05-11 12:44:13 -03:00
vitor-aignosi
e22b0bc7c3 SIENTIAPDE-1646
SIENTIAPDE-1646 Update dependencies and refactor OPC integration

- Replaced `opcua` with `asyncua` in `requirements-local.txt` and `requirements.txt` to utilize the async capabilities.
- Updated `values.yaml` to change the GitHub branch from `feature/SIENTIAPDE-1646` to `release/SIENTIAPDE-1646`.
- Refactored `opc.py` and `opc_repository.py` to accommodate the new `asyncua` library, ensuring compatibility with the synchronous API.
- Adjusted tests in `test_opc_repository.py` to reflect changes in the client implementation and maintain functionality.
2026-05-11 12:29:39 -03:00
vitor-aignosi
8d34228d7b SIENTIAPDE-1646
Update E2E test report and enhance drift analysis handling

- Updated the E2E test report metrics to reflect the latest test results, showing 47 collected tests with all passing.
- Removed outdated sections related to failed tests and their causes, streamlining the report.
- Implemented a regression fix in the drift analysis to handle empty merged frames, ensuring workflows skip export when no drift metrics are available.
- Enhanced the `insert_sample_data` and `insert_sample_prediction` functions to allow customizable timestamps for better test accuracy.
- Refactored E2E tests to improve clarity and maintainability, particularly in handling repeat scenarios with distinct timestamps.
2026-05-11 11:49:30 -03:00
vitor-aignosi
10c7e292b9 SIENTIAPDE-1646
Refactor ModelMetrics to utilize DriftAnalysis for drift detection

- Replaced ModelAnalysis with DriftAnalysis in the ModelMetrics class to enhance drift detection capabilities.
- Updated method signatures and documentation to reflect the changes in target_name and return values.
- Adjusted data handling to ensure compatibility with the new analysis methods and improved clarity in the drift metrics dataframe preparation.
2026-05-08 16:39:12 -03:00
vitor-aignosi
e6018af23f SIENTIAPDE-1646
Update README, requirements, and E2E tests for improved configuration and functionality

- Enhanced the README with updated model configuration examples, including the addition of an alias for production.
- Removed the `requirements-light.txt` file and updated `requirements-local.txt` and `requirements.txt` to replace `asyncua` with `opcua`.
- Refactored E2E test scenarios to utilize scenario input files for better maintainability and clarity.
- Improved test coverage for MinIO offload functionality and added new helper functions for loading scenario inputs.
- Updated `values.yaml` to reflect new global configurations and environment variables for the laborious worker.
2026-05-07 17:02:25 -03:00
vitor-aignosi
aaf647efdf SIENTIAPDE-1646
Refactor MLFlow retraining logic to always use retrain method

- Removed the conditional logic for full retraining, ensuring the `retrain` method is always called.
- Updated the documentation in the `retrain_model` method to reflect the changes in retraining flow.
- Adjusted tests to verify that the `retrain` method is invoked correctly, while ensuring `train` is not called when the full retrain flag is set.
2026-05-07 09:03:33 -03:00
vitor-aignosi
424be007ef SIENTIAPDE-1646
Update dependencies and refactor MLFlow activities

- Replaced direct GitHub dependencies in `requirements.txt` with specific versioned packages for `sientia_do` and `sientia_model`.
- Refactored imports in `activities.py` to streamline the code structure.
- Enhanced the `MLFlow` class in `mlflow.py` by introducing a method to resolve model aliases, improving flexibility in model lookups.
- Simplified shutdown logic in `worker.py` for better readability.
- Added new tests for MLFlow activities and improved existing test coverage for data handling and model retraining processes.
2026-05-06 15:31:25 -03:00
vitor-aignosi
1ce8b9d3a7 SIENTIAPDE-1773
Enhance environment configuration and update dependencies

- Added new environment variables for PluginStore and MLflow configuration in `.env.example`, including `RUNTIME`, `STORE_BASE_URL`, `STORE_OWNER`, `STORE_REPO`, `STORE_BRANCH`, `STORE_USERNAME`, `STORE_PASSWORD`, `STORE_CACHE_TTL_SECONDS`, `PYPI_SERVER`, `PYPI_USERNAME`, and `PYPI_PASSWORD`.
- Updated `git-requirements-mapping.txt` to reflect changes in repository names.
- Modified `requirements-light.txt` and `requirements.txt` to upgrade `sientia-dataops-library` to version 1.12.0 and `sientia-mlops-library` to version 0.8.1.
- Updated `values.yaml` to include new environment variables for worker runtime and PluginStore configuration.
- Refactored E2E tests to utilize new MLflow repository stubs and PluginStore mocks for improved testing accuracy.
2026-05-05 16:52:51 -03:00
vitor-aignosi
473bd0b03f Merge pull request #38 from Aignosi/feature/SIENTIAPDE-1712
Feat/Refactor: MinIO Offload, Data Tracking, and Drift Detection Workflows
2026-04-02 16:20:48 -03:00
vitor-aignosi
25430b5b26 SIENTIAPDE-1712
Update scipy version constraint in requirements.txt to allow versions below 1.14.0 for compatibility with existing dependencies.
2026-04-02 10:07:05 -03:00
vitor-aignosi
5e883d4530 SIENTIAPDE-1712
Add scipy version 1.13.0 to requirements.txt for enhanced scientific computing capabilities.
2026-04-02 10:06:39 -03:00
vitor-aignosi
5398ac6bc2 SIENTIAPDE-1712
Update sientia-mlops-library dependency to version 0.41.0 in requirements.txt for improved functionality and features.
2026-04-01 16:53:12 -03:00
vitor-aignosi
381856f5ca SIENTIAPDE-1712
SIENTIAPDE-1712 Enhance logging across various classes by adding logger parameters and improving debug statements. This update includes adjustments in Gates, MLFlow, ModelMetrics, and MLFlowRepository classes for better traceability and observability during operations.
2026-04-01 13:53:23 -03:00
vitor-aignosi
b9fe4604f7 SIENTIAPDE-1712
SIENTIAPDE-1712 Convert confidence_value to float in API class to ensure consistent data type for value assignment in activity monitoring.
2026-04-01 09:30:55 -03:00
vitor-aignosi
59dd6078b0 SIENTIAPDE-1712
Update values.yaml to adjust workflow and activity poller configurations for improved performance, increasing minimum, initial, and maximum values. Additionally, add new minimal retrain parameters to enhance retraining capabilities.
2026-03-31 16:21:32 -03:00
vitor-aignosi
e6fee73cce SIENTIAPDE-1712
SIENTIAPDE-1712 Enhance logging in MLFlowRepository class by introducing a dedicated _debug_dataframe method for conditional logging of DataFrame content. This update improves observability during model transformation, prediction, and retraining processes while managing log output effectively.
2026-03-31 15:13:05 -03:00
vitor-aignosi
a3775279e1 SIENTIAPDE-1712
SIENTIAPDE-1712 Refactor logging in MLFlowRepository class by removing the debug_dataframe method and replacing it with direct debug statements for improved clarity. This change enhances the logging of DataFrame content during model transformation, prediction, and retraining processes, ensuring better observability without excessive log output.
2026-03-31 15:05:40 -03:00
vitor-aignosi
d9ec7fc496 SIENTIAPDE-1712
Update values.yaml to rename SIE_MINIO_OFFLOAD_THRESHOLD_MEGABYTES to SIENTIA_MINIO_OFFLOAD_THRESHOLD_MEGABYTES and adjust its value to 0.5 for improved configuration clarity.
2026-03-31 09:10:56 -03:00
vitor-aignosi
7c32424cf1 SIENTIAPDE-1712
SIENTIAPDE-1712 Refactor logging in MinioDataFramePayload class to utilize custom_debug method for improved clarity and consistency. Enhanced DataFrame size logging by integrating a dedicated debug method, streamlining the logging process.
2026-03-30 09:32:51 -03:00