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
67453d10
Unverified
Commit
67453d10
authored
Oct 31, 2018
by
SparkSnail
Committed by
GitHub
Oct 31, 2018
Browse files
Show error information and fix paramiko installation (#282)
* fix paramiko install
parent
b07309d9
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
52 additions
and
23 deletions
+52
-23
setup.py
setup.py
+1
-2
tools/bash-completion
tools/bash-completion
+9
-9
tools/nnicmd/launcher.py
tools/nnicmd/launcher.py
+30
-9
tools/nnicmd/ssh_utils.py
tools/nnicmd/ssh_utils.py
+11
-1
tools/setup.py
tools/setup.py
+1
-2
No files found.
setup.py
View file @
67453d10
...
@@ -62,8 +62,7 @@ setup(
...
@@ -62,8 +62,7 @@ setup(
'requests'
,
'requests'
,
'scipy'
,
'scipy'
,
'schema'
,
'schema'
,
'pyhdfs'
,
'pyhdfs'
'paramiko'
],
],
cmdclass
=
{
cmdclass
=
{
...
...
tools/bash-completion
View file @
67453d10
# list of commands/arguments
# list of commands/arguments
__nnictl_cmds="create resume update stop trial experiment config
rest
log"
__nnictl_cmds="create resume update stop trial experiment config
webui
log"
__nnictl_create_cmds="--config --
webui
port"
__nnictl_create_cmds="--config --port"
__nnictl_resume_cmds="--
experiment --manager --webui
port"
__nnictl_resume_cmds="--port"
__nnictl_update_cmds="searchspace concurrency duration"
__nnictl_update_cmds="searchspace concurrency duration
trialnum
"
__nnictl_update_searchspace_cmds="--filename"
__nnictl_update_searchspace_cmds="--filename"
__nnictl_update_concurrency_cmds="--value"
__nnictl_update_concurrency_cmds="--value"
__nnictl_update_duration_cmds="--value"
__nnictl_update_duration_cmds="--value"
__nnictl_update_trialnum_cmds="--value"
__nnictl_trial_cmds="ls kill"
__nnictl_trial_cmds="ls kill"
__nnictl_trial_kill_cmds="--trialid"
__nnictl_trial_kill_cmds="--trialid"
__nnictl_webui_cmds="
start stop
url"
__nnictl_webui_cmds="url"
__nnictl_
webui_start_cmds="--port
"
__nnictl_
experiment_cmds="show list status
"
__nnictl_experiment_cmds="
show
"
__nnictl_experiment_
list_
cmds="
all
"
__nnictl_config_cmds="show"
__nnictl_config_cmds="show"
__nnictl_rest_cmds="check"
__nnictl_log_cmds="stdout stderr trial"
__nnictl_log_cmds="stdout stderr"
__nnictl_log_stdout_cmds="--tail --head --path"
__nnictl_log_stdout_cmds="--tail --head --path"
__nnictl_log_stderr_cmds="--tail --head --path"
__nnictl_log_stderr_cmds="--tail --head --path"
...
...
tools/nnicmd/launcher.py
View file @
67453d10
...
@@ -23,7 +23,7 @@ import json
...
@@ -23,7 +23,7 @@ import json
import
os
import
os
import
shutil
import
shutil
import
string
import
string
from
subprocess
import
Popen
,
PIPE
,
call
from
subprocess
import
Popen
,
PIPE
,
call
,
check_output
import
tempfile
import
tempfile
from
nni_annotation
import
*
from
nni_annotation
import
*
from
.launcher_utils
import
validate_all_content
from
.launcher_utils
import
validate_all_content
...
@@ -36,6 +36,26 @@ import time
...
@@ -36,6 +36,26 @@ import time
import
random
import
random
import
string
import
string
def
get_log_path
(
config_file_name
):
'''generate stdout and stderr log path'''
stdout_full_path
=
os
.
path
.
join
(
NNICTL_HOME_DIR
,
config_file_name
,
'stdout'
)
stderr_full_path
=
os
.
path
.
join
(
NNICTL_HOME_DIR
,
config_file_name
,
'stderr'
)
return
stdout_full_path
,
stderr_full_path
def
print_log_content
(
config_file_name
):
'''print log information'''
stdout_full_path
,
stderr_full_path
=
get_log_path
(
config_file_name
)
print_normal
(
' Stdout:'
)
stdout_cmds
=
[
'cat'
,
stdout_full_path
]
stdout_content
=
check_output
(
stdout_cmds
)
print
(
stdout_content
.
decode
(
'utf-8'
))
print
(
'
\n\n
'
)
print_normal
(
' Stderr:'
)
stderr_cmds
=
[
'cat'
,
stderr_full_path
]
stderr_content
=
check_output
(
stderr_cmds
)
print
(
stderr_content
.
decode
(
'utf-8'
))
def
start_rest_server
(
port
,
platform
,
mode
,
config_file_name
,
experiment_id
=
None
):
def
start_rest_server
(
port
,
platform
,
mode
,
config_file_name
,
experiment_id
=
None
):
'''Run nni manager process'''
'''Run nni manager process'''
nni_config
=
Config
(
config_file_name
)
nni_config
=
Config
(
config_file_name
)
...
@@ -48,8 +68,7 @@ def start_rest_server(port, platform, mode, config_file_name, experiment_id=None
...
@@ -48,8 +68,7 @@ def start_rest_server(port, platform, mode, config_file_name, experiment_id=None
cmds
=
[
manager
,
'--port'
,
str
(
port
),
'--mode'
,
platform
,
'--start_mode'
,
mode
]
cmds
=
[
manager
,
'--port'
,
str
(
port
),
'--mode'
,
platform
,
'--start_mode'
,
mode
]
if
mode
==
'resume'
:
if
mode
==
'resume'
:
cmds
+=
[
'--experiment_id'
,
experiment_id
]
cmds
+=
[
'--experiment_id'
,
experiment_id
]
stdout_full_path
=
os
.
path
.
join
(
NNICTL_HOME_DIR
,
config_file_name
,
'stdout'
)
stdout_full_path
,
stderr_full_path
=
get_log_path
(
config_file_name
)
stderr_full_path
=
os
.
path
.
join
(
NNICTL_HOME_DIR
,
config_file_name
,
'stderr'
)
stdout_file
=
open
(
stdout_full_path
,
'a+'
)
stdout_file
=
open
(
stdout_full_path
,
'a+'
)
stderr_file
=
open
(
stderr_full_path
,
'a+'
)
stderr_file
=
open
(
stderr_full_path
,
'a+'
)
time_now
=
time
.
strftime
(
'%Y-%m-%d %H:%M:%S'
,
time
.
localtime
(
time
.
time
()))
time_now
=
time
.
strftime
(
'%Y-%m-%d %H:%M:%S'
,
time
.
localtime
(
time
.
time
()))
...
@@ -83,7 +102,7 @@ def set_trial_config(experiment_config, port, config_file_name):
...
@@ -83,7 +102,7 @@ def set_trial_config(experiment_config, port, config_file_name):
return
True
return
True
else
:
else
:
print
(
'Error message is {}'
.
format
(
response
.
text
))
print
(
'Error message is {}'
.
format
(
response
.
text
))
stderr_full_path
=
os
.
path
.
join
(
NNICTL_HOME_DIR
,
config_file_name
,
'stderr'
)
_
,
stderr_full_path
=
get_log_path
(
config_file_name
)
with
open
(
stderr_full_path
,
'a+'
)
as
fout
:
with
open
(
stderr_full_path
,
'a+'
)
as
fout
:
fout
.
write
(
json
.
dumps
(
json
.
loads
(
response
.
text
),
indent
=
4
,
sort_keys
=
True
,
separators
=
(
','
,
':'
)))
fout
.
write
(
json
.
dumps
(
json
.
loads
(
response
.
text
),
indent
=
4
,
sort_keys
=
True
,
separators
=
(
','
,
':'
)))
return
False
return
False
...
@@ -102,7 +121,7 @@ def set_remote_config(experiment_config, port, config_file_name):
...
@@ -102,7 +121,7 @@ def set_remote_config(experiment_config, port, config_file_name):
if
not
response
or
not
check_response
(
response
):
if
not
response
or
not
check_response
(
response
):
if
response
is
not
None
:
if
response
is
not
None
:
err_message
=
response
.
text
err_message
=
response
.
text
stderr_full_path
=
os
.
path
.
join
(
NNICTL_HOME_DIR
,
config_file_name
,
'stderr'
)
_
,
stderr_full_path
=
get_log_path
(
config_file_name
)
with
open
(
stderr_full_path
,
'a+'
)
as
fout
:
with
open
(
stderr_full_path
,
'a+'
)
as
fout
:
fout
.
write
(
json
.
dumps
(
json
.
loads
(
err_message
),
indent
=
4
,
sort_keys
=
True
,
separators
=
(
','
,
':'
)))
fout
.
write
(
json
.
dumps
(
json
.
loads
(
err_message
),
indent
=
4
,
sort_keys
=
True
,
separators
=
(
','
,
':'
)))
return
False
,
err_message
return
False
,
err_message
...
@@ -119,7 +138,7 @@ def set_pai_config(experiment_config, port, config_file_name):
...
@@ -119,7 +138,7 @@ def set_pai_config(experiment_config, port, config_file_name):
if
not
response
or
not
response
.
status_code
==
200
:
if
not
response
or
not
response
.
status_code
==
200
:
if
response
is
not
None
:
if
response
is
not
None
:
err_message
=
response
.
text
err_message
=
response
.
text
stderr_full_path
=
os
.
path
.
join
(
NNICTL_HOME_DIR
,
config_file_name
,
'stderr'
)
_
,
stderr_full_path
=
get_log_path
(
config_file_name
)
with
open
(
stderr_full_path
,
'a+'
)
as
fout
:
with
open
(
stderr_full_path
,
'a+'
)
as
fout
:
fout
.
write
(
json
.
dumps
(
json
.
loads
(
err_message
),
indent
=
4
,
sort_keys
=
True
,
separators
=
(
','
,
':'
)))
fout
.
write
(
json
.
dumps
(
json
.
loads
(
err_message
),
indent
=
4
,
sort_keys
=
True
,
separators
=
(
','
,
':'
)))
return
False
,
err_message
return
False
,
err_message
...
@@ -185,7 +204,7 @@ def set_experiment(experiment_config, mode, port, config_file_name):
...
@@ -185,7 +204,7 @@ def set_experiment(experiment_config, mode, port, config_file_name):
if
check_response
(
response
):
if
check_response
(
response
):
return
response
return
response
else
:
else
:
stderr_full_path
=
os
.
path
.
join
(
NNICTL_HOME_DIR
,
config_file_name
,
'stderr'
)
_
,
stderr_full_path
=
get_log_path
(
config_file_name
)
with
open
(
stderr_full_path
,
'a+'
)
as
fout
:
with
open
(
stderr_full_path
,
'a+'
)
as
fout
:
fout
.
write
(
json
.
dumps
(
json
.
loads
(
response
.
text
),
indent
=
4
,
sort_keys
=
True
,
separators
=
(
','
,
':'
)))
fout
.
write
(
json
.
dumps
(
json
.
loads
(
response
.
text
),
indent
=
4
,
sort_keys
=
True
,
separators
=
(
','
,
':'
)))
print_error
(
'Setting experiment error, error message is {}'
.
format
(
response
.
text
))
print_error
(
'Setting experiment error, error message is {}'
.
format
(
response
.
text
))
...
@@ -220,6 +239,7 @@ def launch_experiment(args, experiment_config, mode, config_file_name, experimen
...
@@ -220,6 +239,7 @@ def launch_experiment(args, experiment_config, mode, config_file_name, experimen
print_normal
(
'Successfully started Restful server!'
)
print_normal
(
'Successfully started Restful server!'
)
else
:
else
:
print_error
(
'Restful server start failed!'
)
print_error
(
'Restful server start failed!'
)
print_log_content
(
config_file_name
)
try
:
try
:
cmds
=
[
'pkill'
,
'-P'
,
str
(
rest_process
.
pid
)]
cmds
=
[
'pkill'
,
'-P'
,
str
(
rest_process
.
pid
)]
call
(
cmds
)
call
(
cmds
)
...
@@ -248,7 +268,7 @@ def launch_experiment(args, experiment_config, mode, config_file_name, experimen
...
@@ -248,7 +268,7 @@ def launch_experiment(args, experiment_config, mode, config_file_name, experimen
if
set_local_config
(
experiment_config
,
args
.
port
,
config_file_name
):
if
set_local_config
(
experiment_config
,
args
.
port
,
config_file_name
):
print_normal
(
'Successfully set local config!'
)
print_normal
(
'Successfully set local config!'
)
else
:
else
:
print_error
(
'
F
ailed!'
)
print_error
(
'
Set local config f
ailed!'
)
try
:
try
:
cmds
=
[
'pkill'
,
'-P'
,
str
(
rest_process
.
pid
)]
cmds
=
[
'pkill'
,
'-P'
,
str
(
rest_process
.
pid
)]
call
(
cmds
)
call
(
cmds
)
...
@@ -280,7 +300,8 @@ def launch_experiment(args, experiment_config, mode, config_file_name, experimen
...
@@ -280,7 +300,8 @@ def launch_experiment(args, experiment_config, mode, config_file_name, experimen
experiment_id
=
json
.
loads
(
response
.
text
).
get
(
'experiment_id'
)
experiment_id
=
json
.
loads
(
response
.
text
).
get
(
'experiment_id'
)
nni_config
.
set_config
(
'experimentId'
,
experiment_id
)
nni_config
.
set_config
(
'experimentId'
,
experiment_id
)
else
:
else
:
print_error
(
'Failed!'
)
print_error
(
'Start experiment failed!'
)
print_log_content
(
config_file_name
)
try
:
try
:
cmds
=
[
'pkill'
,
'-P'
,
str
(
rest_process
.
pid
)]
cmds
=
[
'pkill'
,
'-P'
,
str
(
rest_process
.
pid
)]
call
(
cmds
)
call
(
cmds
)
...
...
tools/nnicmd/ssh_utils.py
View file @
67453d10
...
@@ -18,9 +18,17 @@
...
@@ -18,9 +18,17 @@
# DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# 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.
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
import
paramiko
import
os
import
os
from
.common_utils
import
print_error
from
.common_utils
import
print_error
from
subprocess
import
call
def
check_environment
():
'''check if paramiko is installed'''
try
:
import
paramiko
except
:
cmds
=
'python3 -m pip install --user paramiko'
call
(
cmds
,
shell
=
True
)
def
copy_remote_directory_to_local
(
sftp
,
remote_path
,
local_path
):
def
copy_remote_directory_to_local
(
sftp
,
remote_path
,
local_path
):
'''copy remote directory to local machine'''
'''copy remote directory to local machine'''
...
@@ -41,6 +49,8 @@ def copy_remote_directory_to_local(sftp, remote_path, local_path):
...
@@ -41,6 +49,8 @@ def copy_remote_directory_to_local(sftp, remote_path, local_path):
def
create_ssh_sftp_client
(
host_ip
,
port
,
username
,
password
):
def
create_ssh_sftp_client
(
host_ip
,
port
,
username
,
password
):
'''create ssh client'''
'''create ssh client'''
try
:
try
:
check_environment
()
import
paramiko
conn
=
paramiko
.
Transport
(
host_ip
,
port
)
conn
=
paramiko
.
Transport
(
host_ip
,
port
)
conn
.
connect
(
username
=
username
,
password
=
password
)
conn
.
connect
(
username
=
username
,
password
=
password
)
sftp
=
paramiko
.
SFTPClient
.
from_transport
(
conn
)
sftp
=
paramiko
.
SFTPClient
.
from_transport
(
conn
)
...
...
tools/setup.py
View file @
67453d10
...
@@ -12,8 +12,7 @@ setuptools.setup(
...
@@ -12,8 +12,7 @@ setuptools.setup(
'psutil'
,
'psutil'
,
'astor'
,
'astor'
,
'schema'
,
'schema'
,
'pyhdfs'
,
'pyhdfs'
'paramiko'
],
],
author
=
'Microsoft NNI Team'
,
author
=
'Microsoft NNI Team'
,
...
...
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