Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
nni
Commits
01385bb0
"git@developer.sourcefind.cn:OpenDAS/nni.git" did not exist on "6ef6511736ccac0bce0f459d9c436b079174ed0d"
Unverified
Commit
01385bb0
authored
Dec 31, 2019
by
SparkSnail
Committed by
GitHub
Dec 31, 2019
Browse files
Fix pai http format error, add protocol (#1898)
parent
faca02c3
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
25 additions
and
14 deletions
+25
-14
src/nni_manager/training_service/pai/paiJobInfoCollector.ts
src/nni_manager/training_service/pai/paiJobInfoCollector.ts
+10
-6
src/nni_manager/training_service/pai/paiK8S/paiK8STrainingService.ts
...ager/training_service/pai/paiK8S/paiK8STrainingService.ts
+1
-1
src/nni_manager/training_service/pai/paiTrainingService.ts
src/nni_manager/training_service/pai/paiTrainingService.ts
+11
-6
src/nni_manager/training_service/pai/paiYarn/paiYarnTrainingService.ts
...er/training_service/pai/paiYarn/paiYarnTrainingService.ts
+3
-1
No files found.
src/nni_manager/training_service/pai/paiJobInfoCollector.ts
View file @
01385bb0
...
...
@@ -25,7 +25,7 @@ export class PAIJobInfoCollector {
this
.
finalStatuses
=
[
'
SUCCEEDED
'
,
'
FAILED
'
,
'
USER_CANCELED
'
,
'
SYS_CANCELED
'
,
'
EARLY_STOPPED
'
];
}
public
async
retrieveTrialStatus
(
token
?
:
string
,
paiBaseClusterConfig
?:
PAIClusterConfig
):
Promise
<
void
>
{
public
async
retrieveTrialStatus
(
protocol
:
string
,
token
?
:
string
,
paiBaseClusterConfig
?:
PAIClusterConfig
):
Promise
<
void
>
{
if
(
paiBaseClusterConfig
===
undefined
||
token
===
undefined
)
{
return
Promise
.
resolve
();
}
...
...
@@ -35,13 +35,13 @@ export class PAIJobInfoCollector {
if
(
paiTrialJob
===
undefined
)
{
throw
new
NNIError
(
NNIErrorNames
.
NOT_FOUND
,
`trial job id
${
trialJobId
}
not found`
);
}
updatePaiTrialJobs
.
push
(
this
.
getSinglePAITrialJobInfo
(
paiTrialJob
,
token
,
paiBaseClusterConfig
));
updatePaiTrialJobs
.
push
(
this
.
getSinglePAITrialJobInfo
(
protocol
,
paiTrialJob
,
token
,
paiBaseClusterConfig
));
}
await
Promise
.
all
(
updatePaiTrialJobs
);
}
private
getSinglePAITrialJobInfo
(
paiTrialJob
:
PAITrialJobDetail
,
paiToken
:
string
,
paiClusterConfig
:
PAIClusterConfig
):
Promise
<
void
>
{
private
getSinglePAITrialJobInfo
(
protocol
:
string
,
paiTrialJob
:
PAITrialJobDetail
,
paiToken
:
string
,
paiClusterConfig
:
PAIClusterConfig
):
Promise
<
void
>
{
const
deferred
:
Deferred
<
void
>
=
new
Deferred
<
void
>
();
if
(
!
this
.
statusesNeedToCheck
.
includes
(
paiTrialJob
.
status
))
{
deferred
.
resolve
();
...
...
@@ -52,7 +52,7 @@ export class PAIJobInfoCollector {
// Rest call to get PAI job info and update status
// Refer https://github.com/Microsoft/pai/blob/master/docs/rest-server/API.md for more detail about PAI Rest API
const
getJobInfoRequest
:
request
.
Options
=
{
uri
:
`
${
paiClusterConfig
.
host
}
/rest-server/api/v1/user/
${
paiClusterConfig
.
userName
}
/jobs/
${
paiTrialJob
.
paiJobName
}
`
,
uri
:
`
${
protocol
}
://
${
paiClusterConfig
.
host
}
/rest-server/api/v1/user/
${
paiClusterConfig
.
userName
}
/jobs/
${
paiTrialJob
.
paiJobName
}
`
,
method
:
'
GET
'
,
json
:
true
,
headers
:
{
...
...
@@ -81,7 +81,11 @@ export class PAIJobInfoCollector {
paiTrialJob
.
startTime
=
response
.
body
.
jobStatus
.
appLaunchedTime
;
}
if
(
paiTrialJob
.
url
===
undefined
)
{
paiTrialJob
.
url
=
response
.
body
.
jobStatus
.
appTrackingUrl
;
if
(
response
.
body
.
jobStatus
.
appTrackingUrl
)
{
paiTrialJob
.
url
=
response
.
body
.
jobStatus
.
appTrackingUrl
;
}
else
{
paiTrialJob
.
url
=
paiTrialJob
.
logPath
;
}
}
break
;
case
'
SUCCEEDED
'
:
...
...
@@ -114,7 +118,7 @@ export class PAIJobInfoCollector {
}
// Set pai trial job's url to WebHDFS output path
if
(
paiTrialJob
.
logPath
!==
undefined
)
{
if
(
paiTrialJob
.
url
)
{
if
(
paiTrialJob
.
url
&&
paiTrialJob
.
url
!==
paiTrialJob
.
logPath
)
{
paiTrialJob
.
url
+=
`,
${
paiTrialJob
.
logPath
}
`
;
}
else
{
paiTrialJob
.
url
=
`
${
paiTrialJob
.
logPath
}
`
;
...
...
src/nni_manager/training_service/pai/paiK8S/paiK8STrainingService.ts
View file @
01385bb0
...
...
@@ -258,7 +258,7 @@ class PAIK8STrainingService extends PAITrainingService {
// Step 3. Submit PAI job via Rest call
// Refer https://github.com/Microsoft/pai/blob/master/docs/rest-server/API.md for more detail about PAI Rest API
const
submitJobRequest
:
request
.
Options
=
{
uri
:
`
${
this
.
paiClusterConfig
.
host
}
/rest-server/api/v2/jobs`
,
uri
:
`
${
this
.
protocol
}
://
${
this
.
paiClusterConfig
.
host
}
/rest-server/api/v2/jobs`
,
method
:
'
POST
'
,
body
:
paiJobConfig
,
headers
:
{
...
...
src/nni_manager/training_service/pai/paiTrainingService.ts
View file @
01385bb0
...
...
@@ -52,6 +52,7 @@ abstract class PAITrainingService implements TrainingService {
protected
authFileHdfsPath
:
string
|
undefined
=
undefined
;
protected
portList
?:
string
|
undefined
;
protected
paiJobRestServer
?:
PAIJobRestServer
;
protected
protocol
:
string
=
'
http
'
;
constructor
()
{
this
.
log
=
getLogger
();
...
...
@@ -165,7 +166,7 @@ abstract class PAITrainingService implements TrainingService {
}
const
stopJobRequest
:
request
.
Options
=
{
uri
:
`
${
this
.
paiClusterConfig
.
host
}
/rest-server/api/v1/user/
${
this
.
paiClusterConfig
.
userName
}
\
uri
:
`
${
this
.
protocol
}
://
${
this
.
paiClusterConfig
.
host
}
/rest-server/api/v1/user/
${
this
.
paiClusterConfig
.
userName
}
\
/jobs/
${
trialJobDetail
.
paiJobName
}
/executionType`
,
method
:
'
PUT
'
,
json
:
true
,
...
...
@@ -219,10 +220,14 @@ abstract class PAITrainingService implements TrainingService {
protected
formatPAIHost
(
host
:
string
):
string
{
// If users' host start with 'http://' or 'https://', use the original host,
// or format to 'http//${host}'
if
(
host
.
startsWith
(
'
http://
'
)
||
host
.
startsWith
(
'
https://
'
))
{
return
host
;
if
(
host
.
startsWith
(
'
http://
'
))
{
this
.
protocol
=
'
http
'
;
return
host
.
replace
(
'
http://
'
,
''
);
}
else
if
(
host
.
startsWith
(
'
https://
'
))
{
this
.
protocol
=
'
https
'
;
return
host
.
replace
(
'
https://
'
,
''
);
}
else
{
return
`http://
${
host
}
`
;
return
host
;
}
}
...
...
@@ -239,7 +244,7 @@ abstract class PAITrainingService implements TrainingService {
}
}
}
await
this
.
paiJobCollector
.
retrieveTrialStatus
(
this
.
paiToken
,
this
.
paiClusterConfig
);
await
this
.
paiJobCollector
.
retrieveTrialStatus
(
this
.
protocol
,
this
.
paiToken
,
this
.
paiClusterConfig
);
if
(
this
.
paiJobRestServer
===
undefined
)
{
throw
new
Error
(
'
paiBaseJobRestServer not implemented!
'
);
}
...
...
@@ -269,7 +274,7 @@ abstract class PAITrainingService implements TrainingService {
}
const
authenticationReq
:
request
.
Options
=
{
uri
:
`
${
this
.
paiClusterConfig
.
host
}
/rest-server/api/v1/token`
,
uri
:
`
${
this
.
protocol
}
://
${
this
.
paiClusterConfig
.
host
}
/rest-server/api/v1/token`
,
method
:
'
POST
'
,
json
:
true
,
body
:
{
...
...
src/nni_manager/training_service/pai/paiYarn/paiYarnTrainingService.ts
View file @
01385bb0
...
...
@@ -91,6 +91,7 @@ class PAIYarnTrainingService extends PAITrainingService {
case
TrialConfigMetadataKey
.
PAI_YARN_CLUSTER_CONFIG
:
this
.
paiJobRestServer
=
new
PAIJobRestServer
(
component
.
get
(
PAIYarnTrainingService
));
this
.
paiClusterConfig
=
<
PAIClusterConfig
>
JSON
.
parse
(
value
);
this
.
paiClusterConfig
.
host
=
this
.
formatPAIHost
(
this
.
paiClusterConfig
.
host
);
this
.
hdfsClient
=
WebHDFS
.
createClient
({
user
:
this
.
paiClusterConfig
.
userName
,
...
...
@@ -98,6 +99,7 @@ class PAIYarnTrainingService extends PAITrainingService {
port
:
80
,
path
:
'
/webhdfs/api/v1
'
,
host
:
this
.
paiClusterConfig
.
host
});
this
.
paiClusterConfig
.
host
=
this
.
formatPAIHost
(
this
.
paiClusterConfig
.
host
);
if
(
this
.
paiClusterConfig
.
passWord
)
{
...
...
@@ -272,7 +274,7 @@ class PAIYarnTrainingService extends PAITrainingService {
// Step 3. Submit PAI job via Rest call
// Refer https://github.com/Microsoft/pai/blob/master/docs/rest-server/API.md for more detail about PAI Rest API
const
submitJobRequest
:
request
.
Options
=
{
uri
:
`
${
this
.
paiClusterConfig
.
host
}
/rest-server/api/v1/user/
${
this
.
paiClusterConfig
.
userName
}
/jobs`
,
uri
:
`
${
this
.
protocol
}
://
${
this
.
paiClusterConfig
.
host
}
/rest-server/api/v1/user/
${
this
.
paiClusterConfig
.
userName
}
/jobs`
,
method
:
'
POST
'
,
json
:
true
,
body
:
paiJobConfig
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment