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
5fc73ba6
Unverified
Commit
5fc73ba6
authored
Aug 27, 2021
by
liuzhe-lz
Committed by
GitHub
Aug 27, 2021
Browse files
Refactor NNI Manager UT (Stage 1) - setup toolchain (#4109)
parent
2b9f5f8c
Changes
121
Show whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
39 additions
and
64 deletions
+39
-64
pipelines/fast-test.yml
pipelines/fast-test.yml
+4
-1
ts/nni_manager/.gitignore
ts/nni_manager/.gitignore
+3
-2
ts/nni_manager/.mocharc.json
ts/nni_manager/.mocharc.json
+5
-0
ts/nni_manager/common/component.ts
ts/nni_manager/common/component.ts
+0
-2
ts/nni_manager/common/datastore.ts
ts/nni_manager/common/datastore.ts
+0
-2
ts/nni_manager/common/errors.ts
ts/nni_manager/common/errors.ts
+0
-2
ts/nni_manager/common/experimentConfig.ts
ts/nni_manager/common/experimentConfig.ts
+1
-3
ts/nni_manager/common/experimentManager.ts
ts/nni_manager/common/experimentManager.ts
+0
-2
ts/nni_manager/common/experimentStartupInfo.ts
ts/nni_manager/common/experimentStartupInfo.ts
+3
-5
ts/nni_manager/common/log.ts
ts/nni_manager/common/log.ts
+2
-4
ts/nni_manager/common/manager.ts
ts/nni_manager/common/manager.ts
+0
-2
ts/nni_manager/common/nniConfig.ts
ts/nni_manager/common/nniConfig.ts
+2
-4
ts/nni_manager/common/observableTimer.ts
ts/nni_manager/common/observableTimer.ts
+1
-3
ts/nni_manager/common/pythonScript.ts
ts/nni_manager/common/pythonScript.ts
+0
-2
ts/nni_manager/common/restServer.ts
ts/nni_manager/common/restServer.ts
+3
-5
ts/nni_manager/common/shellUtils.ts
ts/nni_manager/common/shellUtils.ts
+0
-2
ts/nni_manager/common/tensorboardManager.ts
ts/nni_manager/common/tensorboardManager.ts
+0
-2
ts/nni_manager/common/trainingService.ts
ts/nni_manager/common/trainingService.ts
+0
-2
ts/nni_manager/common/utils.ts
ts/nni_manager/common/utils.ts
+13
-15
ts/nni_manager/core/ipcInterface.ts
ts/nni_manager/core/ipcInterface.ts
+2
-4
No files found.
pipelines/fast-test.yml
View file @
5fc73ba6
...
@@ -165,6 +165,7 @@ stages:
...
@@ -165,6 +165,7 @@ stages:
-
script
:
|
-
script
:
|
python setup.py develop
python setup.py develop
mkdir -p coverage
displayName
:
Install NNI
displayName
:
Install NNI
-
script
:
|
-
script
:
|
...
@@ -185,12 +186,14 @@ stages:
...
@@ -185,12 +186,14 @@ stages:
python -m pytest ut/sdk/test_compressor_tf.py --cov-config=.coveragerc --cov-append
python -m pytest ut/sdk/test_compressor_tf.py --cov-config=.coveragerc --cov-append
python -m pytest ut/sdk/test_compressor_torch.py --cov-config=.coveragerc --cov-append
python -m pytest ut/sdk/test_compressor_torch.py --cov-config=.coveragerc --cov-append
python -m pytest ut/sdk/test_model_speedup.py --cov-config=.coveragerc --cov-append
python -m pytest ut/sdk/test_model_speedup.py --cov-config=.coveragerc --cov-append
cp coverage.xml ../coverage/python.xml
displayName
:
Python unit test
displayName
:
Python unit test
-
script
:
|
-
script
:
|
set -e
set -e
cd ts/nni_manager
cd ts/nni_manager
yarn test
yarn test
cp coverage/cobertura-coverage.xml ../../coverage/typescript.xml
displayName
:
TypeScript unit test
displayName
:
TypeScript unit test
-
task
:
PublishTestResults@2
-
task
:
PublishTestResults@2
...
@@ -203,7 +206,7 @@ stages:
...
@@ -203,7 +206,7 @@ stages:
-
task
:
PublishCodeCoverageResults@1
-
task
:
PublishCodeCoverageResults@1
inputs
:
inputs
:
codeCoverageTool
:
Cobertura
codeCoverageTool
:
Cobertura
summaryFileLocation
:
'
$(System.DefaultWorkingDirectory)/**/*
coverage
.xml'
summaryFileLocation
:
coverage
/*
displayName
:
Publish code coverage results
displayName
:
Publish code coverage results
-
script
:
|
-
script
:
|
...
...
ts/nni_manager/.gitignore
View file @
5fc73ba6
# Build result
# Build result
dist/
/dist
/.tsbuildinfo
# node modules
# node modules
node_modules
/
/
node_modules
# test files
# test files
.experiment.test
.experiment.test
ts/nni_manager/.mocharc.json
0 → 100644
View file @
5fc73ba6
{
"color"
:
true
,
"require"
:
"test/register.js"
,
"timeout"
:
"15s"
}
ts/nni_manager/common/component.ts
View file @
5fc73ba6
// Copyright (c) Microsoft Corporation.
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
// Licensed under the MIT license.
'
use strict
'
;
import
*
as
ioc
from
'
typescript-ioc
'
;
import
*
as
ioc
from
'
typescript-ioc
'
;
const
Inject
:
(...
args
:
any
[])
=>
any
=
ioc
.
Inject
;
const
Inject
:
(...
args
:
any
[])
=>
any
=
ioc
.
Inject
;
...
...
ts/nni_manager/common/datastore.ts
View file @
5fc73ba6
// Copyright (c) Microsoft Corporation.
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
// Licensed under the MIT license.
'
use strict
'
;
import
{
ExperimentProfile
,
TrialJobStatistics
}
from
'
./manager
'
;
import
{
ExperimentProfile
,
TrialJobStatistics
}
from
'
./manager
'
;
import
{
TrialJobDetail
,
TrialJobStatus
}
from
'
./trainingService
'
;
import
{
TrialJobDetail
,
TrialJobStatus
}
from
'
./trainingService
'
;
...
...
ts/nni_manager/common/errors.ts
View file @
5fc73ba6
// Copyright (c) Microsoft Corporation.
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
// Licensed under the MIT license.
'
use strict
'
;
export
namespace
NNIErrorNames
{
export
namespace
NNIErrorNames
{
export
const
NOT_FOUND
:
string
=
'
NOT_FOUND
'
;
export
const
NOT_FOUND
:
string
=
'
NOT_FOUND
'
;
export
const
INVALID_JOB_DETAIL
:
string
=
'
NO_VALID_JOB_DETAIL_FOUND
'
;
export
const
INVALID_JOB_DETAIL
:
string
=
'
NO_VALID_JOB_DETAIL_FOUND
'
;
...
...
ts/nni_manager/common/experimentConfig.ts
View file @
5fc73ba6
// Copyright (c) Microsoft Corporation.
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
// Licensed under the MIT license.
'
use strict
'
;
import
assert
from
'
assert
'
;
import
*
as
assert
from
'
assert
'
;
import
{
KubeflowOperator
,
OperatorApiVersion
}
from
'
../training_service/kubernetes/kubeflow/kubeflowConfig
'
import
{
KubeflowOperator
,
OperatorApiVersion
}
from
'
../training_service/kubernetes/kubeflow/kubeflowConfig
'
import
{
KubernetesStorageKind
}
from
'
../training_service/kubernetes/kubernetesConfig
'
;
import
{
KubernetesStorageKind
}
from
'
../training_service/kubernetes/kubernetesConfig
'
;
...
...
ts/nni_manager/common/experimentManager.ts
View file @
5fc73ba6
// Copyright (c) Microsoft Corporation.
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
// Licensed under the MIT license.
'
use strict
'
;
abstract
class
ExperimentManager
{
abstract
class
ExperimentManager
{
public
abstract
getExperimentsInfo
():
Promise
<
JSON
>
;
public
abstract
getExperimentsInfo
():
Promise
<
JSON
>
;
public
abstract
setExperimentPath
(
newPath
:
string
):
void
;
public
abstract
setExperimentPath
(
newPath
:
string
):
void
;
...
...
ts/nni_manager/common/experimentStartupInfo.ts
View file @
5fc73ba6
// Copyright (c) Microsoft Corporation.
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
// Licensed under the MIT license.
'
use strict
'
;
import
assert
from
'
assert
'
;
import
os
from
'
os
'
;
import
*
as
assert
from
'
assert
'
;
import
path
from
'
path
'
;
import
*
as
os
from
'
os
'
;
import
*
as
path
from
'
path
'
;
const
API_ROOT_URL
:
string
=
'
/api/v1/nni
'
;
const
API_ROOT_URL
:
string
=
'
/api/v1/nni
'
;
...
...
ts/nni_manager/common/log.ts
View file @
5fc73ba6
// Copyright (c) Microsoft Corporation.
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
// Licensed under the MIT license.
'
use strict
'
;
import
fs
from
'
fs
'
;
import
*
as
fs
from
'
fs
'
;
import
{
Writable
}
from
'
stream
'
;
import
{
Writable
}
from
'
stream
'
;
import
*
as
util
from
'
util
'
;
import
util
from
'
util
'
;
/* log level constants */
/* log level constants */
...
...
ts/nni_manager/common/manager.ts
View file @
5fc73ba6
// Copyright (c) Microsoft Corporation.
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
// Licensed under the MIT license.
'
use strict
'
;
import
{
MetricDataRecord
,
MetricType
,
TrialJobInfo
}
from
'
./datastore
'
;
import
{
MetricDataRecord
,
MetricType
,
TrialJobInfo
}
from
'
./datastore
'
;
import
{
TrialJobStatus
}
from
'
./trainingService
'
;
import
{
TrialJobStatus
}
from
'
./trainingService
'
;
import
{
ExperimentConfig
}
from
'
./experimentConfig
'
;
import
{
ExperimentConfig
}
from
'
./experimentConfig
'
;
...
...
ts/nni_manager/common/nniConfig.ts
View file @
5fc73ba6
// Copyright (c) Microsoft Corporation.
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
// Licensed under the MIT license.
'
use strict
'
;
import
fs
from
'
fs
'
;
import
path
from
'
path
'
;
import
*
as
fs
from
'
fs
'
;
import
*
as
path
from
'
path
'
;
import
{
promisify
}
from
'
util
'
;
import
{
promisify
}
from
'
util
'
;
import
{
runPythonScript
}
from
'
./pythonScript
'
;
import
{
runPythonScript
}
from
'
./pythonScript
'
;
...
...
ts/nni_manager/common/observableTimer.ts
View file @
5fc73ba6
// Copyright (c) Microsoft Corporation.
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
// Licensed under the MIT license.
'
use strict
'
;
import
rx
from
'
rx
'
;
import
*
as
rx
from
'
rx
'
;
import
*
as
component
from
'
../common/component
'
;
import
*
as
component
from
'
../common/component
'
;
@
component
.
Singleton
@
component
.
Singleton
...
...
ts/nni_manager/common/pythonScript.ts
View file @
5fc73ba6
// Copyright (c) Microsoft Corporation.
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
// Licensed under the MIT license.
'
use strict
'
;
import
{
spawn
}
from
'
child_process
'
;
import
{
spawn
}
from
'
child_process
'
;
import
{
Logger
,
getLogger
}
from
'
./log
'
;
import
{
Logger
,
getLogger
}
from
'
./log
'
;
...
...
ts/nni_manager/common/restServer.ts
View file @
5fc73ba6
// Copyright (c) Microsoft Corporation.
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
// Licensed under the MIT license.
'
use strict
'
;
import
assert
from
'
assert
'
;
import
express
from
'
express
'
;
import
*
as
assert
from
'
assert
'
;
import
http
from
'
http
'
;
import
*
as
express
from
'
express
'
;
import
*
as
http
from
'
http
'
;
import
{
Deferred
}
from
'
ts-deferred
'
;
import
{
Deferred
}
from
'
ts-deferred
'
;
import
{
getLogger
,
Logger
}
from
'
./log
'
;
import
{
getLogger
,
Logger
}
from
'
./log
'
;
import
{
getBasePort
}
from
'
./experimentStartupInfo
'
;
import
{
getBasePort
}
from
'
./experimentStartupInfo
'
;
...
...
ts/nni_manager/common/shellUtils.ts
View file @
5fc73ba6
// Copyright (c) Microsoft Corporation.
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
// Licensed under the MIT license.
'
use strict
'
;
// for readability
// for readability
const
singleQuote
=
"
'
"
;
const
singleQuote
=
"
'
"
;
const
doubleQuote
=
'
"
'
;
const
doubleQuote
=
'
"
'
;
...
...
ts/nni_manager/common/tensorboardManager.ts
View file @
5fc73ba6
// Copyright (c) Microsoft Corporation.
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
// Licensed under the MIT license.
'
use strict
'
;
interface
TensorboardParams
{
interface
TensorboardParams
{
trials
:
string
;
trials
:
string
;
}
}
...
...
ts/nni_manager/common/trainingService.ts
View file @
5fc73ba6
// Copyright (c) Microsoft Corporation.
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
// Licensed under the MIT license.
'
use strict
'
;
/**
/**
* define TrialJobStatus
* define TrialJobStatus
*/
*/
...
...
ts/nni_manager/common/utils.ts
View file @
5fc73ba6
// Copyright (c) Microsoft Corporation.
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
// Licensed under the MIT license.
'
use strict
'
;
import
assert
from
'
assert
'
;
import
*
as
assert
from
'
assert
'
;
import
{
randomBytes
}
from
'
crypto
'
;
import
{
randomBytes
}
from
'
crypto
'
;
import
*
as
cpp
from
'
child-process-promise
'
;
import
cpp
from
'
child-process-promise
'
;
import
*
as
cp
from
'
child_process
'
;
import
cp
from
'
child_process
'
;
import
{
ChildProcess
,
spawn
,
StdioOptions
}
from
'
child_process
'
;
import
{
ChildProcess
,
spawn
,
StdioOptions
}
from
'
child_process
'
;
import
*
as
dgram
from
'
dgram
'
;
import
dgram
from
'
dgram
'
;
import
*
as
fs
from
'
fs
'
;
import
fs
from
'
fs
'
;
import
*
as
net
from
'
net
'
;
import
net
from
'
net
'
;
import
*
as
os
from
'
os
'
;
import
os
from
'
os
'
;
import
*
as
path
from
'
path
'
;
import
path
from
'
path
'
;
import
*
as
timersPromises
from
'
timers/promises
'
;
import
*
as
timersPromises
from
'
timers/promises
'
;
import
*
as
lockfile
from
'
lockfile
'
;
import
lockfile
from
'
lockfile
'
;
import
{
Deferred
}
from
'
ts-deferred
'
;
import
{
Deferred
}
from
'
ts-deferred
'
;
import
{
Container
}
from
'
typescript-ioc
'
;
import
{
Container
}
from
'
typescript-ioc
'
;
import
*
as
glob
from
'
glob
'
;
import
glob
from
'
glob
'
;
import
{
Database
,
DataStore
}
from
'
./datastore
'
;
import
{
Database
,
DataStore
}
from
'
./datastore
'
;
import
{
getExperimentStartupInfo
,
setExperimentStartupInfo
}
from
'
./experimentStartupInfo
'
;
import
{
getExperimentStartupInfo
,
setExperimentStartupInfo
}
from
'
./experimentStartupInfo
'
;
...
@@ -243,7 +241,7 @@ function countFilesRecursively(directory: string): Promise<number> {
...
@@ -243,7 +241,7 @@ function countFilesRecursively(directory: string): Promise<number> {
const
deferred
:
Deferred
<
number
>
=
new
Deferred
<
number
>
();
const
deferred
:
Deferred
<
number
>
=
new
Deferred
<
number
>
();
let
timeoutId
:
NodeJS
.
Timer
let
timeoutId
:
NodeJS
.
Timer
const
delayTimeout
:
Promise
<
number
>
=
new
Promise
((
resolve
:
Function
,
reject
:
Function
):
void
=>
{
const
delayTimeout
:
Promise
<
number
>
=
new
Promise
((
_
resolve
:
Function
,
reject
:
Function
):
void
=>
{
// Set timeout and reject the promise once reach timeout (5 seconds)
// Set timeout and reject the promise once reach timeout (5 seconds)
timeoutId
=
setTimeout
(()
=>
{
timeoutId
=
setTimeout
(()
=>
{
reject
(
new
Error
(
`Timeout: path
${
directory
}
has too many files`
));
reject
(
new
Error
(
`Timeout: path
${
directory
}
has too many files`
));
...
@@ -375,11 +373,11 @@ function unixPathJoin(...paths: any[]): string {
...
@@ -375,11 +373,11 @@ function unixPathJoin(...paths: any[]): string {
*/
*/
function
withLockSync
(
func
:
Function
,
filePath
:
string
,
lockOpts
:
{[
key
:
string
]:
any
},
...
args
:
any
):
any
{
function
withLockSync
(
func
:
Function
,
filePath
:
string
,
lockOpts
:
{[
key
:
string
]:
any
},
...
args
:
any
):
any
{
const
lockName
=
path
.
join
(
path
.
dirname
(
filePath
),
path
.
basename
(
filePath
)
+
`.lock.
${
process
.
pid
}
`
);
const
lockName
=
path
.
join
(
path
.
dirname
(
filePath
),
path
.
basename
(
filePath
)
+
`.lock.
${
process
.
pid
}
`
);
if
(
typeof
lockOpts
.
stale
===
'
number
'
){
if
(
typeof
lockOpts
[
'
stale
'
]
===
'
number
'
){
const
lockPath
=
path
.
join
(
path
.
dirname
(
filePath
),
path
.
basename
(
filePath
)
+
'
.lock.*
'
);
const
lockPath
=
path
.
join
(
path
.
dirname
(
filePath
),
path
.
basename
(
filePath
)
+
'
.lock.*
'
);
const
lockFileNames
:
string
[]
=
glob
.
sync
(
lockPath
);
const
lockFileNames
:
string
[]
=
glob
.
sync
(
lockPath
);
const
canLock
:
boolean
=
lockFileNames
.
map
((
fileName
)
=>
{
const
canLock
:
boolean
=
lockFileNames
.
map
((
fileName
)
=>
{
return
fs
.
existsSync
(
fileName
)
&&
Date
.
now
()
-
fs
.
statSync
(
fileName
).
mtimeMs
<
lockOpts
.
stale
;
return
fs
.
existsSync
(
fileName
)
&&
Date
.
now
()
-
fs
.
statSync
(
fileName
).
mtimeMs
<
lockOpts
[
'
stale
'
]
;
}).
filter
(
unexpired
=>
unexpired
===
true
).
length
===
0
;
}).
filter
(
unexpired
=>
unexpired
===
true
).
length
===
0
;
if
(
!
canLock
)
{
if
(
!
canLock
)
{
throw
new
Error
(
'
File has been locked.
'
);
throw
new
Error
(
'
File has been locked.
'
);
...
...
ts/nni_manager/core/ipcInterface.ts
View file @
5fc73ba6
// Copyright (c) Microsoft Corporation.
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
// Licensed under the MIT license.
'
use strict
'
;
import
assert
from
'
assert
'
;
import
*
as
assert
from
'
assert
'
;
import
{
ChildProcess
}
from
'
child_process
'
;
import
{
ChildProcess
}
from
'
child_process
'
;
import
{
EventEmitter
}
from
'
events
'
;
import
{
EventEmitter
}
from
'
events
'
;
import
*
as
net
from
'
net
'
;
import
net
from
'
net
'
;
import
{
Readable
,
Writable
}
from
'
stream
'
;
import
{
Readable
,
Writable
}
from
'
stream
'
;
import
{
NNIError
}
from
'
../common/errors
'
;
import
{
NNIError
}
from
'
../common/errors
'
;
import
{
getLogger
,
Logger
}
from
'
../common/log
'
;
import
{
getLogger
,
Logger
}
from
'
../common/log
'
;
...
...
Prev
1
2
3
4
5
…
7
Next
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