feat: Add predictive maintenance example using DMI and edge AI#168
feat: Add predictive maintenance example using DMI and edge AI#168darshankerkar wants to merge 4 commits into
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: darshankerkar The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
Welcome @darshankerkar! It looks like this is your first PR to kubeedge/examples 🎉 |
There was a problem hiding this comment.
Code Review
This pull request introduces a comprehensive Predictive Maintenance example for KubeEdge, featuring a Go-based mapper that performs real-time Z-score anomaly detection on simulated sensor data. The feedback focuses on improving the robustness of the mapper's lifecycle management, specifically by implementing proper synchronization during shutdown and validating configuration parameters to prevent runtime panics. Additionally, improvements were suggested for the device configurations and DMI reporting logic to correctly handle read-only properties by removing unnecessary desired state fields.
| } | ||
|
|
||
| func runLoop(ctx context.Context, sensor *driver.VirtualSensor, detector *inference.Detector, client *dmi.Client, interval int) { | ||
| ticker := time.NewTicker(time.Duration(interval) * time.Second) |
There was a problem hiding this comment.
Signed-off-by: darshankerkar <darshankerkar09@gmail.com>
33ffbcb to
9ddf1e1
Compare
Signed-off-by: darshankerkar <darshankerkar09@gmail.com>
There was a problem hiding this comment.
Code Review
This pull request introduces a new Predictive Maintenance example for KubeEdge, featuring a Go-based mapper that simulates industrial equipment sensors and performs offline anomaly detection using a Z-score algorithm. The implementation includes device models, deployment manifests, and scripts for verifying edge autonomy. Feedback focuses on optimizing memory management in the rolling window, removing unused sensor code, and improving the security and portability of the Kubernetes manifests by avoiding host networking and hardcoded node names. It was also suggested to make gRPC timeouts configurable for better production readiness.
Signed-off-by: darshankerkar <darshankerkar09@gmail.com>
There was a problem hiding this comment.
Code Review
This pull request introduces a comprehensive 'Predictive Maintenance @edge' example for KubeEdge, featuring a Go-based mapper that simulates industrial sensors and performs offline anomaly detection using a Z-score algorithm. The implementation includes KubeEdge CRD configurations, deployment manifests, and scripts for testing edge autonomy. Feedback on the code focuses on improving the statistical robustness and performance of the inference engine. Key recommendations include updating the data window after analysis to prevent outliers from masking themselves, optimizing mean and standard deviation calculations into a single pass for better edge performance, and implementing a noise floor to handle zero-variance scenarios.
| func zScore(value, mean, std float64) float64 { | ||
| if std < 1e-10 { | ||
| return 0 | ||
| } | ||
| return (value - mean) / std | ||
| } |
There was a problem hiding this comment.
Returning 0 when std is near zero prevents division by zero, but it also means that any deviation from a perfectly constant signal will not be detected as an anomaly until the window accumulates enough variance. Consider adding a small 'noise floor' or epsilon to the standard deviation to allow detection of spikes in very stable data.
Signed-off-by: darshankerkar <darshankerkar09@gmail.com>
86793b5 to
8edbadb
Compare
|
Fixed the code and resolved the outdated suggestions by @gemini-code-assist. |
What type of PR is this?
/kind feature
What this PR does / why we need it:
Hello everyone! This PR introduces a complete, end to end example of Predictive Maintenance at the edge to showcase Embodied Intelligence use cases using KubeEdge.
While working with the framework, I realized it would be highly beneficial to have a comprehensive demo showing how edge AI can operate autonomously. This example covers:
ReportDeviceStatusgRPC callsEverything is self contained with CRDs, deployment manifests, unit tests, and a detailed README to help new users and contributors get started easily.
Which issue(s) this PR fixes:
None directly (standalone example).
Special notes for your reviewer:
I have verified that the module path is correctly scoped to the examples repository and the API dependency points to a valid pseudo version so it builds successfully standalone without interfering with the main project directory. Looking forward to any feedback!