Skip to content

Commit 6c7f440

Browse files
author
changfeng
committed
refactoring rest-server && model-hub && model-client
1 parent ad4dbb3 commit 6c7f440

File tree

183 files changed

+20717
-10275
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

183 files changed

+20717
-10275
lines changed

README_zh.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,10 @@ Web门户上也提供了Web UI进行集群的管理。
7878
## 系统结构
7979

8080
<p style="text-align: left;">
81-
<img src="./sysarch.png" title="System Architecture" alt="System Architecture" />
81+
<img src="./sysarch-zh.png" title="System Architecture" alt="System Architecture" />
8282
</p>
8383

84+
8485
系统的整体结构如上图所示。
8586
用户通过[Web门户](./webportal/README.md)提交了任务作业或集群状态监视的申请,该操作会调用[REST服务器](./rest-server/README.md)提供的API。
8687
第三方工具也可以直接调用REST服务器进行作业管理。收到API调用后,REST服务器与[FrameworkLauncher](./frameworklauncher/README.md)(简称Launcher)协同工作来进行作业管理。Launcher服务器处理来自REST服务器的请求,并将任务作业提交到Hadoop YARN。由YARN和[GPU强化](https://issues.apache.org/jira/browse/YARN-7481)调度的作业, 可以使用集群中的GPU资源进行深度学习运算。其他基于CPU的AI工作或者传统的大数据任务作业也可以在平台上运行,与那些基于GPU的作业共存。

frameworklauncher/README-zh.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
1717
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1818
19-
19+
2020
Copyright (c) Peking University 2018
2121
2222
The software is released under the Open-Intelligence Open Source License V1.0.
@@ -25,7 +25,7 @@
2525
Artificial Intelligence Technology Innovation Strategic Alliance (the AITISA).
2626
-->
2727

28-
# 微软FrameworkLauncher
28+
# FrameworkLauncher
2929

3030
搭建FrameworkLauncher(简称Launcher)是为了支持在 [YARN](http://hadoop.apache.org/) 容器内可以长期运行大规模服务,而无需更改该服务自身。 它还支持批量作业,如TensorFlow,CNTK等。
3131

frameworklauncher/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1818
-->
1919

20-
# Microsoft FrameworkLauncher
20+
# FrameworkLauncher
2121

2222
FrameworkLauncher (or Launcher for short) is built to enable running Large-Scale Long-Running Services inside [YARN](http://hadoop.apache.org/) Containers without making changes to the Services themselves. It also supports Batch Jobs, such as TensorFlow, CNTK, etc.
2323

model-client/command/commands/clone.js

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const fileUtil = require("../../utils/file");
1010
const lang = require("../../prototype/lang");
1111
const log = require("../../utils/log");
1212
const validate = require("../../utils/validate");
13-
const userInfo = require("../../lib/userInfo");
13+
const userLib = require("../../lib/user");
1414

1515
function isExist(dir,project_name){
1616
let project_path = path.join(dir,project_name);
@@ -34,7 +34,6 @@ function GetVersions(user,project,server){
3434
if(err){
3535
throw err;
3636
}
37-
3837

3938
if( body instanceof Buffer){
4039
body = body.toString();
@@ -48,6 +47,7 @@ function GetVersions(user,project,server){
4847
access_denied:false,
4948
versions:{}
5049
};
50+
5151
if( body.success == true){
5252
response.success = true;
5353
response.versions = body.versions;
@@ -60,7 +60,6 @@ function GetVersions(user,project,server){
6060
response.internal_error = true;
6161
}
6262
}
63-
6463

6564
return response;
6665
});
@@ -75,13 +74,11 @@ function clone(args,opt){
7574
let cwd = process.cwd();
7675

7776
let project_address = args[0];
78-
79-
console.log(project_address)
8077

8178
if(!validate.isValidateProjectAddress(project_address)){
8279
log.info(lang.New()
83-
.zh("[CLONE ERROR] - 项目地址格式不正确")
84-
.en("[CLONE ERROR] - Wrong form of repository address!"));
80+
.zh("项目地址格式不正确")
81+
.en("Wrong form of repository address!"));
8582

8683
log.info(lang.New()
8784
.zh("正确的格式是'http(s)://host/username/project_name.ms'")
@@ -120,7 +117,7 @@ function clone(args,opt){
120117
return false;
121118
}
122119

123-
let [err1,user_info] = yield userInfo.GetInfo(server.hostname,user);
120+
let [err1,user_info] = yield userLib.getInfo(server.hostname,user);
124121

125122
if(err1){
126123
throw err1;
@@ -139,19 +136,19 @@ function clone(args,opt){
139136
if(!response.success){
140137

141138
if(response.internal_error == true){
142-
log.info("[CLONE ERROR] - "+response.message);
139+
log.info(response.message);
140+
}else{
141+
log.info(lang.New().en(`Access denied,Please login again.`).zh("鉴权失败,请登录远程仓库"));
143142
}
144143

145-
log.info(lang.New().en(`[CLONE ERROR] - Access denied,Please login again.`).zh("[CLONE ERROR] - 鉴权失败,请登录远程仓库"));
146-
147144
return false;
148145

149146
}
150147

151148
if(response.versions.length == 0){
152149
log.info(lang.New()
153-
.en(`[CLONE ERROR] - Project "${project_name}" is not found at remote!`)
154-
.zh(`[CLONE ERROR] - 项目"${project_name}"不存在`))
150+
.en(`Project "${project_name}" is not found at remote!`)
151+
.zh(`项目"${project_name}"不存在`))
155152

156153
return false;
157154
}
@@ -170,8 +167,8 @@ function clone(args,opt){
170167
}
171168
if(!found){
172169
log.info(lang.New()
173-
.en(`[CLONE ERROR] - The version "${version}" of "${project_name}" is not found`)
174-
.zh(`[CLONE ERROR] - 未找到${version}版的${project_name}`));
170+
.en(`The version "${version}" of "${project_name}" is not found`)
171+
.zh(`未找到${version}版的${project_name}`));
175172

176173

177174
return false;

model-client/command/commands/init.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ function init(args,opt){
4545
break;
4646
}else{
4747
log.info(lang.New()
48-
.zh("[INIT ERROR] - 项目地址格式不正确")
49-
.en("[INIT ERROR] - Wrong form of repository address!"));
48+
.zh("项目地址格式不正确")
49+
.en("Wrong form of repository address!"));
5050

5151
log.info(lang.New()
5252
.zh("正确的格式是'http(s)://host/username/project_name.ms'")

model-client/command/commands/login.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22
const co = require("zco");
33
const Command = require("../../prototype/command");
44
const lang = require("../../prototype/lang");
5-
const login = require("../../lib/login");
6-
const userInfo = require("../../lib/userInfo");
5+
const userLib = require("../../lib/user")
76
const url = require("url");
87
const log = require('../../utils/log');
98

@@ -43,10 +42,10 @@ function Login (args,opt){
4342

4443
this.ctx.server = server;
4544

46-
let loginRes = yield login.login(user,pwd);
45+
let loginRes = yield userLib.login(user,pwd);
4746

4847
if(loginRes.success){
49-
yield userInfo.SetInfo(server.hostname,loginRes.token,user);
48+
yield userLib.setInfo(server.hostname,loginRes.token,user);
5049
log.info(lang.New().en(" Login successfully!").zh("登录成功"));
5150

5251
}else{

model-client/command/commands/touch.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ const Command = require("../../prototype/command");
88

99
const lang = require("../../prototype/lang");
1010

11-
12-
1311
function touch (args){
1412
return co.brief(function*(resume){
1513

model-client/command/commands/version.js

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ function create(cwd,args,opt){
1414
let version = args[1];
1515

1616
if (!version){
17-
log.info("[VERSION CREATE ERROR] - "+lang.New().en("Parameter 'version' is required!").zh("缺失参数'version'(版本号)"))
17+
log.info(lang.New().en("Parameter 'version' is required!").zh("缺失参数'version'(版本号)"))
1818
return null;
1919
}
2020

@@ -33,7 +33,7 @@ function create(cwd,args,opt){
3333
}
3434

3535
if(json.versions.includes(version)){
36-
log.info("[VERSION CREATE ERROR] "+lang.New().en(`Version "${version}" has already existed.`).zh(`版本"${version}"已经存在`));
36+
log.info(lang.New().en(`Version "${version}" has already existed.`).zh(`版本"${version}"已经存在`));
3737
return null;
3838
}
3939

@@ -83,7 +83,7 @@ function create(cwd,args,opt){
8383
yield fileUtil.copy(src_path,cwd,[path.join(src_path,"project.json")]);
8484
}
8585

86-
log.info("[VERSION CREATE] - "+lang.New().en(`Create new version "${version}" successfully!`).zh(`版本${version}创建成功`));
86+
log.info(lang.New().en(`Create new version "${version}" successfully!`).zh(`版本${version}创建成功`));
8787

8888
});
8989
}
@@ -92,8 +92,7 @@ function _switch(cwd,version){
9292
return co.brief(function*(resume){
9393
let [err,file] = yield fs.readFile(path.join(cwd,"project.json"),resume);
9494
if(err){
95-
log.info("[]VERSION SWITCH ERROR] - "+err.message);
96-
95+
log.info(lang.New().en("Failed to switch version,"+err.message).zh("切换版本失败,"+err.message));
9796
return false;
9897
}
9998
let json = JSON.parse(file);
@@ -102,20 +101,20 @@ function _switch(cwd,version){
102101
return null;
103102
}
104103
if(!json.versions.includes(version)){
105-
log.info("[VERSION SWITCH ERROR] - "+lang.New().en(`The version "${version}" has not existed!`).zh(`版本"${version}"不存在`));
104+
log.info(lang.New().en(`The version "${version}" has not existed!`).zh(`版本"${version}"不存在`));
106105

107106
return null;
108107
}
109108
let target_version_cache_path = path.join(cwd,".ms","v"+version);
110109

111110
if(!fs.existsSync(target_version_cache_path)){
112-
log.info("[VERSION SWITCH ERROR] - "+lang.New().en(`The version "${version}" has not existed!`).zh(`版本"${version}"不存在`));
111+
log.info(lang.New().en(`The version "${version}" has not existed!`).zh(`版本"${version}"不存在`));
113112

114113
return null;
115114
}
116115

117116
if(!fs.existsSync(path.join(target_version_cache_path,"project.json"))){
118-
log.info("[VERSION SWITCH ERROR] - "+lang.New().en("Missing 'project.json'.").zh("缺失'project.json'."));
117+
log.info(lang.New().en("Missing 'project.json'.").zh("缺失'project.json'."));
119118
return null;
120119
}
121120

@@ -128,7 +127,7 @@ function _switch(cwd,version){
128127

129128
if(err){
130129

131-
log.info("[VERSION SWITCH ERROR] - "+err.message);
130+
log.info(lang.New().en("Failed to switch version,"+err.message).zh("切换版本失败,"+err.message));
132131
return false;
133132

134133
}
@@ -142,14 +141,14 @@ function _switch(cwd,version){
142141
[err,file] = yield fs.readFile(path.join(cwd,"project.json"),resume);
143142

144143
if(err){
145-
log.info("[VERSION SWITCH ERROR] - "+err.message);
144+
log.info(lang.New().en("Failed to switch version,"+err.message).zh("切换版本失败,"+err.message));
146145
return false;
147146
}
148147

149148
json = JSON.parse(file);
150149

151150
if(false == json.synced){
152-
log.info("[VERSION SWITCH] - "+lang.New().en("Start to download data from remote repository server\n").zh("开始从远程仓库下载项目数据"));
151+
log.info(lang.New().en("Start to download data from remote repository server\n").zh("开始从远程仓库下载项目数据"));
153152
yield download.download();
154153
delete json.synced;
155154
[err] = yield fs.writeFile(path.join(cwd,"project.json"),JSON.stringify(json," ",2),resume);
@@ -158,7 +157,7 @@ function _switch(cwd,version){
158157
}
159158
}
160159

161-
log.info(lang.New().en("[VERSION SWITCH] - Successfully").zh("成功切换版本"));
160+
log.info(lang.New().en("Successfully").zh("成功切换版本"));
162161

163162
});
164163
}
@@ -167,7 +166,7 @@ function current(cwd){
167166
return co.brief(function*(resume){
168167
let [err,file] = yield fs.readFile(path.join(cwd,"project.json"),resume);
169168
if(err){
170-
console.log("[VERSION LIST ERROR] - "+err.message);
169+
log.info(lang.New().en("Failed to print current version,"+err.message).zh("打印当前版本号失败,"+err.message))
171170
return false;
172171
}
173172
let json = JSON.parse(file);
@@ -180,7 +179,8 @@ function list(cwd){
180179
return co.brief(function*(resume){
181180
let [err,file] = yield fs.readFile(path.join(cwd,"project.json"),resume);
182181
if(err){
183-
console.log("[VERSION LIST ERROR] - "+err.message);
182+
log.info(lang.New().en("Failed to list versions,"+err.message).zh("列出版本列表失败,"+err.message))
183+
184184
return false;
185185
}
186186
let json = JSON.parse(file);
@@ -209,21 +209,25 @@ function version(args,opt){
209209
yield current(cwd);
210210
return false;
211211
}
212+
212213
let sub_command = args[0];
213214

214215
if("create" == sub_command){
216+
215217
yield create(cwd,args,opt);
218+
216219
}else if("switch" == sub_command){
217-
if (!opt.v){
218-
log.info("[VERSION SWITCH ERROR] - "+lang.New().en("Parameter 'version' is required!").zh("缺少'版本号'参数"));
219220

220-
221+
if (!opt.v){
222+
log.info(lang.New().en("Parameter 'version' is required!").zh("缺少'版本号'参数"));
221223
}else{
222224
yield _switch(cwd,opt.v);
223225
}
224226

225227
}else if("list" == sub_command){
228+
226229
yield list(cwd,opt);
230+
227231
}else{
228232
log.info(lang.New().en(`Command "version ${sub_command}" is not found`).zh(`无此命令 "version ${sub_command}"`))
229233

@@ -234,6 +238,7 @@ function version(args,opt){
234238
}
235239

236240
let type = lang.New().en("About Project Management").zh("项目管理相关");
241+
237242
let note = lang.New().en("List,create,or switch versions.").zh("罗列,创建,或者切换版本");
238243

239244
const cmd = new Command("version",version,type);
@@ -248,7 +253,7 @@ cmd.usage("version switch -v 'version'",lang.New().en("Switch to target version.
248253

249254
cmd.usage("version list",lang.New().en("List all versions.").zh("列出所有的版本"));
250255

251-
cmd.usage("version",lang.New().en("Print the current versio.n").zh("打印出当前版本号"));
256+
cmd.usage("version",lang.New().en("Print the current version.").zh("打印出当前版本号"));
252257

253258
module.exports = cmd;
254259

model-client/command/index.js

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ const cmd_exit = require("./commands/exit");
2323
const cmd_lang = require("./commands/lang");
2424

2525

26-
const exist = require("./middlewares/exist")
27-
const notFound = require("./middlewares/not_found");
28-
const signed = require("./middlewares/signed");
26+
const exist = require("./middlewares/project_exist")
27+
const not_found = require("./middlewares/not_found");
28+
const check_login = require("./middlewares/check_login");
2929

3030
require("./setup").run();
3131

@@ -44,15 +44,13 @@ flow.use("touch",cmd_touch)//done
4444
flow.use("init",cmd_init);//done
4545
flow.use("login",cmd_login);//done
4646
flow.use("clone",cmd_clone);//done
47-
flow.use("pull",exist,signed,cmd_pull);//done
48-
flow.use("push",exist,signed,cmd_push);//done
47+
flow.use("pull",exist,check_login,cmd_pull);//done
48+
flow.use("push",exist,check_login,cmd_push);//done
4949
flow.use("version",exist,cmd_version);//done
50-
flow.use("convert",exist,signed,cmd_convert);//done
50+
flow.use("convert",exist,check_login,cmd_convert);//done
5151

5252

53-
54-
55-
flow.use(notFound);
53+
flow.use(not_found);
5654

5755

5856
co(function*(resume){

0 commit comments

Comments
 (0)