Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
OpenDAS
nni
Commits
ba8dccd6
Commit
ba8dccd6
authored
Jun 23, 2019
by
suiguoxin
Browse files
Merge branch 'master' of
https://github.com/microsoft/nni
parents
56a1575b
150ee83a
Changes
208
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
27 additions
and
27 deletions
+27
-27
tools/nni_cmd/nnictl_utils.py
tools/nni_cmd/nnictl_utils.py
+2
-2
tools/nni_cmd/package_management.py
tools/nni_cmd/package_management.py
+2
-2
tools/nni_cmd/updater.py
tools/nni_cmd/updater.py
+1
-1
tools/nni_trial_tool/hdfsClientUtility.py
tools/nni_trial_tool/hdfsClientUtility.py
+3
-3
tools/nni_trial_tool/log_utils.py
tools/nni_trial_tool/log_utils.py
+4
-4
tools/nni_trial_tool/test/test_hdfsClientUtility.py
tools/nni_trial_tool/test/test_hdfsClientUtility.py
+12
-12
tools/nni_trial_tool/trial_keeper.py
tools/nni_trial_tool/trial_keeper.py
+2
-2
uninstall.ps1
uninstall.ps1
+1
-1
No files found.
tools/nni_cmd/nnictl_utils.py
View file @
ba8dccd6
...
@@ -321,7 +321,7 @@ def log_internal(args, filetype):
...
@@ -321,7 +321,7 @@ def log_internal(args, filetype):
else
:
else
:
file_full_path
=
os
.
path
.
join
(
NNICTL_HOME_DIR
,
file_name
,
'stderr'
)
file_full_path
=
os
.
path
.
join
(
NNICTL_HOME_DIR
,
file_name
,
'stderr'
)
print
(
check_output_command
(
file_full_path
,
head
=
args
.
head
,
tail
=
args
.
tail
))
print
(
check_output_command
(
file_full_path
,
head
=
args
.
head
,
tail
=
args
.
tail
))
def
log_stdout
(
args
):
def
log_stdout
(
args
):
'''get stdout log'''
'''get stdout log'''
log_internal
(
args
,
'stdout'
)
log_internal
(
args
,
'stdout'
)
...
@@ -393,7 +393,7 @@ def experiment_list(args):
...
@@ -393,7 +393,7 @@ def experiment_list(args):
print_warning
(
'There is no experiment running...
\n
You can use
\'
nnictl experiment list all
\'
to list all stopped experiments!'
)
print_warning
(
'There is no experiment running...
\n
You can use
\'
nnictl experiment list all
\'
to list all stopped experiments!'
)
experiment_information
=
""
experiment_information
=
""
for
key
in
experiment_id_list
:
for
key
in
experiment_id_list
:
experiment_information
+=
(
EXPERIMENT_DETAIL_FORMAT
%
(
key
,
experiment_dict
[
key
][
'status'
],
experiment_dict
[
key
][
'port'
],
\
experiment_information
+=
(
EXPERIMENT_DETAIL_FORMAT
%
(
key
,
experiment_dict
[
key
][
'status'
],
experiment_dict
[
key
][
'port'
],
\
experiment_dict
[
key
].
get
(
'platform'
),
experiment_dict
[
key
][
'startTime'
],
experiment_dict
[
key
][
'endTime'
]))
experiment_dict
[
key
].
get
(
'platform'
),
experiment_dict
[
key
][
'startTime'
],
experiment_dict
[
key
][
'endTime'
]))
print
(
EXPERIMENT_INFORMATION_FORMAT
%
experiment_information
)
print
(
EXPERIMENT_INFORMATION_FORMAT
%
experiment_information
)
...
...
tools/nni_cmd/package_management.py
View file @
ba8dccd6
...
@@ -36,8 +36,8 @@ def process_install(package_name):
...
@@ -36,8 +36,8 @@ def process_install(package_name):
def
package_install
(
args
):
def
package_install
(
args
):
'''install packages'''
'''install packages'''
process_install
(
args
.
name
)
process_install
(
args
.
name
)
def
package_show
(
args
):
def
package_show
(
args
):
'''show all packages'''
'''show all packages'''
print
(
' '
.
join
(
PACKAGE_REQUIREMENTS
.
keys
()))
print
(
' '
.
join
(
PACKAGE_REQUIREMENTS
.
keys
()))
tools/nni_cmd/updater.py
View file @
ba8dccd6
...
@@ -112,7 +112,7 @@ def update_concurrency(args):
...
@@ -112,7 +112,7 @@ def update_concurrency(args):
print_error
(
'Update %s failed!'
%
'concurrency'
)
print_error
(
'Update %s failed!'
%
'concurrency'
)
def
update_duration
(
args
):
def
update_duration
(
args
):
#parse time, change time unit to seconds
#parse time, change time unit to seconds
args
.
value
=
parse_time
(
args
.
value
)
args
.
value
=
parse_time
(
args
.
value
)
args
.
port
=
get_experiment_port
(
args
)
args
.
port
=
get_experiment_port
(
args
)
if
args
.
port
is
not
None
:
if
args
.
port
is
not
None
:
...
...
tools/nni_trial_tool/hdfsClientUtility.py
View file @
ba8dccd6
...
@@ -40,16 +40,16 @@ def copyHdfsDirectoryToLocal(hdfsDirectory, localDirectory, hdfsClient):
...
@@ -40,16 +40,16 @@ def copyHdfsDirectoryToLocal(hdfsDirectory, localDirectory, hdfsClient):
copyHdfsDirectoryToLocal
(
subHdfsDirectory
,
subLocalDirectory
,
hdfsClient
)
copyHdfsDirectoryToLocal
(
subHdfsDirectory
,
subLocalDirectory
,
hdfsClient
)
elif
f
.
type
==
'FILE'
:
elif
f
.
type
==
'FILE'
:
hdfsFilePath
=
posixpath
.
join
(
hdfsDirectory
,
f
.
pathSuffix
)
hdfsFilePath
=
posixpath
.
join
(
hdfsDirectory
,
f
.
pathSuffix
)
localFilePath
=
os
.
path
.
join
(
localDirectory
,
f
.
pathSuffix
)
localFilePath
=
os
.
path
.
join
(
localDirectory
,
f
.
pathSuffix
)
copyHdfsFileToLocal
(
hdfsFilePath
,
localFilePath
,
hdfsClient
)
copyHdfsFileToLocal
(
hdfsFilePath
,
localFilePath
,
hdfsClient
)
else
:
else
:
raise
AssertionError
(
'unexpected type {}'
.
format
(
f
.
type
))
raise
AssertionError
(
'unexpected type {}'
.
format
(
f
.
type
))
def
copyHdfsFileToLocal
(
hdfsFilePath
,
localFilePath
,
hdfsClient
,
override
=
True
):
def
copyHdfsFileToLocal
(
hdfsFilePath
,
localFilePath
,
hdfsClient
,
override
=
True
):
'''Copy file from HDFS to local'''
'''Copy file from HDFS to local'''
if
not
hdfsClient
.
exists
(
hdfsFilePath
):
if
not
hdfsClient
.
exists
(
hdfsFilePath
):
raise
Exception
(
'HDFS file {} does not exist!'
.
format
(
hdfsFilePath
))
raise
Exception
(
'HDFS file {} does not exist!'
.
format
(
hdfsFilePath
))
try
:
try
:
file_status
=
hdfsClient
.
get_file_status
(
hdfsFilePath
)
file_status
=
hdfsClient
.
get_file_status
(
hdfsFilePath
)
if
file_status
.
type
!=
'FILE'
:
if
file_status
.
type
!=
'FILE'
:
raise
Exception
(
'HDFS file path {} is not a file'
.
format
(
hdfsFilePath
))
raise
Exception
(
'HDFS file path {} is not a file'
.
format
(
hdfsFilePath
))
...
...
tools/nni_trial_tool/log_utils.py
View file @
ba8dccd6
...
@@ -142,7 +142,7 @@ class PipeLogReader(threading.Thread):
...
@@ -142,7 +142,7 @@ class PipeLogReader(threading.Thread):
'''
'''
time
.
sleep
(
5
)
time
.
sleep
(
5
)
while
True
:
while
True
:
cur_process_exit
=
self
.
process_exit
cur_process_exit
=
self
.
process_exit
try
:
try
:
line
=
self
.
queue
.
get
(
True
,
5
)
line
=
self
.
queue
.
get
(
True
,
5
)
try
:
try
:
...
@@ -150,7 +150,7 @@ class PipeLogReader(threading.Thread):
...
@@ -150,7 +150,7 @@ class PipeLogReader(threading.Thread):
except
Exception
as
e
:
except
Exception
as
e
:
pass
pass
except
Exception
as
e
:
except
Exception
as
e
:
if
cur_process_exit
==
True
:
if
cur_process_exit
==
True
:
self
.
_is_read_completed
=
True
self
.
_is_read_completed
=
True
break
break
...
@@ -177,7 +177,7 @@ class PipeLogReader(threading.Thread):
...
@@ -177,7 +177,7 @@ class PipeLogReader(threading.Thread):
if
not
self
.
log_pattern
.
match
(
line
):
if
not
self
.
log_pattern
.
match
(
line
):
continue
continue
self
.
queue
.
put
(
line
)
self
.
queue
.
put
(
line
)
self
.
pipeReader
.
close
()
self
.
pipeReader
.
close
()
def
close
(
self
):
def
close
(
self
):
...
@@ -190,7 +190,7 @@ class PipeLogReader(threading.Thread):
...
@@ -190,7 +190,7 @@ class PipeLogReader(threading.Thread):
"""Return if read is completed
"""Return if read is completed
"""
"""
return
self
.
_is_read_completed
return
self
.
_is_read_completed
def
set_process_exit
(
self
):
def
set_process_exit
(
self
):
self
.
process_exit
=
True
self
.
process_exit
=
True
return
self
.
process_exit
return
self
.
process_exit
\ No newline at end of file
tools/nni_trial_tool/test/test_hdfsClientUtility.py
View file @
ba8dccd6
...
@@ -39,9 +39,9 @@ class HDFSClientUtilityTest(unittest.TestCase):
...
@@ -39,9 +39,9 @@ class HDFSClientUtilityTest(unittest.TestCase):
self
.
hdfs_config
=
json
.
load
(
file
)
self
.
hdfs_config
=
json
.
load
(
file
)
except
Exception
as
exception
:
except
Exception
as
exception
:
print
(
exception
)
print
(
exception
)
self
.
hdfs_client
=
HdfsClient
(
hosts
=
'{0}:{1}'
.
format
(
self
.
hdfs_config
[
'host'
],
'50070'
),
user_name
=
self
.
hdfs_config
[
'userName'
])
self
.
hdfs_client
=
HdfsClient
(
hosts
=
'{0}:{1}'
.
format
(
self
.
hdfs_config
[
'host'
],
'50070'
),
user_name
=
self
.
hdfs_config
[
'userName'
])
def
get_random_name
(
self
,
length
):
def
get_random_name
(
self
,
length
):
return
''
.
join
(
random
.
sample
(
string
.
ascii_letters
+
string
.
digits
,
length
))
return
''
.
join
(
random
.
sample
(
string
.
ascii_letters
+
string
.
digits
,
length
))
...
@@ -49,20 +49,20 @@ class HDFSClientUtilityTest(unittest.TestCase):
...
@@ -49,20 +49,20 @@ class HDFSClientUtilityTest(unittest.TestCase):
'''test copyFileToHdfs'''
'''test copyFileToHdfs'''
file_name
=
self
.
get_random_name
(
8
)
file_name
=
self
.
get_random_name
(
8
)
file_content
=
'hello world!'
file_content
=
'hello world!'
with
open
(
'./{}'
.
format
(
file_name
),
'w'
)
as
file
:
with
open
(
'./{}'
.
format
(
file_name
),
'w'
)
as
file
:
file
.
write
(
file_content
)
file
.
write
(
file_content
)
result
=
copyFileToHdfs
(
'./{}'
.
format
(
file_name
),
'/{0}/{1}'
.
format
(
self
.
hdfs_config
[
'userName'
],
file_name
),
self
.
hdfs_client
)
result
=
copyFileToHdfs
(
'./{}'
.
format
(
file_name
),
'/{0}/{1}'
.
format
(
self
.
hdfs_config
[
'userName'
],
file_name
),
self
.
hdfs_client
)
self
.
assertTrue
(
result
)
self
.
assertTrue
(
result
)
file_list
=
self
.
hdfs_client
.
listdir
(
'/{0}'
.
format
(
self
.
hdfs_config
[
'userName'
]))
file_list
=
self
.
hdfs_client
.
listdir
(
'/{0}'
.
format
(
self
.
hdfs_config
[
'userName'
]))
self
.
assertIn
(
file_name
,
file_list
)
self
.
assertIn
(
file_name
,
file_list
)
hdfs_file_name
=
self
.
get_random_name
(
8
)
hdfs_file_name
=
self
.
get_random_name
(
8
)
self
.
hdfs_client
.
copy_to_local
(
'/{0}/{1}'
.
format
(
self
.
hdfs_config
[
'userName'
],
file_name
),
'./{}'
.
format
(
hdfs_file_name
))
self
.
hdfs_client
.
copy_to_local
(
'/{0}/{1}'
.
format
(
self
.
hdfs_config
[
'userName'
],
file_name
),
'./{}'
.
format
(
hdfs_file_name
))
self
.
assertTrue
(
os
.
path
.
exists
(
'./{}'
.
format
(
hdfs_file_name
)))
self
.
assertTrue
(
os
.
path
.
exists
(
'./{}'
.
format
(
hdfs_file_name
)))
with
open
(
'./{}'
.
format
(
hdfs_file_name
),
'r'
)
as
file
:
with
open
(
'./{}'
.
format
(
hdfs_file_name
),
'r'
)
as
file
:
content
=
file
.
readline
()
content
=
file
.
readline
()
self
.
assertEqual
(
file_content
,
content
)
self
.
assertEqual
(
file_content
,
content
)
...
@@ -70,21 +70,21 @@ class HDFSClientUtilityTest(unittest.TestCase):
...
@@ -70,21 +70,21 @@ class HDFSClientUtilityTest(unittest.TestCase):
os
.
remove
(
'./{}'
.
format
(
file_name
))
os
.
remove
(
'./{}'
.
format
(
file_name
))
os
.
remove
(
'./{}'
.
format
(
hdfs_file_name
))
os
.
remove
(
'./{}'
.
format
(
hdfs_file_name
))
self
.
hdfs_client
.
delete
(
'/{0}/{1}'
.
format
(
self
.
hdfs_config
[
'userName'
],
file_name
))
self
.
hdfs_client
.
delete
(
'/{0}/{1}'
.
format
(
self
.
hdfs_config
[
'userName'
],
file_name
))
def
test_copy_directory_run
(
self
):
def
test_copy_directory_run
(
self
):
'''test copyDirectoryToHdfs'''
'''test copyDirectoryToHdfs'''
directory_name
=
self
.
get_random_name
(
8
)
directory_name
=
self
.
get_random_name
(
8
)
file_name_list
=
[
self
.
get_random_name
(
8
),
self
.
get_random_name
(
8
)]
file_name_list
=
[
self
.
get_random_name
(
8
),
self
.
get_random_name
(
8
)]
file_content
=
'hello world!'
file_content
=
'hello world!'
os
.
makedirs
(
'./{}'
.
format
(
directory_name
))
os
.
makedirs
(
'./{}'
.
format
(
directory_name
))
for
file_name
in
file_name_list
:
for
file_name
in
file_name_list
:
with
open
(
'./{0}/{1}'
.
format
(
directory_name
,
file_name
),
'w'
)
as
file
:
with
open
(
'./{0}/{1}'
.
format
(
directory_name
,
file_name
),
'w'
)
as
file
:
file
.
write
(
file_content
)
file
.
write
(
file_content
)
result
=
copyDirectoryToHdfs
(
'./{}'
.
format
(
directory_name
),
'/{0}/{1}'
.
format
(
self
.
hdfs_config
[
'userName'
],
directory_name
),
self
.
hdfs_client
)
result
=
copyDirectoryToHdfs
(
'./{}'
.
format
(
directory_name
),
'/{0}/{1}'
.
format
(
self
.
hdfs_config
[
'userName'
],
directory_name
),
self
.
hdfs_client
)
self
.
assertTrue
(
result
)
self
.
assertTrue
(
result
)
directory_list
=
self
.
hdfs_client
.
listdir
(
'/{0}'
.
format
(
self
.
hdfs_config
[
'userName'
]))
directory_list
=
self
.
hdfs_client
.
listdir
(
'/{0}'
.
format
(
self
.
hdfs_config
[
'userName'
]))
self
.
assertIn
(
directory_name
,
directory_list
)
self
.
assertIn
(
directory_name
,
directory_list
)
...
@@ -94,7 +94,7 @@ class HDFSClientUtilityTest(unittest.TestCase):
...
@@ -94,7 +94,7 @@ class HDFSClientUtilityTest(unittest.TestCase):
#clean up
#clean up
self
.
hdfs_client
.
delete
(
'/{0}/{1}/{2}'
.
format
(
self
.
hdfs_config
[
'userName'
],
directory_name
,
file_name
))
self
.
hdfs_client
.
delete
(
'/{0}/{1}/{2}'
.
format
(
self
.
hdfs_config
[
'userName'
],
directory_name
,
file_name
))
self
.
hdfs_client
.
delete
(
'/{0}/{1}'
.
format
(
self
.
hdfs_config
[
'userName'
],
directory_name
))
self
.
hdfs_client
.
delete
(
'/{0}/{1}'
.
format
(
self
.
hdfs_config
[
'userName'
],
directory_name
))
shutil
.
rmtree
(
'./{}'
.
format
(
directory_name
))
shutil
.
rmtree
(
'./{}'
.
format
(
directory_name
))
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
...
...
tools/nni_trial_tool/trial_keeper.py
View file @
ba8dccd6
...
@@ -42,10 +42,10 @@ regular = re.compile('v?(?P<version>[0-9](\.[0-9]){0,1}).*')
...
@@ -42,10 +42,10 @@ regular = re.compile('v?(?P<version>[0-9](\.[0-9]){0,1}).*')
def
main_loop
(
args
):
def
main_loop
(
args
):
'''main loop logic for trial keeper'''
'''main loop logic for trial keeper'''
if
not
os
.
path
.
exists
(
LOG_DIR
):
if
not
os
.
path
.
exists
(
LOG_DIR
):
os
.
makedirs
(
LOG_DIR
)
os
.
makedirs
(
LOG_DIR
)
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+'
)
trial_keeper_syslogger
=
RemoteLogger
(
args
.
nnimanager_ip
,
args
.
nnimanager_port
,
'trial_keeper'
,
StdOutputType
.
Stdout
,
args
.
log_collection
)
trial_keeper_syslogger
=
RemoteLogger
(
args
.
nnimanager_ip
,
args
.
nnimanager_port
,
'trial_keeper'
,
StdOutputType
.
Stdout
,
args
.
log_collection
)
...
...
uninstall.ps1
View file @
ba8dccd6
...
@@ -15,7 +15,7 @@ else{
...
@@ -15,7 +15,7 @@ else{
$PIP_UNINSTALL
=
"""
$NNI_PYTHON3
\python"" -m pip uninstall -y "
$PIP_UNINSTALL
=
"""
$NNI_PYTHON3
\python"" -m pip uninstall -y "
$NNI_NODE_FOLDER
=
$NNI_DEPENDENCY_FOLDER
+
"\nni-node"
$NNI_NODE_FOLDER
=
$NNI_DEPENDENCY_FOLDER
+
"\nni-node"
$NNI_YARN_FOLDER
=
$NNI_DEPENDENCY_FOLDER
+
"\nni-yarn"
$NNI_YARN_FOLDER
=
$NNI_DEPENDENCY_FOLDER
+
"\nni-yarn"
# uninstall
# uninstall
Remove-Item
$NNI_PKG_FOLDER
-Recurse
-Force
Remove-Item
$NNI_PKG_FOLDER
-Recurse
-Force
cmd
/C
$PIP_UNINSTALL
"nni"
cmd
/C
$PIP_UNINSTALL
"nni"
...
...
Prev
1
…
7
8
9
10
11
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