manager.ts 4.52 KB
Newer Older
Deshui Yu's avatar
Deshui Yu committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
/**
 * Copyright (c) Microsoft Corporation
 * All rights reserved.
 *
 * MIT License
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
 * documentation files (the "Software"), to deal in the Software without restriction, including without limitation
 * the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and
 * to permit persons to whom the Software is furnished to do so, subject to the following conditions:
 * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 */

'use strict';

import { MetricDataRecord, MetricType, TrialJobInfo } from './datastore';
import { TrialJobStatus } from './trainingService';

QuanluZhang's avatar
QuanluZhang committed
25
type ProfileUpdateType = 'TRIAL_CONCURRENCY' | 'MAX_EXEC_DURATION' | 'SEARCH_SPACE' | 'MAX_TRIAL_NUM';
chicm-ms's avatar
chicm-ms committed
26
type ExperimentStatus = 'INITIALIZED' | 'RUNNING' | 'ERROR' | 'STOPPING' | 'STOPPED' | 'DONE' | 'NO_MORE_TRIAL' | 'TUNER_NO_MORE_TRIAL';
SparkSnail's avatar
SparkSnail committed
27
28
29
30
namespace ExperimentStartUpMode {
    export const NEW = 'new';
    export const RESUME = 'resume';
}
Deshui Yu's avatar
Deshui Yu committed
31
32
33
34

interface ExperimentParams {
    authorName: string;
    experimentName: string;
35
    description?: string;
Deshui Yu's avatar
Deshui Yu committed
36
37
38
39
    trialConcurrency: number;
    maxExecDuration: number; //seconds
    maxTrialNum: number;
    searchSpace: string;
40
    trainingServicePlatform: string;
chicm-ms's avatar
chicm-ms committed
41
    multiPhase?: boolean;
chicm-ms's avatar
chicm-ms committed
42
    multiThread?: boolean;
43
    versionCheck?: boolean;
SparkSnail's avatar
SparkSnail committed
44
    logCollection?: string;
QuanluZhang's avatar
QuanluZhang committed
45
    tuner?: {
46
47
48
49
50
51
52
        className: string;
        builtinTunerName?: string;
        codeDir?: string;
        classArgs?: any;
        classFileName?: string;
        checkpointDir: string;
        gpuNum?: number;
53
        includeIntermediateResults?: boolean;
Deshui Yu's avatar
Deshui Yu committed
54
55
    };
    assessor?: {
56
57
58
59
60
61
62
        className: string;
        builtinAssessorName?: string;
        codeDir?: string;
        classArgs?: any;
        classFileName?: string;
        checkpointDir: string;
        gpuNum?: number;
Deshui Yu's avatar
Deshui Yu committed
63
    };
QuanluZhang's avatar
QuanluZhang committed
64
65
66
67
68
69
70
71
72
    advisor?: {
        className: string;
        builtinAdvisorName?: string;
        codeDir?: string;
        classArgs?: any;
        classFileName?: string;
        checkpointDir: string;
        gpuNum?: number;
    };
Deshui Yu's avatar
Deshui Yu committed
73
74
75
76
77
78
79
80
81
82
    clusterMetaData?: {
        key: string;
        value: string;
    }[];
}

interface ExperimentProfile {
    params: ExperimentParams;
    id: string;
    execDuration: number;
83
    logDir?: string;
84
85
    startTime?: number;
    endTime?: number;
86
    maxSequenceId: number;
Deshui Yu's avatar
Deshui Yu committed
87
88
89
90
91
92
93
94
    revision: number;
}

interface TrialJobStatistics {
    trialJobStatus: TrialJobStatus;
    trialJobNumber: number;
}

95
interface NNIManagerStatus {
chicm-ms's avatar
chicm-ms committed
96
    status: ExperimentStatus;
97
98
99
    errors: string[];
}

Deshui Yu's avatar
Deshui Yu committed
100
101
abstract class Manager {
    public abstract startExperiment(experimentParams: ExperimentParams): Promise<string>;
SparkSnail's avatar
SparkSnail committed
102
    public abstract resumeExperiment(readonly: boolean): Promise<void>;
Deshui Yu's avatar
Deshui Yu committed
103
104
105
    public abstract stopExperiment(): Promise<void>;
    public abstract getExperimentProfile(): Promise<ExperimentProfile>;
    public abstract updateExperimentProfile(experimentProfile: ExperimentProfile, updateType: ProfileUpdateType): Promise<void>;
106
    public abstract importData(data: string): Promise<void>;
107
    public abstract exportData(): Promise<string>;
Deshui Yu's avatar
Deshui Yu committed
108
109
110
111
112
113
114
115
116

    public abstract addCustomizedTrialJob(hyperParams: string): Promise<void>;
    public abstract cancelTrialJobByUser(trialJobId: string): Promise<void>;

    public abstract listTrialJobs(status?: TrialJobStatus): Promise<TrialJobInfo[]>;
    public abstract getTrialJob(trialJobId: string): Promise<TrialJobInfo>;
    public abstract setClusterMetadata(key: string, value: string): Promise<void>;
    public abstract getClusterMetadata(key: string): Promise<string>;

117
    public abstract getMetricData(trialJobId?: string, metricType?: MetricType): Promise<MetricDataRecord[]>;
Deshui Yu's avatar
Deshui Yu committed
118
    public abstract getTrialJobStatistics(): Promise<TrialJobStatistics[]>;
119
    public abstract getStatus(): NNIManagerStatus;
Deshui Yu's avatar
Deshui Yu committed
120
121
}

SparkSnail's avatar
SparkSnail committed
122
export { Manager, ExperimentParams, ExperimentProfile, TrialJobStatistics, ProfileUpdateType, NNIManagerStatus, ExperimentStatus, ExperimentStartUpMode };