Commit a4d62e95 authored by suiguoxin's avatar suiguoxin
Browse files

add get_experiment_id

parent d5e9a576
......@@ -26,7 +26,7 @@ import * as path from 'path';
import * as ts from 'tail-stream';
import * as tkill from 'tree-kill';
import { NNIError, NNIErrorNames } from '../../common/errors';
import { getInitTrialSequenceId } from '../../common/experimentStartupInfo';
import { getExperimentId, getInitTrialSequenceId } from '../../common/experimentStartupInfo';
import { getLogger, Logger } from '../../common/log';
import {
HostJobApplicationForm, HyperParameters, JobApplicationForm, TrainingService, TrialJobApplicationForm,
......@@ -126,6 +126,7 @@ class LocalTrainingService implements TrainingService {
private stopping: boolean;
private rootDir!: string;
private trialSequenceId: number;
private readonly experimentId! : string;
private gpuScheduler!: GPUScheduler;
private readonly occupiedGpuIndexNumMap: Map<number, number>;
private designatedGpuIndices!: Set<number>;
......@@ -145,6 +146,7 @@ class LocalTrainingService implements TrainingService {
this.stopping = false;
this.log = getLogger();
this.trialSequenceId = -1;
this.experimentId = getExperimentId();
this.jobStreamMap = new Map<string, ts.Stream>();
this.log.info('Construct local machine training service.');
this.occupiedGpuIndexNumMap = new Map<number, number>();
......@@ -400,6 +402,7 @@ class LocalTrainingService implements TrainingService {
resource: { gpuIndices: number[] }): { key: string; value: string }[] {
const envVariables: { key: string; value: string }[] = [
{ key: 'NNI_PLATFORM', value: 'local' },
{ key: 'NNI_EXP_ID', value: this.experimentId },
{ key: 'NNI_SYS_DIR', value: trialJobDetail.workingDirectory },
{ key: 'NNI_TRIAL_JOB_ID', value: trialJobDetail.id },
{ key: 'NNI_OUTPUT_DIR', value: trialJobDetail.workingDirectory },
......
......@@ -24,6 +24,7 @@ from collections import namedtuple
_trial_env_var_names = [
'NNI_PLATFORM',
'NNI_EXP_ID',
'NNI_TRIAL_JOB_ID',
'NNI_SYS_DIR',
'NNI_OUTPUT_DIR',
......
......@@ -94,9 +94,11 @@ def send_metric(string):
else:
subprocess.run(['touch', _metric_file.name], check = True)
def get_sequence_id():
return trial_env_vars.NNI_TRIAL_SEQ_ID
def get_experiment_id():
return trial_env_vars.NNI_EXP_ID
def get_trial_id():
return trial_env_vars.NNI_TRIAL_JOB_ID
def get_sequence_id():
return trial_env_vars.NNI_TRIAL_SEQ_ID
......@@ -25,12 +25,15 @@ import json_tricks
def get_next_parameter():
pass
def get_sequence_id():
def get_experiment_id():
pass
def get_trial_id():
pass
def get_sequence_id():
pass
def send_metric(string):
metric = json_tricks.loads(string)
if metric['type'] == 'FINAL':
......
......@@ -30,14 +30,16 @@ __all__ = [
'get_current_parameter',
'report_intermediate_result',
'report_final_result',
'get_experiment_id',
'get_trial_id',
'get_sequence_id',
'get_trial_id'
]
_params = None
_sequence_id = platform.get_sequence_id()
_experiment_id = platform.get_experiment_id()
_trial_id = platform.get_trial_id()
_sequence_id = platform.get_sequence_id()
def get_next_parameter():
......@@ -54,12 +56,15 @@ def get_current_parameter(tag):
return None
return _params['parameters'][tag]
def get_sequence_id():
return _sequence_id
def get_experiment_id():
return _experiment_id
def get_trial_id():
return _trial_id
def get_sequence_id():
return _sequence_id
_intermediate_seq = 0
def report_intermediate_result(metric):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment