Skip to content
This repository has been archived by the owner on Sep 18, 2024. It is now read-only.

fix trial status not correct when trial is early stoped #4005

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion ts/nni_manager/core/nnimanager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -681,7 +681,12 @@ class NNIManager implements Manager {
this.currSubmittedTrialNum++;
this.log.info('submitTrialJob: form:', form);
const trialJobDetail: TrialJobDetail = await this.trainingService.submitTrialJob(form);
setTimeout(async () => this.stopTrialJobIfOverMaxDurationTimer(trialJobDetail.id), 1000 * this.maxTrialDuration);
if(this.maxTrialDuration !== Infinity){
// Fix timeout warning : Infinity does not fit into a 32-bit signed integer(2147483647).
const duration = (this.maxTrialDuration * 1000) > 2147483647 ? 2147483647 : this.maxTrialDuration * 1000;
setTimeout(async () => this.stopTrialJobIfOverMaxDurationTimer(trialJobDetail.id), duration);
}

const Snapshot: TrialJobDetail = Object.assign({}, trialJobDetail);
await this.storeExperimentProfile();
this.trialJobs.set(trialJobDetail.id, Snapshot);
Expand Down
6 changes: 3 additions & 3 deletions ts/nni_manager/training_service/local/localTrainingService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -237,8 +237,10 @@ class LocalTrainingService implements TrainingService {
return Promise.resolve();
}
tkill(trialJob.pid, 'SIGTERM');
this.setTrialJobStatus(trialJob, getJobCancelStatus(isEarlyStopped));

const startTime = Date.now();
while(await isAlive(trialJob.pid)) {
while(await isAlive(trialJob.pid)) {
if (Date.now() - startTime > 4999) {
tkill(trialJob.pid, 'SIGKILL', (err) => {
if (err) {
Expand All @@ -250,8 +252,6 @@ class LocalTrainingService implements TrainingService {
await delay(500);
}

this.setTrialJobStatus(trialJob, getJobCancelStatus(isEarlyStopped));

return Promise.resolve();
}

Expand Down