Commit 150ee83a authored by XupuWang's avatar XupuWang Committed by Yan Ni
Browse files

fix negative time number in local mode when trial time is short (#1185)

* fix negative time number in local mode when trial time is short

* fix bug of duration<0

* fix windows version and readme

* change tab

* change line
parent 83fae834
...@@ -144,7 +144,7 @@ export NNI_TRIAL_SEQ_ID=1 ...@@ -144,7 +144,7 @@ export NNI_TRIAL_SEQ_ID=1
export MULTI_PHASE=false export MULTI_PHASE=false
export CUDA_VISIBLE_DEVICES= export CUDA_VISIBLE_DEVICES=
eval python3 mnist.py 2>/home/user_name/nni/experiments/$experiment_id$/trials/$trial_id$/stderr eval python3 mnist.py 2>/home/user_name/nni/experiments/$experiment_id$/trials/$trial_id$/stderr
echo $? `date +%s000` >/home/user_name/nni/experiments/$experiment_id$/trials/$trial_id$/.nni/state echo $? `date +%s%3N` >/home/user_name/nni/experiments/$experiment_id$/trials/$trial_id$/.nni/state
``` ```
### Other Modes ### Other Modes
......
...@@ -149,7 +149,7 @@ export NNI_TRIAL_SEQ_ID=1 ...@@ -149,7 +149,7 @@ export NNI_TRIAL_SEQ_ID=1
export MULTI_PHASE=false export MULTI_PHASE=false
export CUDA_VISIBLE_DEVICES= export CUDA_VISIBLE_DEVICES=
eval python3 mnist.py 2>/home/user_name/nni/experiments/$experiment_id$/trials/$trial_id$/stderr eval python3 mnist.py 2>/home/user_name/nni/experiments/$experiment_id$/trials/$trial_id$/stderr
echo $? `date +%s000` >/home/user_name/nni/experiments/$experiment_id$/trials/$trial_id$/.nni/state echo $? `date +%s%3N` >/home/user_name/nni/experiments/$experiment_id$/trials/$trial_id$/.nni/state
``` ```
### 其它模式 ### 其它模式
...@@ -166,4 +166,4 @@ echo $? `date +%s000` >/home/user_name/nni/experiments/$experiment_id$/trials/$t ...@@ -166,4 +166,4 @@ echo $? `date +%s000` >/home/user_name/nni/experiments/$experiment_id$/trials/$t
* [为 CIFAR 10 分类找到最佳的 optimizer](Cifar10Examples.md) * [为 CIFAR 10 分类找到最佳的 optimizer](Cifar10Examples.md)
* [如何在 NNI 调优 SciKit-learn 的参数](SklearnExamples.md) * [如何在 NNI 调优 SciKit-learn 的参数](SklearnExamples.md)
* [在阅读理解上使用自动模型架构搜索。](SquadEvolutionExamples.md) * [在阅读理解上使用自动模型架构搜索。](SquadEvolutionExamples.md)
* [如何在 NNI 上调优 GBDT](GbdtExample.md) * [如何在 NNI 上调优 GBDT](GbdtExample.md)
\ No newline at end of file
...@@ -507,12 +507,12 @@ class LocalTrainingService implements TrainingService { ...@@ -507,12 +507,12 @@ class LocalTrainingService implements TrainingService {
script.push( script.push(
`cmd /c ${localTrailConfig.command} 2>${path.join(workingDirectory, 'stderr')}`, `cmd /c ${localTrailConfig.command} 2>${path.join(workingDirectory, 'stderr')}`,
`$NOW_DATE = [int64](([datetime]::UtcNow)-(get-date "1/1/1970")).TotalSeconds`, `$NOW_DATE = [int64](([datetime]::UtcNow)-(get-date "1/1/1970")).TotalSeconds`,
`$NOW_DATE = "$NOW_DATE" + "000"`, `$NOW_DATE = "$NOW_DATE" + (Get-Date -Format fff).ToString()`,
`Write $LASTEXITCODE " " $NOW_DATE | Out-File ${path.join(workingDirectory, '.nni', 'state')} -NoNewline -encoding utf8`); `Write $LASTEXITCODE " " $NOW_DATE | Out-File ${path.join(workingDirectory, '.nni', 'state')} -NoNewline -encoding utf8`);
} else { } else {
script.push( script.push(
`eval ${localTrailConfig.command} 2>${path.join(workingDirectory, 'stderr')}`, `eval ${localTrailConfig.command} 2>${path.join(workingDirectory, 'stderr')}`,
`echo $? \`date +%s000\` >${path.join(workingDirectory, '.nni', 'state')}`); `echo $? \`date +%s%3N\` >${path.join(workingDirectory, '.nni', 'state')}`);
} }
return script; return script;
......
...@@ -72,8 +72,15 @@ class SuccessTable extends React.Component<SuccessTableProps, {}> { ...@@ -72,8 +72,15 @@ class SuccessTable extends React.Component<SuccessTableProps, {}> {
sorter: (a: TableObj, b: TableObj) => (a.duration as number) - (b.duration as number), sorter: (a: TableObj, b: TableObj) => (a.duration as number) - (b.duration as number),
render: (text: string, record: TableObj) => { render: (text: string, record: TableObj) => {
let duration; let duration;
if (record.duration) { if (record.duration !== undefined) {
duration = convertDuration(record.duration); // duration is nagative number(-1) & 0-1
if (record.duration > 0 && record.duration < 1 || record.duration < 0) {
duration = `${record.duration}s`;
} else {
duration = convertDuration(record.duration);
}
} else {
duration = 0;
} }
return ( return (
<div className="durationsty"><div>{duration}</div></div> <div className="durationsty"><div>{duration}</div></div>
......
...@@ -264,7 +264,8 @@ class TableList extends React.Component<TableListProps, TableListState> { ...@@ -264,7 +264,8 @@ class TableList extends React.Component<TableListProps, TableListState> {
render: (text: string, record: TableObj) => { render: (text: string, record: TableObj) => {
let duration; let duration;
if (record.duration !== undefined) { if (record.duration !== undefined) {
if (record.duration > 0 && record.duration < 1) { // duration is nagative number(-1) & 0-1
if (record.duration > 0 && record.duration < 1 || record.duration < 0) {
duration = `${record.duration}s`; duration = `${record.duration}s`;
} else { } else {
duration = convertDuration(record.duration); duration = convertDuration(record.duration);
......
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