edge-impulse-linux 1.26.1 → 1.26.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -2
- package/build/cli/linux/agent-capture.d.ts +29 -0
- package/build/cli/linux/agent-capture.js +94 -0
- package/build/cli/linux/agent-capture.js.map +1 -0
- package/build/cli/linux/agent-runner-metadata.d.ts +12 -3
- package/build/cli/linux/agent-runner-metadata.js +15 -3
- package/build/cli/linux/agent-runner-metadata.js.map +1 -1
- package/build/cli/linux/audio-utils.d.ts +1 -10
- package/build/cli/linux/audio-utils.js +2 -25
- package/build/cli/linux/audio-utils.js.map +1 -1
- package/build/cli/linux/runner-downloader.js +3 -0
- package/build/cli/linux/runner-downloader.js.map +1 -1
- package/build/cli/linux/runner-utils.js +1 -1
- package/build/cli/linux/runner-utils.js.map +1 -1
- package/build/cli/linux/runner.js +96 -60
- package/build/cli/linux/runner.js.map +1 -1
- package/build/cli-common/model-monitor.d.ts +97 -10
- package/build/cli-common/model-monitor.js +380 -373
- package/build/cli-common/model-monitor.js.map +1 -1
- package/build/cli-common/remote-mgmt-service.d.ts +1 -0
- package/build/cli-common/remote-mgmt-service.js +29 -11
- package/build/cli-common/remote-mgmt-service.js.map +1 -1
- package/build/library/classifier/audio-classifier.d.ts +16 -0
- package/build/library/classifier/audio-classifier.js +77 -1
- package/build/library/classifier/audio-classifier.js.map +1 -1
- package/build/library/classifier/image-classifier.d.ts +14 -0
- package/build/library/classifier/image-classifier.js +79 -3
- package/build/library/classifier/image-classifier.js.map +1 -1
- package/build/library/classifier/linux-impulse-runner.d.ts +8 -1
- package/build/library/classifier/linux-impulse-runner.js +13 -0
- package/build/library/classifier/linux-impulse-runner.js.map +1 -1
- package/build/library/sensors/audio-utils.d.ts +4 -0
- package/build/library/sensors/audio-utils.js +23 -0
- package/build/library/sensors/audio-utils.js.map +1 -0
- package/build/library/sensors/gstreamer.d.ts +1 -1
- package/build/library/sensors/gstreamer.js +7 -4
- package/build/library/sensors/gstreamer.js.map +1 -1
- package/build/sdk/studio/sdk/api/devicesApi.d.ts +2 -2
- package/build/sdk/studio/sdk/api/devicesApi.js +2 -2
- package/build/sdk/studio/sdk/model/additionalMetricOptionalFullPrecisionValue.d.ts +7 -0
- package/build/sdk/studio/sdk/model/additionalMetricOptionalFullPrecisionValue.js +4 -0
- package/build/sdk/studio/sdk/model/additionalMetricOptionalFullPrecisionValue.js.map +1 -0
- package/build/sdk/studio/sdk/model/dSPGroupItem.d.ts +9 -1
- package/build/sdk/studio/sdk/model/dSPGroupItem.js +3 -1
- package/build/sdk/studio/sdk/model/dSPGroupItem.js.map +1 -1
- package/build/sdk/studio/sdk/model/device.d.ts +5 -5
- package/build/sdk/studio/sdk/model/deviceApplication.d.ts +12 -0
- package/build/sdk/studio/sdk/model/{deviceWorkload.js → deviceApplication.js} +1 -1
- package/build/sdk/studio/sdk/model/deviceApplication.js.map +1 -0
- package/build/sdk/studio/sdk/model/{deviceWorkloadModel.d.ts → deviceApplicationModel.d.ts} +2 -2
- package/build/sdk/studio/sdk/model/{deviceWorkloadModel.js → deviceApplicationModel.js} +1 -1
- package/build/sdk/studio/sdk/model/deviceApplicationModel.js.map +1 -0
- package/build/sdk/studio/sdk/model/deviceDeploymentEvent.d.ts +4 -4
- package/build/sdk/studio/sdk/model/deviceModelDeploymentRequest.d.ts +5 -0
- package/build/sdk/studio/sdk/model/foldModelMetadata.d.ts +5 -0
- package/build/sdk/studio/sdk/model/getMonitoringEventDetailsResponse.d.ts +4 -0
- package/build/sdk/studio/sdk/model/getMonitoringEventDetailsResponse.js.map +1 -1
- package/build/sdk/studio/sdk/model/inferenceHistoryAggregate.d.ts +2 -2
- package/build/sdk/studio/sdk/model/kerasModelMetadata.d.ts +5 -0
- package/build/sdk/studio/sdk/model/kerasModelMetadataBase.d.ts +5 -0
- package/build/sdk/studio/sdk/model/kerasModelMetadataResponse.d.ts +5 -0
- package/build/sdk/studio/sdk/model/models.d.ts +3 -2
- package/build/sdk/studio/sdk/model/models.js +3 -2
- package/build/sdk/studio/sdk/model/models.js.map +1 -1
- package/build/sdk/studio/sdk/model/monitoringEventContext.d.ts +6 -2
- package/build/sdk/studio/sdk/model/monitoringInferenceSummary.d.ts +4 -0
- package/build/sdk/studio/sdk/model/userOrganization.d.ts +2 -0
- package/build/shared/viewmodels/init.d.ts +0 -1
- package/build/shared/viewmodels/init.js +0 -1
- package/build/shared/viewmodels/init.js.map +1 -1
- package/package.json +2 -2
- package/test/agent-bundle-lifecycle.test.ts +2 -2
- package/test/agent-bundle.test.ts +104 -0
- package/test/agent-capture.test.ts +528 -0
- package/test/agent-client.test.ts +64 -169
- package/test/agent-command-processor.test.ts +1 -1
- package/test/agent-preview-replacement.test.ts +114 -0
- package/test/agent-runner-configuration.test.ts +12 -3
- package/test/agent-runner-integration.test.ts +50 -8
- package/test/gstreamer.test.ts +1 -1
- package/test/helpers/mock-agent.ts +106 -0
- package/test/model-monitor.test.ts +250 -55
- package/test/monitoring-fixture.ts +168 -0
- package/test/monitoring-policy-protocol.test.ts +193 -1
- package/test/runner-preview.test.ts +59 -0
- package/test/summary-rules-fixtures.test.ts +194 -0
- package/test/utils/agent-runner-fixtures.ts +22 -7
- package/build/sdk/studio/sdk/model/deviceWorkload.d.ts +0 -12
- package/build/sdk/studio/sdk/model/deviceWorkload.js.map +0 -1
- package/build/sdk/studio/sdk/model/deviceWorkloadModel.js.map +0 -1
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
/// <reference types="node" />
|
|
3
3
|
import { MonitoringSummaryPolicy } from '../shared/device-protocol/remote-management';
|
|
4
4
|
import { Config } from './config';
|
|
5
|
-
import { RunnerClassifyResponseSuccess, ModelInformation } from "../library/classifier/linux-impulse-runner-types";
|
|
5
|
+
import { RunnerClassifyResponseSuccess, ModelInformation, RunnerBlockThreshold } from "../library/classifier/linux-impulse-runner-types";
|
|
6
6
|
import { EventEmitter } from 'tsee';
|
|
7
7
|
import { MgmtInterfaceImpulseRecordRawData, MgmtInterfaceInferenceSummary } from '../shared/MgmtInterfaceTypes';
|
|
8
8
|
export declare const DEFAULT_MONITOR_SUMMARY_INTERVAL_MS = 60000;
|
|
@@ -10,7 +10,7 @@ export declare const MIN_MONITOR_SUMMARY_INTERVAL_MS = 5000;
|
|
|
10
10
|
/**
|
|
11
11
|
* Helper to check if the model has visual AD capabilities based on its parameters.
|
|
12
12
|
*/
|
|
13
|
-
export declare function hasVisualAd(model:
|
|
13
|
+
export declare function hasVisualAd(model: Pick<MonitoredModel, 'modelParameters'>): boolean;
|
|
14
14
|
export type ImpulseRecord = {
|
|
15
15
|
impulseRecord: RunnerClassifyResponseSuccess;
|
|
16
16
|
timestamp: number;
|
|
@@ -32,8 +32,70 @@ export type MetricsWindowBoundary = {
|
|
|
32
32
|
timestamp: number;
|
|
33
33
|
};
|
|
34
34
|
export type InferenceMetrics = MgmtInterfaceInferenceSummary['inferenceSummary'];
|
|
35
|
+
/** Model metadata plus the original threshold snapshot used to calculate inference summaries. */
|
|
36
|
+
export type MonitoredModel = {
|
|
37
|
+
modelParameters: Pick<ModelInformation['modelParameters'], 'model_type' | 'has_anomaly' | 'thresholds'>;
|
|
38
|
+
reportedThresholds: readonly RunnerBlockThreshold[];
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* The part of the configuration that the metrics calculator reads.
|
|
42
|
+
*/
|
|
43
|
+
export interface MetricsConfig {
|
|
44
|
+
getMonitorSummaryIntervalMs(): Promise<number | undefined>;
|
|
45
|
+
}
|
|
46
|
+
/** Distinguish the active reporting interval from the saved CLI preference during construction. */
|
|
47
|
+
type MetricsCalculatorCadence = {
|
|
48
|
+
summaryWindowMs: number;
|
|
49
|
+
configuredSummaryIntervalMs: number | undefined;
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* Computes inference summaries from the model's original thresholds. Half-open windows close
|
|
53
|
+
* before a boundary result or on a timer; late results are dropped, and empty windows produce no summary.
|
|
54
|
+
*/
|
|
55
|
+
export declare class MetricsCalculator {
|
|
56
|
+
private readonly _model;
|
|
57
|
+
private _completedMetrics;
|
|
58
|
+
private _summaryWindowMs;
|
|
59
|
+
readonly configuredSummaryIntervalMs: number | undefined;
|
|
60
|
+
private _accumulator;
|
|
61
|
+
private _windowStart;
|
|
62
|
+
private _windowEnd;
|
|
63
|
+
private _latestTimestamp;
|
|
64
|
+
private _closedThrough;
|
|
65
|
+
/** Prepare a fresh accumulator for one deployment and retain its configured and effective cadence. */
|
|
66
|
+
constructor(_model: MonitoredModel, cadence: MetricsCalculatorCadence);
|
|
67
|
+
/** Read the saved preference and create a fresh calculator for this monitoring session. */
|
|
68
|
+
static getMetricsInstance(config: MetricsConfig, model: MonitoredModel): Promise<MetricsCalculator>;
|
|
69
|
+
/** Create empty statistics using this deployment's original thresholds, never mutable runner settings. */
|
|
70
|
+
private createAccumulator;
|
|
71
|
+
/** Expose the current half-open window's end, or undefined when no window has results. */
|
|
72
|
+
get summaryDeadline(): number | undefined;
|
|
73
|
+
/** Expose the policy-adjusted reporting interval. */
|
|
74
|
+
get summaryIntervalMs(): number;
|
|
75
|
+
/** Update cadence while keeping the open window's end strictly after every already-admitted timestamp. */
|
|
76
|
+
setSummaryIntervalMs(intervalMs: number): void;
|
|
77
|
+
/** Finish any valid snapshot before resetting statistics and advancing the late-result cutoff. */
|
|
78
|
+
private closeWindow;
|
|
79
|
+
/** Return whether wall time moved far enough behind known windows that the existing grid is unusable. */
|
|
80
|
+
private clockMovedBack;
|
|
81
|
+
/** Close the current window, if any, and forget the future grid after a backward clock correction. */
|
|
82
|
+
private resetAfterClockCorrection;
|
|
83
|
+
/** Close an elapsed window, or reset a stale future window after wall time moves backwards. */
|
|
84
|
+
closeDueWindow(timestamp: number): Promise<InferenceMetrics | undefined>;
|
|
85
|
+
/** Close pending results once at a partial-window cutoff; leave empty windows unreported. */
|
|
86
|
+
flushMetrics(): Promise<InferenceMetrics | undefined>;
|
|
87
|
+
/**
|
|
88
|
+
* Reject late records, close a due window before admission,
|
|
89
|
+
* and expose its summary separately from the new window.
|
|
90
|
+
*/
|
|
91
|
+
updateMetrics(record: Pick<ImpulseRecord, 'impulseRecord' | 'timestamp' | 'index'>): Promise<boolean>;
|
|
92
|
+
/** Hand off a record-triggered completed summary once, independently of the new window's snapshot. */
|
|
93
|
+
takeCompletedMetrics(): InferenceMetrics | undefined;
|
|
94
|
+
}
|
|
35
95
|
/**
|
|
36
|
-
*
|
|
96
|
+
* Coordinates record persistence, calculator updates and summary delivery through one serialized queue.
|
|
97
|
+
* Keeps policy, deployment transitions and debug-record delivery separate from summary aggregation,
|
|
98
|
+
* using the calculator's deadline for timer-driven closure.
|
|
37
99
|
*/
|
|
38
100
|
export declare class ModelMonitor extends EventEmitter<{
|
|
39
101
|
'impulse-record': (ev: ImpulseRecord) => void;
|
|
@@ -42,18 +104,36 @@ export declare class ModelMonitor extends EventEmitter<{
|
|
|
42
104
|
}> {
|
|
43
105
|
private _storageManager;
|
|
44
106
|
private _metricsCalculator;
|
|
107
|
+
private _processing;
|
|
108
|
+
private _acceptingResults;
|
|
109
|
+
private _summaryTimer;
|
|
45
110
|
private _streamState;
|
|
46
111
|
private _lastPolicy;
|
|
47
112
|
private _streamPrevState;
|
|
113
|
+
/** Prepare event delivery; the factory initializes deployment storage and its calculator asynchronously. */
|
|
48
114
|
private constructor();
|
|
49
115
|
/**
|
|
50
116
|
* Creates a new instance of ModelMonitor with the provided configuration and model information.
|
|
51
117
|
* @param config The configuration object.
|
|
52
118
|
* @param model The model information object.
|
|
119
|
+
* @param options Original model thresholds supplied by the runner, before local settings are applied.
|
|
53
120
|
* @returns A promise that resolves to a ModelMonitor instance.
|
|
54
121
|
*/
|
|
55
|
-
static getModelMonitor(config: Config, model: ModelInformation): Promise<ModelMonitor>;
|
|
122
|
+
static getModelMonitor(config: Config, model: ModelInformation, options: Pick<MonitoredModel, 'reportedThresholds'>): Promise<ModelMonitor>;
|
|
123
|
+
/** Serialize record allocation, statistics and flushes while allowing later operations after a failure. */
|
|
124
|
+
private enqueue;
|
|
125
|
+
/** Schedule the active deadline, delaying retries if closure fails. */
|
|
126
|
+
private scheduleSummary;
|
|
127
|
+
/** Permanently stop admitting results, then drain and flush the current deployment. */
|
|
128
|
+
stop(): Promise<void>;
|
|
129
|
+
/**
|
|
130
|
+
* Replace deployment storage/statistics after the caller pauses inference and flushes the old model.
|
|
131
|
+
* Retain listeners and policy without restarting a monitor that has been terminally stopped.
|
|
132
|
+
*/
|
|
133
|
+
replaceModel(config: Config, model: ModelInformation, options: Pick<MonitoredModel, 'reportedThresholds'>): Promise<void>;
|
|
134
|
+
/** Expose the saved CLI preference, independent of this session's server policy. */
|
|
56
135
|
get configuredSummaryIntervalMs(): number | undefined;
|
|
136
|
+
/** Expose the calculator's current policy-adjusted reporting interval. */
|
|
57
137
|
get effectiveSummaryIntervalMs(): number | undefined;
|
|
58
138
|
/**
|
|
59
139
|
* Apply the server requirement to this session without overwriting the saved CLI preference.
|
|
@@ -63,17 +143,18 @@ export declare class ModelMonitor extends EventEmitter<{
|
|
|
63
143
|
* produce a warning. Preserving the in-flight aggregate means acceleration cannot backfill history.
|
|
64
144
|
*/
|
|
65
145
|
applySummaryPolicy(policy: MonitoringSummaryPolicy | undefined): void;
|
|
146
|
+
/** Queue a flush after admitted records, emit only a new summary, and refresh any remaining timer. */
|
|
66
147
|
flushMetrics(): Promise<void>;
|
|
148
|
+
/** Report whether processed records are currently streamed live for debugging. */
|
|
67
149
|
get impulseDebug(): boolean;
|
|
68
150
|
/**
|
|
69
|
-
*
|
|
70
|
-
*
|
|
71
|
-
* When disabled, the model monitor will not emit impulse records.
|
|
72
|
-
* In the 'records-request' state, setting impulseDebug to true will abort the records-request state.
|
|
73
|
-
* In the 'records-request' state, setting impulseDebug to false has no effect.
|
|
151
|
+
* Switch between live debug-record streaming and idle, replacing any records-request state.
|
|
152
|
+
* Summary collection remains active independently of debug streaming.
|
|
74
153
|
*/
|
|
75
154
|
set impulseDebug(enabled: boolean);
|
|
155
|
+
/** Return retained record bounds for Remote Management, or zero bounds before storage is available. */
|
|
76
156
|
getStorageStatus(): Promise<StorageStatus>;
|
|
157
|
+
/** Restore the previous streaming state when a record request is aborted. */
|
|
77
158
|
abortImpulseRecordsRequest(): void;
|
|
78
159
|
/**
|
|
79
160
|
* Retrieves impulse records based on the provided request.
|
|
@@ -82,7 +163,8 @@ export declare class ModelMonitor extends EventEmitter<{
|
|
|
82
163
|
* - index: The index of the single impulse record to retrieve.
|
|
83
164
|
* - range: An object with first and last properties specifying the range of impulse records to retrieve.
|
|
84
165
|
* - list: An array of indices of impulse records to retrieve (in any order)
|
|
85
|
-
*
|
|
166
|
+
* Missing records and inverted ranges emit error responses.
|
|
167
|
+
* @throws Error if the request supplies none of the supported selectors.
|
|
86
168
|
*/
|
|
87
169
|
getImpulseRecords(impulseRequest: {
|
|
88
170
|
index?: number;
|
|
@@ -92,8 +174,13 @@ export declare class ModelMonitor extends EventEmitter<{
|
|
|
92
174
|
};
|
|
93
175
|
list?: number[];
|
|
94
176
|
}): void;
|
|
177
|
+
/**
|
|
178
|
+
* Admit an active producer result, persist it before aggregation,
|
|
179
|
+
* and deliver completed summaries/debug records.
|
|
180
|
+
*/
|
|
95
181
|
processResult(result: RunnerClassifyResponseSuccess, rawData: {
|
|
96
182
|
type: 'wav' | 'jpg';
|
|
97
183
|
buffer: Buffer;
|
|
98
184
|
}): Promise<void>;
|
|
99
185
|
}
|
|
186
|
+
export {};
|