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
cd3a912a
Unverified
Commit
cd3a912a
authored
Nov 27, 2019
by
SparkSnail
Committed by
GitHub
Nov 27, 2019
Browse files
Merge pull request #218 from microsoft/master
merge master
parents
a0846f2a
e9cba778
Changes
375
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
82 additions
and
315 deletions
+82
-315
test/tuner_test/naive_trial.py
test/tuner_test/naive_trial.py
+3
-0
test/unittest.ps1
test/unittest.ps1
+13
-5
test/utils.py
test/utils.py
+3
-20
tools/nni_annotation/__init__.py
tools/nni_annotation/__init__.py
+2
-20
tools/nni_annotation/code_generator.py
tools/nni_annotation/code_generator.py
+2
-20
tools/nni_annotation/examples/mnist_generated.py
tools/nni_annotation/examples/mnist_generated.py
+3
-0
tools/nni_annotation/examples/mnist_with_annotation.py
tools/nni_annotation/examples/mnist_with_annotation.py
+3
-16
tools/nni_annotation/examples/mnist_without_annotation.py
tools/nni_annotation/examples/mnist_without_annotation.py
+3
-16
tools/nni_annotation/search_space_generator.py
tools/nni_annotation/search_space_generator.py
+2
-20
tools/nni_annotation/specific_code_generator.py
tools/nni_annotation/specific_code_generator.py
+2
-20
tools/nni_annotation/test_annotation.py
tools/nni_annotation/test_annotation.py
+2
-20
tools/nni_cmd/command_utils.py
tools/nni_cmd/command_utils.py
+3
-0
tools/nni_cmd/common_utils.py
tools/nni_cmd/common_utils.py
+3
-20
tools/nni_cmd/config_schema.py
tools/nni_cmd/config_schema.py
+2
-19
tools/nni_cmd/config_utils.py
tools/nni_cmd/config_utils.py
+2
-20
tools/nni_cmd/constants.py
tools/nni_cmd/constants.py
+2
-19
tools/nni_cmd/launcher.py
tools/nni_cmd/launcher.py
+3
-21
tools/nni_cmd/launcher_utils.py
tools/nni_cmd/launcher_utils.py
+2
-19
tools/nni_cmd/nnictl.py
tools/nni_cmd/nnictl.py
+11
-21
tools/nni_cmd/nnictl_utils.py
tools/nni_cmd/nnictl_utils.py
+16
-19
No files found.
test/tuner_test/naive_trial.py
View file @
cd3a912a
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
import
nni
import
nni
params
=
nni
.
get_next_parameter
()
params
=
nni
.
get_next_parameter
()
...
...
test/unittest.ps1
View file @
cd3a912a
...
@@ -6,7 +6,10 @@ $ErrorActionPreference = "Stop"
...
@@ -6,7 +6,10 @@ $ErrorActionPreference = "Stop"
echo
""
echo
""
echo
"===========================Testing: nni_annotation==========================="
echo
"===========================Testing: nni_annotation==========================="
cd
$CWD
/../tools/
cd
$CWD
/../tools/
python
-m
unittest
-v
nni_annotation/test_annotation.py
cmd
/c
"python -m unittest -v nni_annotation/test_annotation.py 2>&1"
if
(
$LASTEXITCODE
-ne
0
)
{
throw
"Exit code
$LASTEXITCODE
"
}
## Export certain environment variables for unittest code to work
## Export certain environment variables for unittest code to work
$
env
:
NNI_TRIAL_JOB_ID
=
"test_trial_job_id"
$
env
:
NNI_TRIAL_JOB_ID
=
"test_trial_job_id"
...
@@ -16,12 +19,17 @@ $env:NNI_PLATFORM="unittest"
...
@@ -16,12 +19,17 @@ $env:NNI_PLATFORM="unittest"
echo
""
echo
""
echo
"===========================Testing: nni_sdk==========================="
echo
"===========================Testing: nni_sdk==========================="
cd
$CWD
/../src/sdk/pynni/
cd
$CWD
/../src/sdk/pynni/
python
-m
unittest
discover
-v
tests
cmd
/c
"python -m unittest discover -v tests 2>&1"
if
(
$LASTEXITCODE
-ne
0
)
{
throw
"Exit code
$LASTEXITCODE
"
}
# -------------For typescript unittest-------------
# -------------For typescript unittest-------------
cd
$CWD
/../src/nni_manager
cd
$CWD
/../src/nni_manager
echo
""
echo
""
echo
"===========================Testing: nni_manager==========================="
echo
"===========================Testing: nni_manager==========================="
npm
run
test
cmd
/c
"npm run test 2>&1"
# don't check now. adding back later.
# if ($LASTEXITCODE -ne 0) {
# throw "Exit code $LASTEXITCODE"
# }
test/utils.py
View file @
cd3a912a
# Copyright (c) Microsoft Corporation
# Copyright (c) Microsoft Corporation.
# All rights reserved.
# Licensed under the MIT license.
#
# MIT License
#
# Permission is hereby granted, free of charge,
# to any person obtaining a copy of this software and associated
# documentation files (the "Software"), to deal in the Software without restriction,
# including without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and
# to permit persons to whom the Software is furnished to do so, subject to the following conditions:
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
# BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
# DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
import
contextlib
import
contextlib
import
collections
import
collections
...
@@ -173,4 +156,4 @@ def detect_port(port):
...
@@ -173,4 +156,4 @@ def detect_port(port):
def
snooze
():
def
snooze
():
'''Sleep to make sure previous stopped exp has enough time to exit'''
'''Sleep to make sure previous stopped exp has enough time to exit'''
time
.
sleep
(
6
)
time
.
sleep
(
6
)
\ No newline at end of file
tools/nni_annotation/__init__.py
View file @
cd3a912a
# Copyright (c) Microsoft Corporation. All rights reserved.
# Copyright (c) Microsoft Corporation.
#
# Licensed under the MIT license.
# MIT License
#
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
# associated documentation files (the "Software"), to deal in the Software without restriction,
# including without limitation the rights to use, copy, modify, merge, publish, distribute,
# sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all copies or
# substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
# NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
# DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT
# OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
# ==================================================================================================
import
os
import
os
import
sys
import
sys
...
...
tools/nni_annotation/code_generator.py
View file @
cd3a912a
# Copyright (c) Microsoft Corporation. All rights reserved.
# Copyright (c) Microsoft Corporation.
#
# Licensed under the MIT license.
# MIT License
#
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
# associated documentation files (the "Software"), to deal in the Software without restriction,
# including without limitation the rights to use, copy, modify, merge, publish, distribute,
# sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all copies or
# substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
# NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
# DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT
# OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
# ==================================================================================================
import
ast
import
ast
import
astor
import
astor
...
...
tools/nni_annotation/examples/mnist_generated.py
View file @
cd3a912a
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
"""A deep MNIST classifier using convolutional layers."""
"""A deep MNIST classifier using convolutional layers."""
import
logging
import
logging
import
math
import
math
...
...
tools/nni_annotation/examples/mnist_with_annotation.py
View file @
cd3a912a
#!/usr/bin/python
#!/usr/bin/python
# Copyright (c) Microsoft Corporation
# All rights reserved.
# Copyright (c) Microsoft Corporation.
#
# Licensed under the MIT license.
# MIT License
#
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
# documentation files (the "Software"), to deal in the Software without restriction, including without limitation
# the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and
# to permit persons to whom the Software is furnished to do so, subject to the following conditions:
# The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
# BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
# DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
"""A deep MNIST classifier using convolutional layers."""
"""A deep MNIST classifier using convolutional layers."""
...
...
tools/nni_annotation/examples/mnist_without_annotation.py
View file @
cd3a912a
#!/usr/bin/python
#!/usr/bin/python
# Copyright (c) Microsoft Corporation
# All rights reserved.
# Copyright (c) Microsoft Corporation.
#
# Licensed under the MIT license.
# MIT License
#
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
# documentation files (the "Software"), to deal in the Software without restriction, including without limitation
# the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and
# to permit persons to whom the Software is furnished to do so, subject to the following conditions:
# The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
# BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
# DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
"""A deep MNIST classifier using convolutional layers."""
"""A deep MNIST classifier using convolutional layers."""
...
...
tools/nni_annotation/search_space_generator.py
View file @
cd3a912a
# Copyright (c) Microsoft Corporation. All rights reserved.
# Copyright (c) Microsoft Corporation.
#
# Licensed under the MIT license.
# MIT License
#
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
# associated documentation files (the "Software"), to deal in the Software without restriction,
# including without limitation the rights to use, copy, modify, merge, publish, distribute,
# sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all copies or
# substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
# NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
# DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT
# OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
# ==================================================================================================
import
ast
import
ast
import
numbers
import
numbers
...
...
tools/nni_annotation/specific_code_generator.py
View file @
cd3a912a
# Copyright (c) Microsoft Corporation. All rights reserved.
# Copyright (c) Microsoft Corporation.
#
# Licensed under the MIT license.
# MIT License
#
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
# associated documentation files (the "Software"), to deal in the Software without restriction,
# including without limitation the rights to use, copy, modify, merge, publish, distribute,
# sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all copies or
# substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
# NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
# DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT
# OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
# ==================================================================================================
import
ast
import
ast
import
astor
import
astor
...
...
tools/nni_annotation/test_annotation.py
View file @
cd3a912a
# Copyright (c) Microsoft Corporation. All rights reserved.
# Copyright (c) Microsoft Corporation.
#
# Licensed under the MIT license.
# MIT License
#
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
# associated documentation files (the "Software"), to deal in the Software without restriction,
# including without limitation the rights to use, copy, modify, merge, publish, distribute,
# sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all copies or
# substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
# NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
# DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT
# OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
# ==================================================================================================
# pylint: skip-file
# pylint: skip-file
...
...
tools/nni_cmd/command_utils.py
View file @
cd3a912a
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
from
subprocess
import
call
,
check_output
from
subprocess
import
call
,
check_output
import
sys
import
sys
import
os
import
os
...
...
tools/nni_cmd/common_utils.py
View file @
cd3a912a
# Copyright (c) Microsoft Corporation
# Copyright (c) Microsoft Corporation.
# All rights reserved.
# Licensed under the MIT license.
#
# MIT License
#
# Permission is hereby granted, free of charge,
# to any person obtaining a copy of this software and associated
# documentation files (the "Software"), to deal in the Software without restriction,
# including without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and
# to permit persons to whom the Software is furnished to do so, subject to the following conditions:
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
# BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
# DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
import
os
import
os
import
sys
import
sys
...
@@ -90,4 +73,4 @@ def get_python_dir(sitepackages_path):
...
@@ -90,4 +73,4 @@ def get_python_dir(sitepackages_path):
if
sys
.
platform
==
"win32"
:
if
sys
.
platform
==
"win32"
:
return
str
(
Path
(
sitepackages_path
))
return
str
(
Path
(
sitepackages_path
))
else
:
else
:
return
str
(
Path
(
sitepackages_path
).
parents
[
2
])
return
str
(
Path
(
sitepackages_path
).
parents
[
2
])
\ No newline at end of file
tools/nni_cmd/config_schema.py
View file @
cd3a912a
# Copyright (c) Microsoft Corporation
# Copyright (c) Microsoft Corporation.
# All rights reserved.
# Licensed under the MIT license.
#
# MIT License
#
# Permission is hereby granted, free of charge,
# to any person obtaining a copy of this software and associated
# documentation files (the "Software"), to deal in the Software without restriction,
# including without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and
# to permit persons to whom the Software is furnished to do so, subject to the following conditions:
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
# BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
# DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
import
os
import
os
from
schema
import
Schema
,
And
,
Optional
,
Regex
,
Or
from
schema
import
Schema
,
And
,
Optional
,
Regex
,
Or
...
...
tools/nni_cmd/config_utils.py
View file @
cd3a912a
# Copyright (c) Microsoft Corporation
# Copyright (c) Microsoft Corporation.
# All rights reserved.
# Licensed under the MIT license.
#
# MIT License
#
# Permission is hereby granted, free of charge,
# to any person obtaining a copy of this software and associated
# documentation files (the "Software"), to deal in the Software without restriction,
# including without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and
# to permit persons to whom the Software is furnished to do so, subject to the following conditions:
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
# BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
# DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
import
os
import
os
import
json
import
json
...
...
tools/nni_cmd/constants.py
View file @
cd3a912a
# Copyright (c) Microsoft Corporation
# Copyright (c) Microsoft Corporation.
# All rights reserved.
# Licensed under the MIT license.
#
# MIT License
#
# Permission is hereby granted, free of charge,
# to any person obtaining a copy of this software and associated
# documentation files (the "Software"), to deal in the Software without restriction,
# including without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and
# to permit persons to whom the Software is furnished to do so, subject to the following conditions:
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
# BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
# DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
import
os
import
os
from
colorama
import
Fore
from
colorama
import
Fore
...
...
tools/nni_cmd/launcher.py
View file @
cd3a912a
# Copyright (c) Microsoft Corporation
# Copyright (c) Microsoft Corporation.
# All rights reserved.
# Licensed under the MIT license.
#
# MIT License
#
# Permission is hereby granted, free of charge,
# to any person obtaining a copy of this software and associated
# documentation files (the "Software"), to deal in the Software without restriction,
# including without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and
# to permit persons to whom the Software is furnished to do so, subject to the following conditions:
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
# BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
# DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
import
json
import
json
import
os
import
os
...
@@ -536,4 +518,4 @@ def view_experiment(args):
...
@@ -536,4 +518,4 @@ def view_experiment(args):
def
resume_experiment
(
args
):
def
resume_experiment
(
args
):
'''resume an experiment'''
'''resume an experiment'''
manage_stopped_experiment
(
args
,
'resume'
)
manage_stopped_experiment
(
args
,
'resume'
)
\ No newline at end of file
tools/nni_cmd/launcher_utils.py
View file @
cd3a912a
# Copyright (c) Microsoft Corporation
# Copyright (c) Microsoft Corporation.
# All rights reserved.
# Licensed under the MIT license.
#
# MIT License
#
# Permission is hereby granted, free of charge,
# to any person obtaining a copy of this software and associated
# documentation files (the "Software"), to deal in the Software without restriction,
# including without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and
# to permit persons to whom the Software is furnished to do so, subject to the following conditions:
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
# BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
# DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
import
os
import
os
import
json
import
json
...
...
tools/nni_cmd/nnictl.py
View file @
cd3a912a
# Copyright (c) Microsoft Corporation
# Copyright (c) Microsoft Corporation.
# All rights reserved.
# Licensed under the MIT license.
#
# MIT License
#
# Permission is hereby granted, free of charge,
# to any person obtaining a copy of this software and associated
# documentation files (the "Software"), to deal in the Software without restriction,
# including without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and
# to permit persons to whom the Software is furnished to do so, subject to the following conditions:
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
# BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
# DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
import
argparse
import
argparse
import
os
import
os
...
@@ -28,7 +10,8 @@ from .launcher import create_experiment, resume_experiment, view_experiment
...
@@ -28,7 +10,8 @@ from .launcher import create_experiment, resume_experiment, view_experiment
from
.updater
import
update_searchspace
,
update_concurrency
,
update_duration
,
update_trialnum
,
import_data
from
.updater
import
update_searchspace
,
update_concurrency
,
update_duration
,
update_trialnum
,
import_data
from
.nnictl_utils
import
stop_experiment
,
trial_ls
,
trial_kill
,
list_experiment
,
experiment_status
,
\
from
.nnictl_utils
import
stop_experiment
,
trial_ls
,
trial_kill
,
list_experiment
,
experiment_status
,
\
log_trial
,
experiment_clean
,
platform_clean
,
experiment_list
,
\
log_trial
,
experiment_clean
,
platform_clean
,
experiment_list
,
\
monitor_experiment
,
export_trials_data
,
trial_codegen
,
webui_url
,
get_config
,
log_stdout
,
log_stderr
monitor_experiment
,
export_trials_data
,
trial_codegen
,
webui_url
,
\
get_config
,
log_stdout
,
log_stderr
,
search_space_auto_gen
from
.package_management
import
package_install
,
package_show
from
.package_management
import
package_install
,
package_show
from
.constants
import
DEFAULT_REST_PORT
from
.constants
import
DEFAULT_REST_PORT
from
.tensorboard_utils
import
start_tensorboard
,
stop_tensorboard
from
.tensorboard_utils
import
start_tensorboard
,
stop_tensorboard
...
@@ -56,6 +39,13 @@ def parse_args():
...
@@ -56,6 +39,13 @@ def parse_args():
# create subparsers for args with sub values
# create subparsers for args with sub values
subparsers
=
parser
.
add_subparsers
()
subparsers
=
parser
.
add_subparsers
()
# parse the command of auto generating search space
parser_start
=
subparsers
.
add_parser
(
'ss_gen'
,
help
=
'automatically generate search space file from trial code'
)
parser_start
.
add_argument
(
'--trial_command'
,
'-t'
,
required
=
True
,
dest
=
'trial_command'
,
help
=
'the command for running trial code'
)
parser_start
.
add_argument
(
'--trial_dir'
,
'-d'
,
default
=
'./'
,
dest
=
'trial_dir'
,
help
=
'the directory for running the command'
)
parser_start
.
add_argument
(
'--file'
,
'-f'
,
default
=
'nni_auto_gen_search_space.json'
,
dest
=
'file'
,
help
=
'the path of search space file'
)
parser_start
.
set_defaults
(
func
=
search_space_auto_gen
)
# parse start command
# parse start command
parser_start
=
subparsers
.
add_parser
(
'create'
,
help
=
'create a new experiment'
)
parser_start
=
subparsers
.
add_parser
(
'create'
,
help
=
'create a new experiment'
)
parser_start
.
add_argument
(
'--config'
,
'-c'
,
required
=
True
,
dest
=
'config'
,
help
=
'the path of yaml config file'
)
parser_start
.
add_argument
(
'--config'
,
'-c'
,
required
=
True
,
dest
=
'config'
,
help
=
'the path of yaml config file'
)
...
...
tools/nni_cmd/nnictl_utils.py
View file @
cd3a912a
# Copyright (c) Microsoft Corporation
# Copyright (c) Microsoft Corporation.
# All rights reserved.
# Licensed under the MIT license.
#
# MIT License
#
# Permission is hereby granted, free of charge,
# to any person obtaining a copy of this software and associated
# documentation files (the "Software"), to deal in the Software without restriction,
# including without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and
# to permit persons to whom the Software is furnished to do so, subject to the following conditions:
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
# BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
# DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
import
csv
import
csv
import
os
import
os
...
@@ -26,6 +9,7 @@ import re
...
@@ -26,6 +9,7 @@ import re
import
shutil
import
shutil
from
datetime
import
datetime
,
timezone
from
datetime
import
datetime
,
timezone
from
pathlib
import
Path
from
pathlib
import
Path
from
subprocess
import
Popen
from
pyhdfs
import
HdfsClient
from
pyhdfs
import
HdfsClient
from
nni_annotation
import
expand_annotations
from
nni_annotation
import
expand_annotations
from
.rest_utils
import
rest_get
,
rest_delete
,
check_rest_server_quick
,
check_response
from
.rest_utils
import
rest_get
,
rest_delete
,
check_rest_server_quick
,
check_response
...
@@ -692,3 +676,16 @@ def export_trials_data(args):
...
@@ -692,3 +676,16 @@ def export_trials_data(args):
print_error
(
'Export failed...'
)
print_error
(
'Export failed...'
)
else
:
else
:
print_error
(
'Restful server is not Running'
)
print_error
(
'Restful server is not Running'
)
def
search_space_auto_gen
(
args
):
'''dry run trial code to generate search space file'''
trial_dir
=
os
.
path
.
expanduser
(
args
.
trial_dir
)
file_path
=
os
.
path
.
expanduser
(
args
.
file
)
if
not
os
.
path
.
isabs
(
file_path
):
abs_file_path
=
os
.
path
.
join
(
os
.
getcwd
(),
file_path
)
assert
os
.
path
.
exists
(
trial_dir
)
if
os
.
path
.
exists
(
abs_file_path
):
print_warning
(
'%s already exits, will be over written'
%
abs_file_path
)
print_normal
(
'Dry run to generate search space...'
)
Popen
(
args
.
trial_command
,
cwd
=
trial_dir
,
env
=
dict
(
os
.
environ
,
NNI_GEN_SEARCH_SPACE
=
abs_file_path
),
shell
=
True
).
wait
()
print_normal
(
'Dry run to generate search space, Done'
)
\ No newline at end of file
Prev
1
…
14
15
16
17
18
19
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