remoteMachineJobRestServer.ts 1.19 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
import { ClusterJobRestServer } from '../common/clusterJobRestServer';
SparkSnail's avatar
SparkSnail committed
5
6
7
8
import { RemoteMachineTrainingService } from './remoteMachineTrainingService';

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

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

chicm-ms's avatar
chicm-ms committed
22
    protected handleTrialMetrics(jobId: string, metrics: any[]): void {
SparkSnail's avatar
SparkSnail committed
23
24
25
26
27
28
29
30
31
        // 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
            });
        }
    }
32
}