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
e267a737
Commit
e267a737
authored
May 30, 2019
by
Mohit Anand
Committed by
xuehui
May 30, 2019
Browse files
Changed file opening syntax to use with open(filename, mode) (#1126)
parent
5a058baf
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
17 deletions
+14
-17
tools/nni_cmd/launcher.py
tools/nni_cmd/launcher.py
+11
-12
tools/nni_cmd/tensorboard_utils.py
tools/nni_cmd/tensorboard_utils.py
+3
-5
No files found.
tools/nni_cmd/launcher.py
View file @
e267a737
...
@@ -125,18 +125,17 @@ def start_rest_server(port, platform, mode, config_file_name, experiment_id=None
...
@@ -125,18 +125,17 @@ def start_rest_server(port, platform, mode, config_file_name, experiment_id=None
if
mode
==
'resume'
:
if
mode
==
'resume'
:
cmds
+=
[
'--experiment_id'
,
experiment_id
]
cmds
+=
[
'--experiment_id'
,
experiment_id
]
stdout_full_path
,
stderr_full_path
=
get_log_path
(
config_file_name
)
stdout_full_path
,
stderr_full_path
=
get_log_path
(
config_file_name
)
stdout_file
=
open
(
stdout_full_path
,
'a+'
)
with
open
(
stdout_full_path
,
'a+'
)
as
stdout_file
,
open
(
stderr_full_path
,
'a+'
)
as
stderr_file
:
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
()))
#add time information in the header of log files
#add time information in the header of log files
log_header
=
LOG_HEADER
%
str
(
time_now
)
log_header
=
LOG_HEADER
%
str
(
time_now
)
stdout_file
.
write
(
log_header
)
stdout_file
.
write
(
log_header
)
stderr_file
.
write
(
log_header
)
stderr_file
.
write
(
log_header
)
if
sys
.
platform
==
'win32'
:
if
sys
.
platform
==
'win32'
:
from
subprocess
import
CREATE_NEW_PROCESS_GROUP
from
subprocess
import
CREATE_NEW_PROCESS_GROUP
process
=
Popen
(
cmds
,
cwd
=
entry_dir
,
stdout
=
stdout_file
,
stderr
=
stderr_file
,
creationflags
=
CREATE_NEW_PROCESS_GROUP
)
process
=
Popen
(
cmds
,
cwd
=
entry_dir
,
stdout
=
stdout_file
,
stderr
=
stderr_file
,
creationflags
=
CREATE_NEW_PROCESS_GROUP
)
else
:
else
:
process
=
Popen
(
cmds
,
cwd
=
entry_dir
,
stdout
=
stdout_file
,
stderr
=
stderr_file
)
process
=
Popen
(
cmds
,
cwd
=
entry_dir
,
stdout
=
stdout_file
,
stderr
=
stderr_file
)
return
process
,
str
(
time_now
)
return
process
,
str
(
time_now
)
def
set_trial_config
(
experiment_config
,
port
,
config_file_name
):
def
set_trial_config
(
experiment_config
,
port
,
config_file_name
):
...
...
tools/nni_cmd/tensorboard_utils.py
View file @
e267a737
...
@@ -94,11 +94,9 @@ def start_tensorboard_process(args, nni_config, path_list, temp_nni_path):
...
@@ -94,11 +94,9 @@ def start_tensorboard_process(args, nni_config, path_list, temp_nni_path):
if
detect_port
(
args
.
port
):
if
detect_port
(
args
.
port
):
print_error
(
'Port %s is used by another process, please reset port!'
%
str
(
args
.
port
))
print_error
(
'Port %s is used by another process, please reset port!'
%
str
(
args
.
port
))
exit
(
1
)
exit
(
1
)
with
open
(
os
.
path
.
join
(
temp_nni_path
,
'tensorboard_stdout'
),
'a+'
)
as
stdout_file
,
open
(
os
.
path
.
join
(
temp_nni_path
,
'tensorboard_stderr'
),
'a+'
)
as
stderr_file
:
stdout_file
=
open
(
os
.
path
.
join
(
temp_nni_path
,
'tensorboard_stdout'
),
'a+'
)
cmds
=
[
'tensorboard'
,
'--logdir'
,
format_tensorboard_log_path
(
path_list
),
'--port'
,
str
(
args
.
port
)]
stderr_file
=
open
(
os
.
path
.
join
(
temp_nni_path
,
'tensorboard_stderr'
),
'a+'
)
tensorboard_process
=
Popen
(
cmds
,
stdout
=
stdout_file
,
stderr
=
stderr_file
)
cmds
=
[
'tensorboard'
,
'--logdir'
,
format_tensorboard_log_path
(
path_list
),
'--port'
,
str
(
args
.
port
)]
tensorboard_process
=
Popen
(
cmds
,
stdout
=
stdout_file
,
stderr
=
stderr_file
)
url_list
=
get_local_urls
(
args
.
port
)
url_list
=
get_local_urls
(
args
.
port
)
print_normal
(
COLOR_GREEN_FORMAT
%
'Start tensorboard success!
\n
'
+
'Tensorboard urls: '
+
' '
.
join
(
url_list
))
print_normal
(
COLOR_GREEN_FORMAT
%
'Start tensorboard success!
\n
'
+
'Tensorboard urls: '
+
' '
.
join
(
url_list
))
tensorboard_process_pid_list
=
nni_config
.
get_config
(
'tensorboardPidList'
)
tensorboard_process_pid_list
=
nni_config
.
get_config
(
'tensorboardPidList'
)
...
...
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