Browse Source

Not-ending learning for anomaly detector #665 (#674)

pull/1/head
rozetko 6 years ago committed by GitHub
parent
commit
8074e0a2e1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 5
      server/src/controllers/analytics_controller.ts
  2. 1
      server/src/models/analytic_units/types.ts

5
server/src/controllers/analytics_controller.ts

@ -290,6 +290,8 @@ export async function runLearning(id: AnalyticUnit.AnalyticUnitId, from?: number
if(result.status !== AnalyticUnit.AnalyticUnitStatus.SUCCESS) { if(result.status !== AnalyticUnit.AnalyticUnitStatus.SUCCESS) {
throw new Error(result.error); throw new Error(result.error);
} }
// TODO: rename SUCCESS to something better
await AnalyticUnit.setStatus(id, AnalyticUnit.AnalyticUnitStatus.SUCCESS);
await AnalyticUnitCache.setData(id, result.payload.cache); await AnalyticUnitCache.setData(id, result.payload.cache);
} catch (err) { } catch (err) {
const message = err.message || JSON.stringify(err); const message = err.message || JSON.stringify(err);
@ -331,8 +333,7 @@ export async function runDetect(id: AnalyticUnit.AnalyticUnitId, from?: number,
{ detector, analyticUnitType, lastDetectionTime: unit.lastDetectionTime, data, cache: oldCache } { detector, analyticUnitType, lastDetectionTime: unit.lastDetectionTime, data, cache: oldCache }
); );
console.log(`run task, id:${id}`); console.log(`run task, id:${id}`);
// TODO: status: detection await AnalyticUnit.setStatus(id, AnalyticUnit.AnalyticUnitStatus.DETECTION);
await AnalyticUnit.setStatus(id, AnalyticUnit.AnalyticUnitStatus.LEARNING);
const result = await runTask(task); const result = await runTask(task);
if(result.status === AnalyticUnit.AnalyticUnitStatus.FAILED) { if(result.status === AnalyticUnit.AnalyticUnitStatus.FAILED) {

1
server/src/models/analytic_units/types.ts

@ -6,6 +6,7 @@ export enum AnalyticUnitStatus {
READY = 'READY', READY = 'READY',
PENDING = 'PENDING', PENDING = 'PENDING',
LEARNING = 'LEARNING', LEARNING = 'LEARNING',
DETECTION = 'DETECTION',
SUCCESS = 'SUCCESS', SUCCESS = 'SUCCESS',
FAILED = 'FAILED' FAILED = 'FAILED'
}; };

Loading…
Cancel
Save