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
44ab774d
"awq/modules/git@developer.sourcefind.cn:OpenDAS/autoawq.git" did not exist on "0392a823775734116d2d1cc1d9eed98173c64ba0"
Unverified
Commit
44ab774d
authored
Oct 31, 2018
by
SparkSnail
Committed by
GitHub
Oct 31, 2018
Browse files
Quick fix resume logic (#285)
parent
b7028549
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
25 deletions
+9
-25
tools/nnicmd/launcher.py
tools/nnicmd/launcher.py
+9
-25
No files found.
tools/nnicmd/launcher.py
View file @
44ab774d
...
@@ -110,8 +110,9 @@ def set_trial_config(experiment_config, port, config_file_name):
...
@@ -110,8 +110,9 @@ def set_trial_config(experiment_config, port, config_file_name):
else
:
else
:
print
(
'Error message is {}'
.
format
(
response
.
text
))
print
(
'Error message is {}'
.
format
(
response
.
text
))
_
,
stderr_full_path
=
get_log_path
(
config_file_name
)
_
,
stderr_full_path
=
get_log_path
(
config_file_name
)
with
open
(
stderr_full_path
,
'a+'
)
as
fout
:
if
response
:
fout
.
write
(
json
.
dumps
(
json
.
loads
(
response
.
text
),
indent
=
4
,
sort_keys
=
True
,
separators
=
(
','
,
':'
)))
with
open
(
stderr_full_path
,
'a+'
)
as
fout
:
fout
.
write
(
json
.
dumps
(
json
.
loads
(
response
.
text
),
indent
=
4
,
sort_keys
=
True
,
separators
=
(
','
,
':'
)))
return
False
return
False
def
set_local_config
(
experiment_config
,
port
,
config_file_name
):
def
set_local_config
(
experiment_config
,
port
,
config_file_name
):
...
@@ -212,8 +213,9 @@ def set_experiment(experiment_config, mode, port, config_file_name):
...
@@ -212,8 +213,9 @@ def set_experiment(experiment_config, mode, port, config_file_name):
return
response
return
response
else
:
else
:
_
,
stderr_full_path
=
get_log_path
(
config_file_name
)
_
,
stderr_full_path
=
get_log_path
(
config_file_name
)
with
open
(
stderr_full_path
,
'a+'
)
as
fout
:
if
response
:
fout
.
write
(
json
.
dumps
(
json
.
loads
(
response
.
text
),
indent
=
4
,
sort_keys
=
True
,
separators
=
(
','
,
':'
)))
with
open
(
stderr_full_path
,
'a+'
)
as
fout
:
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
))
return
None
return
None
...
@@ -324,15 +326,6 @@ def launch_experiment(args, experiment_config, mode, config_file_name, experimen
...
@@ -324,15 +326,6 @@ def launch_experiment(args, experiment_config, mode, config_file_name, experimen
print_normal
(
EXPERIMENT_SUCCESS_INFO
%
(
experiment_id
,
' '
.
join
(
web_ui_url_list
)))
print_normal
(
EXPERIMENT_SUCCESS_INFO
%
(
experiment_id
,
' '
.
join
(
web_ui_url_list
)))
def
cmp_time
(
time1
,
time2
):
'''compare the time'''
try
:
time1
=
time
.
strptime
(
time1
,
'%Y-%m-%d %H:%M:%S'
)
time2
=
time
.
strptime
(
time2
,
'%Y-%m-%d %H:%M:%S'
)
return
int
(
time1
)
-
int
(
time2
)
except
:
return
0
def
resume_experiment
(
args
):
def
resume_experiment
(
args
):
'''resume an experiment'''
'''resume an experiment'''
experiment_config
=
Experiments
()
experiment_config
=
Experiments
()
...
@@ -341,18 +334,9 @@ def resume_experiment(args):
...
@@ -341,18 +334,9 @@ def resume_experiment(args):
experiment_endTime
=
None
experiment_endTime
=
None
#find the latest stopped experiment
#find the latest stopped experiment
if
not
args
.
id
:
if
not
args
.
id
:
for
key
in
experiment_dict
.
keys
():
print_error
(
'Please set experiment id!
\n
You could use
\'
nnictl resume {id}
\'
to resume a stopped experiment!
\n
'
\
if
experiment_dict
[
key
][
'status'
]
==
'stopped'
:
'You could use
\'
nnictl experiment list all
\'
to show all of stopped experiments!'
)
if
experiment_id
is
None
:
exit
(
1
)
experiment_id
=
key
experiment_endTime
=
experiment_dict
[
key
][
'endTime'
]
else
:
if
cmp_time
(
experiment_dict
[
key
][
'endTime'
],
experiment_endTime
)
>
0
:
experiment_id
=
key
experiment_endTime
=
experiment_dict
[
key
][
'endTime'
]
if
experiment_id
is
None
:
print_error
(
'There is no experiment stopped!'
)
exit
(
1
)
else
:
else
:
if
experiment_dict
.
get
(
args
.
id
)
is
None
:
if
experiment_dict
.
get
(
args
.
id
)
is
None
:
print_error
(
'Id %s not exist!'
%
args
.
id
)
print_error
(
'Id %s not exist!'
%
args
.
id
)
...
...
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