remoteMachineJobRestServer.ts 1.21 KB
Newer Older
liuzhe-lz's avatar
liuzhe-lz committed
1
2
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
SparkSnail's avatar
SparkSnail committed
3
4
5

'use strict';

6
import { ClusterJobRestServer } from '../common/clusterJobRestServer';
SparkSnail's avatar
SparkSnail committed
7
8
9
10
import { RemoteMachineTrainingService } from './remoteMachineTrainingService';

/**
 * RemoteMachine Training service Rest server, provides rest RemoteMachine to support remotemachine job metrics update
11
 *
SparkSnail's avatar
SparkSnail committed
12
 */
13
export class RemoteMachineJobRestServer extends ClusterJobRestServer {
chicm-ms's avatar
chicm-ms committed
14
    private readonly remoteMachineTrainingService: RemoteMachineTrainingService;
SparkSnail's avatar
SparkSnail committed
15
16
17
18

    /**
     * constructor to provide NNIRestServer's own rest property, e.g. port
     */
19
    constructor(remoteMachineTrainingService: RemoteMachineTrainingService) {
SparkSnail's avatar
SparkSnail committed
20
        super();
21
        this.remoteMachineTrainingService = remoteMachineTrainingService;
SparkSnail's avatar
SparkSnail committed
22
23
    }

chicm-ms's avatar
chicm-ms committed
24
    protected handleTrialMetrics(jobId: string, metrics: any[]): void {
SparkSnail's avatar
SparkSnail committed
25
26
27
28
29
30
31
32
33
        // Split metrics array into single metric, then emit
        // Warning: If not split metrics into single ones, the behavior will be UNKNOWNls
        for (const singleMetric of metrics) {
            this.remoteMachineTrainingService.MetricsEmitter.emit('metric', {
                id : jobId,
                data : singleMetric
            });
        }
    }
34
}