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
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 {
...
@@ -25,7 +25,7 @@ export class PAIJobInfoCollector {
this
.
finalStatuses
=
[
'
SUCCEEDED
'
,
'
FAILED
'
,
'
USER_CANCELED
'
,
'
SYS_CANCELED
'
,
'
EARLY_STOPPED
'
];
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
)
{
if
(
paiBaseClusterConfig
===
undefined
||
token
===
undefined
)
{
return
Promise
.
resolve
();
return
Promise
.
resolve
();
}
}
...
@@ -35,13 +35,13 @@ export class PAIJobInfoCollector {
...
@@ -35,13 +35,13 @@ export class PAIJobInfoCollector {
if
(
paiTrialJob
===
undefined
)
{
if
(
paiTrialJob
===
undefined
)
{
throw
new
NNIError
(
NNIErrorNames
.
NOT_FOUND
,
`trial job id
${
trialJobId
}
not found`
);
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
);
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
>
();
const
deferred
:
Deferred
<
void
>
=
new
Deferred
<
void
>
();
if
(
!
this
.
statusesNeedToCheck
.
includes
(
paiTrialJob
.
status
))
{
if
(
!
this
.
statusesNeedToCheck
.
includes
(
paiTrialJob
.
status
))
{
deferred
.
resolve
();
deferred
.
resolve
();
...
@@ -52,7 +52,7 @@ export class PAIJobInfoCollector {
...
@@ -52,7 +52,7 @@ export class PAIJobInfoCollector {
// Rest call to get PAI job info and update status
// 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
// Refer https://github.com/Microsoft/pai/blob/master/docs/rest-server/API.md for more detail about PAI Rest API
const
getJobInfoRequest
:
request
.
Options
=
{
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
'
,
method
:
'
GET
'
,
json
:
true
,
json
:
true
,
headers
:
{
headers
:
{
...
@@ -81,7 +81,11 @@ export class PAIJobInfoCollector {
...
@@ -81,7 +81,11 @@ export class PAIJobInfoCollector {
paiTrialJob
.
startTime
=
response
.
body
.
jobStatus
.
appLaunchedTime
;
paiTrialJob
.
startTime
=
response
.
body
.
jobStatus
.
appLaunchedTime
;
}
}
if
(
paiTrialJob
.
url
===
undefined
)
{
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
;
break
;
case
'
SUCCEEDED
'
:
case
'
SUCCEEDED
'
:
...
@@ -114,7 +118,7 @@ export class PAIJobInfoCollector {
...
@@ -114,7 +118,7 @@ export class PAIJobInfoCollector {
}
}
// Set pai trial job's url to WebHDFS output path
// Set pai trial job's url to WebHDFS output path
if
(
paiTrialJob
.
logPath
!==
undefined
)
{
if
(
paiTrialJob
.
logPath
!==
undefined
)
{
if
(
paiTrialJob
.
url
)
{
if
(
paiTrialJob
.
url
&&
paiTrialJob
.
url
!==
paiTrialJob
.
logPath
)
{
paiTrialJob
.
url
+=
`,
${
paiTrialJob
.
logPath
}
`
;
paiTrialJob
.
url
+=
`,
${
paiTrialJob
.
logPath
}
`
;
}
else
{
}
else
{
paiTrialJob
.
url
=
`
${
paiTrialJob
.
logPath
}
`
;
paiTrialJob
.
url
=
`
${
paiTrialJob
.
logPath
}
`
;
...
...
src/nni_manager/training_service/pai/paiK8S/paiK8STrainingService.ts
View file @
01385bb0
...
@@ -258,7 +258,7 @@ class PAIK8STrainingService extends PAITrainingService {
...
@@ -258,7 +258,7 @@ class PAIK8STrainingService extends PAITrainingService {
// Step 3. Submit PAI job via Rest call
// 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
// Refer https://github.com/Microsoft/pai/blob/master/docs/rest-server/API.md for more detail about PAI Rest API
const
submitJobRequest
:
request
.
Options
=
{
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
'
,
method
:
'
POST
'
,
body
:
paiJobConfig
,
body
:
paiJobConfig
,
headers
:
{
headers
:
{
...
...
src/nni_manager/training_service/pai/paiTrainingService.ts
View file @
01385bb0
...
@@ -52,6 +52,7 @@ abstract class PAITrainingService implements TrainingService {
...
@@ -52,6 +52,7 @@ abstract class PAITrainingService implements TrainingService {
protected
authFileHdfsPath
:
string
|
undefined
=
undefined
;
protected
authFileHdfsPath
:
string
|
undefined
=
undefined
;
protected
portList
?:
string
|
undefined
;
protected
portList
?:
string
|
undefined
;
protected
paiJobRestServer
?:
PAIJobRestServer
;
protected
paiJobRestServer
?:
PAIJobRestServer
;
protected
protocol
:
string
=
'
http
'
;
constructor
()
{
constructor
()
{
this
.
log
=
getLogger
();
this
.
log
=
getLogger
();
...
@@ -165,7 +166,7 @@ abstract class PAITrainingService implements TrainingService {
...
@@ -165,7 +166,7 @@ abstract class PAITrainingService implements TrainingService {
}
}
const
stopJobRequest
:
request
.
Options
=
{
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`
,
/jobs/
${
trialJobDetail
.
paiJobName
}
/executionType`
,
method
:
'
PUT
'
,
method
:
'
PUT
'
,
json
:
true
,
json
:
true
,
...
@@ -219,10 +220,14 @@ abstract class PAITrainingService implements TrainingService {
...
@@ -219,10 +220,14 @@ abstract class PAITrainingService implements TrainingService {
protected
formatPAIHost
(
host
:
string
):
string
{
protected
formatPAIHost
(
host
:
string
):
string
{
// If users' host start with 'http://' or 'https://', use the original host,
// If users' host start with 'http://' or 'https://', use the original host,
// or format to 'http//${host}'
// or format to 'http//${host}'
if
(
host
.
startsWith
(
'
http://
'
)
||
host
.
startsWith
(
'
https://
'
))
{
if
(
host
.
startsWith
(
'
http://
'
))
{
return
host
;
this
.
protocol
=
'
http
'
;
return
host
.
replace
(
'
http://
'
,
''
);
}
else
if
(
host
.
startsWith
(
'
https://
'
))
{
this
.
protocol
=
'
https
'
;
return
host
.
replace
(
'
https://
'
,
''
);
}
else
{
}
else
{
return
`http://
${
host
}
`
;
return
host
;
}
}
}
}
...
@@ -239,7 +244,7 @@ abstract class PAITrainingService implements TrainingService {
...
@@ -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
)
{
if
(
this
.
paiJobRestServer
===
undefined
)
{
throw
new
Error
(
'
paiBaseJobRestServer not implemented!
'
);
throw
new
Error
(
'
paiBaseJobRestServer not implemented!
'
);
}
}
...
@@ -269,7 +274,7 @@ abstract class PAITrainingService implements TrainingService {
...
@@ -269,7 +274,7 @@ abstract class PAITrainingService implements TrainingService {
}
}
const
authenticationReq
:
request
.
Options
=
{
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
'
,
method
:
'
POST
'
,
json
:
true
,
json
:
true
,
body
:
{
body
:
{
...
...
src/nni_manager/training_service/pai/paiYarn/paiYarnTrainingService.ts
View file @
01385bb0
...
@@ -91,6 +91,7 @@ class PAIYarnTrainingService extends PAITrainingService {
...
@@ -91,6 +91,7 @@ class PAIYarnTrainingService extends PAITrainingService {
case
TrialConfigMetadataKey
.
PAI_YARN_CLUSTER_CONFIG
:
case
TrialConfigMetadataKey
.
PAI_YARN_CLUSTER_CONFIG
:
this
.
paiJobRestServer
=
new
PAIJobRestServer
(
component
.
get
(
PAIYarnTrainingService
));
this
.
paiJobRestServer
=
new
PAIJobRestServer
(
component
.
get
(
PAIYarnTrainingService
));
this
.
paiClusterConfig
=
<
PAIClusterConfig
>
JSON
.
parse
(
value
);
this
.
paiClusterConfig
=
<
PAIClusterConfig
>
JSON
.
parse
(
value
);
this
.
paiClusterConfig
.
host
=
this
.
formatPAIHost
(
this
.
paiClusterConfig
.
host
);
this
.
hdfsClient
=
WebHDFS
.
createClient
({
this
.
hdfsClient
=
WebHDFS
.
createClient
({
user
:
this
.
paiClusterConfig
.
userName
,
user
:
this
.
paiClusterConfig
.
userName
,
...
@@ -98,6 +99,7 @@ class PAIYarnTrainingService extends PAITrainingService {
...
@@ -98,6 +99,7 @@ class PAIYarnTrainingService extends PAITrainingService {
port
:
80
,
port
:
80
,
path
:
'
/webhdfs/api/v1
'
,
path
:
'
/webhdfs/api/v1
'
,
host
:
this
.
paiClusterConfig
.
host
host
:
this
.
paiClusterConfig
.
host
});
});
this
.
paiClusterConfig
.
host
=
this
.
formatPAIHost
(
this
.
paiClusterConfig
.
host
);
this
.
paiClusterConfig
.
host
=
this
.
formatPAIHost
(
this
.
paiClusterConfig
.
host
);
if
(
this
.
paiClusterConfig
.
passWord
)
{
if
(
this
.
paiClusterConfig
.
passWord
)
{
...
@@ -272,7 +274,7 @@ class PAIYarnTrainingService extends PAITrainingService {
...
@@ -272,7 +274,7 @@ class PAIYarnTrainingService extends PAITrainingService {
// Step 3. Submit PAI job via Rest call
// 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
// Refer https://github.com/Microsoft/pai/blob/master/docs/rest-server/API.md for more detail about PAI Rest API
const
submitJobRequest
:
request
.
Options
=
{
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
'
,
method
:
'
POST
'
,
json
:
true
,
json
:
true
,
body
:
paiJobConfig
,
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