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
9dec51e2
Unverified
Commit
9dec51e2
authored
Nov 11, 2019
by
SparkSnail
Committed by
GitHub
Nov 11, 2019
Browse files
Support space in logDir (#1694)
parent
0168ff1c
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
21 deletions
+21
-21
src/nni_manager/common/experimentStartupInfo.ts
src/nni_manager/common/experimentStartupInfo.ts
+1
-1
src/nni_manager/training_service/common/util.ts
src/nni_manager/training_service/common/util.ts
+14
-14
src/nni_manager/training_service/local/localTrainingService.ts
...ni_manager/training_service/local/localTrainingService.ts
+6
-6
No files found.
src/nni_manager/common/experimentStartupInfo.ts
View file @
9dec51e2
...
@@ -43,7 +43,7 @@ class ExperimentStartupInfo {
...
@@ -43,7 +43,7 @@ class ExperimentStartupInfo {
this
.
initialized
=
true
;
this
.
initialized
=
true
;
if
(
logDir
!==
undefined
&&
logDir
.
length
>
0
)
{
if
(
logDir
!==
undefined
&&
logDir
.
length
>
0
)
{
this
.
logDir
=
path
.
join
(
logDir
,
getExperimentId
());
this
.
logDir
=
path
.
join
(
path
.
normalize
(
logDir
)
,
getExperimentId
());
}
else
{
}
else
{
this
.
logDir
=
path
.
join
(
os
.
homedir
(),
'
nni
'
,
'
experiments
'
,
getExperimentId
());
this
.
logDir
=
path
.
join
(
os
.
homedir
(),
'
nni
'
,
'
experiments
'
,
getExperimentId
());
}
}
...
...
src/nni_manager/training_service/common/util.ts
View file @
9dec51e2
...
@@ -70,11 +70,11 @@ export async function validateCodeDir(codeDir: string) : Promise<number> {
...
@@ -70,11 +70,11 @@ export async function validateCodeDir(codeDir: string) : Promise<number> {
*/
*/
export
async
function
execMkdir
(
directory
:
string
,
share
:
boolean
=
false
):
Promise
<
void
>
{
export
async
function
execMkdir
(
directory
:
string
,
share
:
boolean
=
false
):
Promise
<
void
>
{
if
(
process
.
platform
===
'
win32
'
)
{
if
(
process
.
platform
===
'
win32
'
)
{
await
cpp
.
exec
(
`powershell.exe New-Item -Path
${
directory
}
-ItemType "directory" -Force`
);
await
cpp
.
exec
(
`powershell.exe New-Item -Path
"
${
directory
}
"
-ItemType "directory" -Force`
);
}
else
if
(
share
)
{
}
else
if
(
share
)
{
await
cpp
.
exec
(
`(umask 0; mkdir -p
${
directory
}
)`
);
await
cpp
.
exec
(
`(umask 0; mkdir -p
'
${
directory
}
'
)`
);
}
else
{
}
else
{
await
cpp
.
exec
(
`mkdir -p
${
directory
}
`
);
await
cpp
.
exec
(
`mkdir -p
'
${
directory
}
'
`
);
}
}
return
Promise
.
resolve
();
return
Promise
.
resolve
();
...
@@ -87,9 +87,9 @@ export async function execMkdir(directory: string, share: boolean = false): Prom
...
@@ -87,9 +87,9 @@ export async function execMkdir(directory: string, share: boolean = false): Prom
*/
*/
export
async
function
execCopydir
(
source
:
string
,
destination
:
string
):
Promise
<
void
>
{
export
async
function
execCopydir
(
source
:
string
,
destination
:
string
):
Promise
<
void
>
{
if
(
process
.
platform
===
'
win32
'
)
{
if
(
process
.
platform
===
'
win32
'
)
{
await
cpp
.
exec
(
`powershell.exe Copy-Item
${
source
}
-Destination
${
destination
}
-Recurse`
);
await
cpp
.
exec
(
`powershell.exe Copy-Item
"
${
source
}
"
-Destination
"
${
destination
}
"
-Recurse`
);
}
else
{
}
else
{
await
cpp
.
exec
(
`cp -r
${
source
}
${
destination
}
`
);
await
cpp
.
exec
(
`cp -r
'
${
source
}
' '
${
destination
}
'
`
);
}
}
return
Promise
.
resolve
();
return
Promise
.
resolve
();
...
@@ -101,9 +101,9 @@ export async function execCopydir(source: string, destination: string): Promise<
...
@@ -101,9 +101,9 @@ export async function execCopydir(source: string, destination: string): Promise<
*/
*/
export
async
function
execNewFile
(
filename
:
string
):
Promise
<
void
>
{
export
async
function
execNewFile
(
filename
:
string
):
Promise
<
void
>
{
if
(
process
.
platform
===
'
win32
'
)
{
if
(
process
.
platform
===
'
win32
'
)
{
await
cpp
.
exec
(
`powershell.exe New-Item -Path
${
filename
}
-ItemType "file" -Force`
);
await
cpp
.
exec
(
`powershell.exe New-Item -Path
"
${
filename
}
"
-ItemType "file" -Force`
);
}
else
{
}
else
{
await
cpp
.
exec
(
`touch
${
filename
}
`
);
await
cpp
.
exec
(
`touch
'
${
filename
}
'
`
);
}
}
return
Promise
.
resolve
();
return
Promise
.
resolve
();
...
@@ -115,9 +115,9 @@ export async function execNewFile(filename: string): Promise<void> {
...
@@ -115,9 +115,9 @@ export async function execNewFile(filename: string): Promise<void> {
*/
*/
export
function
runScript
(
filePath
:
string
):
cp
.
ChildProcess
{
export
function
runScript
(
filePath
:
string
):
cp
.
ChildProcess
{
if
(
process
.
platform
===
'
win32
'
)
{
if
(
process
.
platform
===
'
win32
'
)
{
return
cp
.
exec
(
`powershell.exe -ExecutionPolicy Bypass -file
${
filePath
}
`
);
return
cp
.
exec
(
`powershell.exe -ExecutionPolicy Bypass -file
"
${
filePath
}
"
`
);
}
else
{
}
else
{
return
cp
.
exec
(
`bash
${
filePath
}
`
);
return
cp
.
exec
(
`bash
'
${
filePath
}
'
`
);
}
}
}
}
...
@@ -128,9 +128,9 @@ export function runScript(filePath: string): cp.ChildProcess {
...
@@ -128,9 +128,9 @@ export function runScript(filePath: string): cp.ChildProcess {
export
async
function
execTail
(
filePath
:
string
):
Promise
<
cpp
.
childProcessPromise
.
Result
>
{
export
async
function
execTail
(
filePath
:
string
):
Promise
<
cpp
.
childProcessPromise
.
Result
>
{
let
cmdresult
:
cpp
.
childProcessPromise
.
Result
;
let
cmdresult
:
cpp
.
childProcessPromise
.
Result
;
if
(
process
.
platform
===
'
win32
'
)
{
if
(
process
.
platform
===
'
win32
'
)
{
cmdresult
=
await
cpp
.
exec
(
`powershell.exe Get-Content
${
filePath
}
-Tail 1`
);
cmdresult
=
await
cpp
.
exec
(
`powershell.exe Get-Content
"
${
filePath
}
"
-Tail 1`
);
}
else
{
}
else
{
cmdresult
=
await
cpp
.
exec
(
`tail -n 1
${
filePath
}
`
);
cmdresult
=
await
cpp
.
exec
(
`tail -n 1
'
${
filePath
}
'
`
);
}
}
return
Promise
.
resolve
(
cmdresult
);
return
Promise
.
resolve
(
cmdresult
);
...
@@ -142,9 +142,9 @@ export async function execTail(filePath: string): Promise<cpp.childProcessPromis
...
@@ -142,9 +142,9 @@ export async function execTail(filePath: string): Promise<cpp.childProcessPromis
*/
*/
export
async
function
execRemove
(
directory
:
string
):
Promise
<
void
>
{
export
async
function
execRemove
(
directory
:
string
):
Promise
<
void
>
{
if
(
process
.
platform
===
'
win32
'
)
{
if
(
process
.
platform
===
'
win32
'
)
{
await
cpp
.
exec
(
`powershell.exe Remove-Item
${
directory
}
-Recurse -Force`
);
await
cpp
.
exec
(
`powershell.exe Remove-Item
"
${
directory
}
"
-Recurse -Force`
);
}
else
{
}
else
{
await
cpp
.
exec
(
`rm -rf
${
directory
}
`
);
await
cpp
.
exec
(
`rm -rf
'
${
directory
}
'
`
);
}
}
return
Promise
.
resolve
();
return
Promise
.
resolve
();
...
@@ -173,7 +173,7 @@ export function setEnvironmentVariable(variable: { key: string; value: string })
...
@@ -173,7 +173,7 @@ export function setEnvironmentVariable(variable: { key: string; value: string })
if
(
process
.
platform
===
'
win32
'
)
{
if
(
process
.
platform
===
'
win32
'
)
{
return
`$env:
${
variable
.
key
}
="
${
variable
.
value
}
"`
;
return
`$env:
${
variable
.
key
}
="
${
variable
.
value
}
"`
;
}
else
{
}
else
{
return
`export
${
variable
.
key
}
=
${
variable
.
value
}
`
;
return
`export
${
variable
.
key
}
=
'
${
variable
.
value
}
'
`
;
}
}
}
}
...
...
src/nni_manager/training_service/local/localTrainingService.ts
View file @
9dec51e2
...
@@ -490,18 +490,18 @@ class LocalTrainingService implements TrainingService {
...
@@ -490,18 +490,18 @@ class LocalTrainingService implements TrainingService {
const
script
:
string
[]
=
[];
const
script
:
string
[]
=
[];
if
(
process
.
platform
===
'
win32
'
)
{
if
(
process
.
platform
===
'
win32
'
)
{
script
.
push
(
script
.
push
(
`cmd.exe /c
${
localTrialConfig
.
command
}
2>
${
path
.
join
(
workingDirectory
,
'
stderr
'
)}
`
,
`cmd.exe /c
${
localTrialConfig
.
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" + (Get-Date -Format fff).ToString()`
,
`$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
(
`eval
${
localTrialConfig
.
command
}
2>
${
path
.
join
(
workingDirectory
,
'
stderr
'
)}
`
);
script
.
push
(
`eval
${
localTrialConfig
.
command
}
2>
"
${
path
.
join
(
workingDirectory
,
'
stderr
'
)}
"
`
);
if
(
process
.
platform
===
'
darwin
'
)
{
if
(
process
.
platform
===
'
darwin
'
)
{
// https://superuser.com/questions/599072/how-to-get-bash-execution-time-in-milliseconds-under-mac-os-x
// https://superuser.com/questions/599072/how-to-get-bash-execution-time-in-milliseconds-under-mac-os-x
// Considering the worst case, write 999 to avoid negative duration
// Considering the worst case, write 999 to avoid negative duration
script
.
push
(
`echo $?
\`
date +%s999
\`
>
${
path
.
join
(
workingDirectory
,
'
.nni
'
,
'
state
'
)}
`
);
script
.
push
(
`echo $?
\`
date +%s999
\`
>
'
${
path
.
join
(
workingDirectory
,
'
.nni
'
,
'
state
'
)}
'
`
);
}
else
{
}
else
{
script
.
push
(
`echo $?
\`
date +%s%3N
\`
>
${
path
.
join
(
workingDirectory
,
'
.nni
'
,
'
state
'
)}
`
);
script
.
push
(
`echo $?
\`
date +%s%3N
\`
>
'
${
path
.
join
(
workingDirectory
,
'
.nni
'
,
'
state
'
)}
'
`
);
}
}
}
}
...
@@ -522,7 +522,7 @@ class LocalTrainingService implements TrainingService {
...
@@ -522,7 +522,7 @@ class LocalTrainingService implements TrainingService {
if
(
process
.
platform
!==
'
win32
'
)
{
if
(
process
.
platform
!==
'
win32
'
)
{
runScriptContent
.
push
(
'
#!/bin/bash
'
);
runScriptContent
.
push
(
'
#!/bin/bash
'
);
}
}
runScriptContent
.
push
(
`cd
${
this
.
localTrialConfig
.
codeDir
}
`
);
runScriptContent
.
push
(
`cd
'
${
this
.
localTrialConfig
.
codeDir
}
'
`
);
for
(
const
variable
of
variables
)
{
for
(
const
variable
of
variables
)
{
runScriptContent
.
push
(
setEnvironmentVariable
(
variable
));
runScriptContent
.
push
(
setEnvironmentVariable
(
variable
));
}
}
...
...
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