restValidationSchemas.ts 9.73 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
/**
 * 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';

const joi = require('joi');

export namespace ValidationSchemas {
    export const SETCLUSTERMETADATA = {
        body: {
            machine_list: joi.array().items(joi.object({
                username: joi.string().required(),
                ip: joi.string().ip().required(),
                port: joi.number().min(1).max(65535).required(),
SparkSnail's avatar
SparkSnail committed
31
                passwd: joi.string(),
32
                sshKeyPath: joi.string(),
33
                passphrase: joi.string(),
34
35
36
                gpuIndices: joi.string(),
                maxTrialNumPerGpu: joi.number(),
                useActiveGpu: joi.boolean()
37
            })),
38
            local_config: joi.object({
39
40
41
                gpuIndices: joi.string(),
                maxTrialNumPerGpu: joi.number(),
                useActiveGpu: joi.boolean()
42
            }),
43
            trial_config: joi.object({
44
                image: joi.string().min(1),
45
                codeDir: joi.string().min(1).required(),
46
47
48
49
                dataDir: joi.string(),
                outputDir: joi.string(),
                cpuNum: joi.number().min(1),
                memoryMB: joi.number().min(100),
50
51
                gpuNum: joi.number().min(0),
                command: joi.string().min(1),
52
                virtualCluster: joi.string(),
53
                shmMB: joi.number(),
54
                authFile: joi.string(),
55
                nasMode: joi.string().valid('classic_mode', 'enas_mode', 'oneshot_mode', 'darts_mode'),
56
57
58
59
60
                portList: joi.array().items(joi.object({
                    label: joi.string().required(),
                    beginAt: joi.number().required(),
                    portNumber: joi.number().required(),
                })),
61
62
63
                worker: joi.object({
                    replicas: joi.number().min(1).required(),
                    image: joi.string().min(1),
64
                    privateRegistryAuthPath: joi.string().min(1),
65
66
67
68
69
70
71
72
73
                    outputDir: joi.string(),
                    cpuNum: joi.number().min(1),
                    memoryMB: joi.number().min(100),
                    gpuNum: joi.number().min(0).required(),
                    command: joi.string().min(1).required()
                }),
                ps: joi.object({
                        replicas: joi.number().min(1).required(),
                        image: joi.string().min(1),
74
                        privateRegistryAuthPath: joi.string().min(1),
75
76
77
78
79
                        outputDir: joi.string(),
                        cpuNum: joi.number().min(1),
                        memoryMB: joi.number().min(100),
                        gpuNum: joi.number().min(0).required(),
                        command: joi.string().min(1).required()
80
81
82
83
                }),
                master: joi.object({
                    replicas: joi.number().min(1).required(),
                    image: joi.string().min(1),
84
                    privateRegistryAuthPath: joi.string().min(1),
85
86
87
88
89
                    outputDir: joi.string(),
                    cpuNum: joi.number().min(1),
                    memoryMB: joi.number().min(100),
                    gpuNum: joi.number().min(0).required(),
                    command: joi.string().min(1).required()
90
91
92
93
94
                }),
                taskRoles: joi.array({
                    name: joi.string().min(1),
                    taskNum: joi.number().min(1).required(),
                    image: joi.string().min(1),
95
                    privateRegistryAuthPath: joi.string().min(1),
96
97
98
                    outputDir: joi.string(),
                    cpuNum: joi.number().min(1),
                    memoryMB: joi.number().min(100),
99
                    shmMB: joi.number(),
100
101
102
103
104
105
                    gpuNum: joi.number().min(0).required(),
                    command: joi.string().min(1).required(),
                    frameworkAttemptCompletionPolicy: joi.object({
                        minFailedTaskCount: joi.number(),
                        minSucceededTaskCount: joi.number()
                    })
106
                })
107
108
109
            }),
            pai_config: joi.object({
                userName: joi.string().min(1).required(),
110
111
                passWord: joi.string().min(1),
                token: joi.string().min(1),
112
                host: joi.string().min(1).required()
113
114
115
            }),
            kubeflow_config: joi.object({
                operator: joi.string().min(1).required(),
116
                storage: joi.string().min(1),
117
                apiVersion: joi.string().min(1),
118
119
120
                nfs: joi.object({
                    server: joi.string().min(1).required(),
                    path: joi.string().min(1).required()
SparkSnail's avatar
SparkSnail committed
121
122
123
124
125
126
127
                }),
                keyVault: joi.object({
                    vaultName: joi.string().regex(/^([0-9]|[a-z]|[A-Z]|-){1,127}$/),
                    name: joi.string().regex(/^([0-9]|[a-z]|[A-Z]|-){1,127}$/)
                }),
                azureStorage: joi.object({
                    accountName: joi.string().regex(/^([0-9]|[a-z]|[A-Z]|-){3,31}$/),
128
                    azureShare: joi.string().regex(/^([0-9]|[a-z]|[A-Z]|-){3,63}$/)
129
130
                }),
                uploadRetryCount: joi.number().min(1)
131
132
133
            }),
            frameworkcontroller_config: joi.object({
                storage: joi.string().min(1),
134
                serviceAccountName: joi.string().min(1),
135
136
137
138
139
140
141
142
143
144
                nfs: joi.object({
                    server: joi.string().min(1).required(),
                    path: joi.string().min(1).required()
                }),
                keyVault: joi.object({
                    vaultName: joi.string().regex(/^([0-9]|[a-z]|[A-Z]|-){1,127}$/),
                    name: joi.string().regex(/^([0-9]|[a-z]|[A-Z]|-){1,127}$/)
                }),
                azureStorage: joi.object({
                    accountName: joi.string().regex(/^([0-9]|[a-z]|[A-Z]|-){3,31}$/),
SparkSnail's avatar
SparkSnail committed
145
                    azureShare: joi.string().regex(/^([0-9]|[a-z]|[A-Z]|-){3,63}$/)
146
147
                }),
                uploadRetryCount: joi.number().min(1)
148
149
            }),
            nni_manager_ip: joi.object({
150
                nniManagerIp: joi.string().min(1)
151
152
153
154
155
156
            })
        }
    };
    export const STARTEXPERIMENT = {
        body: {
            experimentName: joi.string().required(),
157
            description: joi.string(),
158
159
160
            authorName: joi.string(),
            maxTrialNum: joi.number().min(0).required(),
            trialConcurrency: joi.number().min(0).required(),
161
            trainingServicePlatform: joi.string(),
162
163
            searchSpace: joi.string().required(),
            maxExecDuration: joi.number().min(0).required(),
chicm-ms's avatar
chicm-ms committed
164
            multiPhase: joi.boolean(),
chicm-ms's avatar
chicm-ms committed
165
            multiThread: joi.boolean(),
166
            versionCheck: joi.boolean(),
SparkSnail's avatar
SparkSnail committed
167
            logCollection: joi.string(),
QuanluZhang's avatar
QuanluZhang committed
168
            advisor: joi.object({
Shufan Huang's avatar
Shufan Huang committed
169
                builtinAdvisorName: joi.string().valid('Hyperband', 'BOHB'),
QuanluZhang's avatar
QuanluZhang committed
170
171
172
                codeDir: joi.string(),
                classFileName: joi.string(),
                className: joi.string(),
chicm-ms's avatar
chicm-ms committed
173
                classArgs: joi.any(),
174
175
                checkpointDir: joi.string().allow(''),
                gpuIndices: joi.string()
QuanluZhang's avatar
QuanluZhang committed
176
            }),
177
            tuner: joi.object({
178
                builtinTunerName: joi.string().valid('TPE', 'Random', 'Anneal', 'Evolution', 'SMAC', 'BatchTuner', 'GridSearch', 'NetworkMorphism', 'MetisTuner', 'GPTuner', 'PPOTuner'),
179
180
181
182
                codeDir: joi.string(),
                classFileName: joi.string(),
                className: joi.string(),
                classArgs: joi.any(),
183
                checkpointDir: joi.string().allow(''),
184
185
                includeIntermediateResults: joi.boolean(),
                gpuIndices: joi.string()
QuanluZhang's avatar
QuanluZhang committed
186
            }),
187
            assessor: joi.object({
188
                builtinAssessorName: joi.string().valid('Medianstop', 'Curvefitting'),
189
190
191
192
                codeDir: joi.string(),
                classFileName: joi.string(),
                className: joi.string(),
                classArgs: joi.any(),
chicm-ms's avatar
chicm-ms committed
193
                checkpointDir: joi.string().allow('')
194
195
196
197
198
199
200
201
202
            }),
            clusterMetaData: joi.array().items(joi.object({
                key: joi.string(),
                value: joi.any()
            }))
        }
    };
    export const UPDATEEXPERIMENT = {
        query: {
QuanluZhang's avatar
QuanluZhang committed
203
            update_type: joi.string().required().valid('TRIAL_CONCURRENCY', 'MAX_EXEC_DURATION', 'SEARCH_SPACE', 'MAX_TRIAL_NUM')
204
205
206
207
        },
        body: {
            id: joi.string().required(),
            revision: joi.number().min(0).required(),
chicm-ms's avatar
chicm-ms committed
208
            params: joi.object(STARTEXPERIMENT.body),
209
210
            execDuration: joi.number().required(),
            startTime: joi.number(),
chicm-ms's avatar
chicm-ms committed
211
212
            endTime: joi.number(),
            logDir: joi.string(),
213
            nextSequenceId: joi.number()
214
215
216
        }
    };
}