restValidationSchemas.ts 7.23 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
31
32
33
34
35
/**
 * 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(),
                passwd: joi.string().required(),
                sshKeyPath: joi.string(),
                passphrase: joi.string()
            })),
            trial_config: joi.object({
36
                image: joi.string().min(1),
37
                codeDir: joi.string().min(1).required(),
38
39
40
41
                dataDir: joi.string(),
                outputDir: joi.string(),
                cpuNum: joi.number().min(1),
                memoryMB: joi.number().min(100),
42
43
                gpuNum: joi.number().min(0),
                command: joi.string().min(1),
44
                virtualCluster: joi.string(),
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
                worker: joi.object({
                    replicas: joi.number().min(1).required(),
                    image: joi.string().min(1),
                    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),
                        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()
62
63
64
65
66
67
68
69
70
                }),
                master: joi.object({
                    replicas: joi.number().min(1).required(),
                    image: joi.string().min(1),
                    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()
71
                })
72
73
74
75
76
            }),
            pai_config: joi.object({
                userName: joi.string().min(1).required(),
                passWord: joi.string().min(1).required(),
                host: joi.string().min(1).required()
77
78
79
            }),
            kubeflow_config: joi.object({
                operator: joi.string().min(1).required(),
80
                storage: joi.string().min(1),
81
                apiVersion: joi.string().min(1),
82
83
84
                nfs: joi.object({
                    server: joi.string().min(1).required(),
                    path: joi.string().min(1).required()
SparkSnail's avatar
SparkSnail committed
85
86
87
88
89
90
91
92
93
                }),
                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}$/),
                    azureShare: joi.string().regex(/^([0-9]|[a-z]|[A-Z]|-){3,63}$/)
                })
94
95
96
            }),
            nni_manager_ip: joi.object({
                nniManagerIp: joi.string().min(1) 
97
98
99
100
101
102
            })
        }
    };
    export const STARTEXPERIMENT = {
        body: {
            experimentName: joi.string().required(),
103
            description: joi.string(),
104
105
106
            authorName: joi.string(),
            maxTrialNum: joi.number().min(0).required(),
            trialConcurrency: joi.number().min(0).required(),
107
            trainingServicePlatform: joi.string(),
108
109
            searchSpace: joi.string().required(),
            maxExecDuration: joi.number().min(0).required(),
chicm-ms's avatar
chicm-ms committed
110
            multiPhase: joi.boolean(),
chicm-ms's avatar
chicm-ms committed
111
            multiThread: joi.boolean(),
QuanluZhang's avatar
QuanluZhang committed
112
113
114
115
116
            advisor: joi.object({
                builtinAdvisorName: joi.string().valid('Hyperband'),
                codeDir: joi.string(),
                classFileName: joi.string(),
                className: joi.string(),
chicm-ms's avatar
chicm-ms committed
117
                classArgs: joi.any(),
QuanluZhang's avatar
QuanluZhang committed
118
                gpuNum: joi.number().min(0),
chicm-ms's avatar
chicm-ms committed
119
                checkpointDir: joi.string().allow('')
QuanluZhang's avatar
QuanluZhang committed
120
            }),
121
            tuner: joi.object({
Lee's avatar
Lee committed
122
                builtinTunerName: joi.string().valid('TPE', 'Random', 'Anneal', 'Evolution', 'SMAC', 'BatchTuner', 'GridSearch', 'NetworkMorphism'),
123
124
125
126
127
                codeDir: joi.string(),
                classFileName: joi.string(),
                className: joi.string(),
                classArgs: joi.any(),
                gpuNum: joi.number().min(0),
chicm-ms's avatar
chicm-ms committed
128
                checkpointDir: joi.string().allow('')
QuanluZhang's avatar
QuanluZhang committed
129
            }),
130
            assessor: joi.object({
131
                builtinAssessorName: joi.string().valid('Medianstop', 'Curvefitting'),
132
133
134
135
136
                codeDir: joi.string(),
                classFileName: joi.string(),
                className: joi.string(),
                classArgs: joi.any(),
                gpuNum: joi.number().min(0),
chicm-ms's avatar
chicm-ms committed
137
                checkpointDir: joi.string().allow('')
138
139
140
141
142
143
144
145
146
            }),
            clusterMetaData: joi.array().items(joi.object({
                key: joi.string(),
                value: joi.any()
            }))
        }
    };
    export const UPDATEEXPERIMENT = {
        query: {
QuanluZhang's avatar
QuanluZhang committed
147
            update_type: joi.string().required().valid('TRIAL_CONCURRENCY', 'MAX_EXEC_DURATION', 'SEARCH_SPACE', 'MAX_TRIAL_NUM')
148
149
150
151
        },
        body: {
            id: joi.string().required(),
            revision: joi.number().min(0).required(),
chicm-ms's avatar
chicm-ms committed
152
            params: joi.object(STARTEXPERIMENT.body),
153
154
            execDuration: joi.number().required(),
            startTime: joi.number(),
chicm-ms's avatar
chicm-ms committed
155
156
157
            endTime: joi.number(),
            logDir: joi.string(),
            maxSequenceId: joi.number()
158
159
160
161
162
163
164
165
166
167
168
169
170
        }
    };
    export const STARTTENSORBOARD = {
        query: {
            job_ids: joi.string().min(5).max(5).required()
        }
    };
    export const STOPTENSORBOARD = {
        query: {
            endpoint: joi.string().uri().required()
        }
    };
}