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
85cb472e
Commit
85cb472e
authored
Jan 08, 2019
by
Shinai Yang (FA TALENT)
Browse files
Merge branch 'master' of
https://github.com/SparkSnail/nni
parents
85c015dc
2c862dcb
Changes
41
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
1467 additions
and
187 deletions
+1467
-187
src/sdk/pynni/nni/metis_tuner/Regression_GP/Prediction.py
src/sdk/pynni/nni/metis_tuner/Regression_GP/Prediction.py
+37
-0
src/sdk/pynni/nni/metis_tuner/Regression_GP/Selection.py
src/sdk/pynni/nni/metis_tuner/Regression_GP/Selection.py
+114
-0
src/sdk/pynni/nni/metis_tuner/Regression_GP/__init__.py
src/sdk/pynni/nni/metis_tuner/Regression_GP/__init__.py
+0
-0
src/sdk/pynni/nni/metis_tuner/lib_acquisition_function.py
src/sdk/pynni/nni/metis_tuner/lib_acquisition_function.py
+202
-0
src/sdk/pynni/nni/metis_tuner/lib_constraint_summation.py
src/sdk/pynni/nni/metis_tuner/lib_constraint_summation.py
+116
-0
src/sdk/pynni/nni/metis_tuner/lib_data.py
src/sdk/pynni/nni/metis_tuner/lib_data.py
+67
-0
src/sdk/pynni/nni/metis_tuner/metis_tuner.py
src/sdk/pynni/nni/metis_tuner/metis_tuner.py
+440
-0
src/sdk/pynni/nni/metis_tuner/requirments.txt
src/sdk/pynni/nni/metis_tuner/requirments.txt
+1
-0
src/sdk/pynni/requirements.txt
src/sdk/pynni/requirements.txt
+4
-1
src/webui/src/components/Overview.tsx
src/webui/src/components/Overview.tsx
+4
-0
src/webui/src/components/TrialsDetail.tsx
src/webui/src/components/TrialsDetail.tsx
+39
-19
src/webui/src/components/overview/Progress.tsx
src/webui/src/components/overview/Progress.tsx
+8
-8
src/webui/src/components/trial-detail/TableList.tsx
src/webui/src/components/trial-detail/TableList.tsx
+318
-143
src/webui/src/static/const.ts
src/webui/src/static/const.ts
+40
-5
src/webui/src/static/function.ts
src/webui/src/static/function.ts
+18
-2
src/webui/src/static/interface.ts
src/webui/src/static/interface.ts
+21
-2
src/webui/src/static/style/search.scss
src/webui/src/static/style/search.scss
+14
-0
tools/nni_cmd/config_schema.py
tools/nni_cmd/config_schema.py
+10
-0
tools/nni_cmd/launcher_utils.py
tools/nni_cmd/launcher_utils.py
+2
-2
tools/nni_trial_tool/log_utils.py
tools/nni_trial_tool/log_utils.py
+12
-5
No files found.
src/sdk/pynni/nni/metis_tuner/Regression_GP/Prediction.py
0 → 100644
View file @
85cb472e
# Copyright (c) Microsoft Corporation
# All rights reserved.
#
# 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
sys
import
numpy
sys
.
path
.
insert
(
1
,
os
.
path
.
join
(
sys
.
path
[
0
],
'..'
))
def
predict
(
parameters_value
,
regressor_gp
):
'''
Predict by Gaussian Process Model
'''
parameters_value
=
numpy
.
array
(
parameters_value
).
reshape
(
-
1
,
len
(
parameters_value
))
mu
,
sigma
=
regressor_gp
.
predict
(
parameters_value
,
return_std
=
True
)
return
mu
[
0
],
sigma
[
0
]
\ No newline at end of file
src/sdk/pynni/nni/metis_tuner/Regression_GP/Selection.py
0 → 100644
View file @
85cb472e
# Copyright (c) Microsoft Corporation
# All rights reserved.
#
# 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
random
import
sys
import
nni.metis_tuner.lib_acquisition_function
as
lib_acquisition_function
import
nni.metis_tuner.lib_constraint_summation
as
lib_constraint_summation
import
nni.metis_tuner.lib_data
as
lib_data
import
nni.metis_tuner.Regression_GP.Prediction
as
gp_prediction
sys
.
path
.
insert
(
1
,
os
.
path
.
join
(
sys
.
path
[
0
],
'..'
))
CONSTRAINT_LOWERBOUND
=
None
CONSTRAINT_UPPERBOUND
=
None
CONSTRAINT_PARAMS_IDX
=
[]
def
selection_r
(
acquisition_function
,
samples_y_aggregation
,
x_bounds
,
x_types
,
regressor_gp
,
num_starting_points
=
100
,
minimize_constraints_fun
=
None
):
'''
Selecte R value
'''
minimize_starting_points
=
[
lib_data
.
rand
(
x_bounds
,
x_types
)
\
for
i
in
range
(
0
,
num_starting_points
)]
outputs
=
selection
(
acquisition_function
,
samples_y_aggregation
,
x_bounds
,
x_types
,
regressor_gp
,
minimize_starting_points
,
minimize_constraints_fun
=
minimize_constraints_fun
)
return
outputs
def
selection
(
acquisition_function
,
samples_y_aggregation
,
x_bounds
,
x_types
,
regressor_gp
,
minimize_starting_points
,
minimize_constraints_fun
=
None
):
'''
selection
'''
outputs
=
None
sys
.
stderr
.
write
(
"[%s] Exercise
\"
%s
\"
acquisition function
\n
"
\
%
(
os
.
path
.
basename
(
__file__
),
acquisition_function
))
if
acquisition_function
==
"ei"
:
outputs
=
lib_acquisition_function
.
next_hyperparameter_expected_improvement
(
\
gp_prediction
.
predict
,
[
regressor_gp
],
x_bounds
,
x_types
,
\
samples_y_aggregation
,
minimize_starting_points
,
\
minimize_constraints_fun
=
minimize_constraints_fun
)
elif
acquisition_function
==
"lc"
:
outputs
=
lib_acquisition_function
.
next_hyperparameter_lowest_confidence
(
\
gp_prediction
.
predict
,
[
regressor_gp
],
x_bounds
,
x_types
,
\
minimize_starting_points
,
minimize_constraints_fun
=
minimize_constraints_fun
)
elif
acquisition_function
==
"lm"
:
outputs
=
lib_acquisition_function
.
next_hyperparameter_lowest_mu
(
\
gp_prediction
.
predict
,
[
regressor_gp
],
x_bounds
,
x_types
,
\
minimize_starting_points
,
minimize_constraints_fun
=
minimize_constraints_fun
)
return
outputs
def
_rand_with_constraints
(
x_bounds
,
x_types
):
'''
Random generate with constraints
'''
outputs
=
None
x_bounds_withconstraints
=
[
x_bounds
[
i
]
for
i
in
CONSTRAINT_PARAMS_IDX
]
x_types_withconstraints
=
[
x_types
[
i
]
for
i
in
CONSTRAINT_PARAMS_IDX
]
x_val_withconstraints
=
lib_constraint_summation
.
rand
(
x_bounds_withconstraints
,
x_types_withconstraints
,
CONSTRAINT_LOWERBOUND
,
CONSTRAINT_UPPERBOUND
)
if
x_val_withconstraints
is
not
None
:
outputs
=
[
None
]
*
len
(
x_bounds
)
for
i
,
_
in
enumerate
(
CONSTRAINT_PARAMS_IDX
):
outputs
[
CONSTRAINT_PARAMS_IDX
[
i
]]
=
x_val_withconstraints
[
i
]
for
i
,
_
in
enumerate
(
outputs
):
if
outputs
[
i
]
is
None
:
outputs
[
i
]
=
random
.
randint
(
x_bounds
[
i
][
0
],
x_bounds
[
i
][
1
])
return
outputs
def
_minimize_constraints_fun_summation
(
x
):
'''
Minimize the constraints fun summation
'''
summation
=
sum
([
x
[
i
]
for
i
in
CONSTRAINT_PARAMS_IDX
])
return
CONSTRAINT_UPPERBOUND
>=
summation
>=
CONSTRAINT_LOWERBOUND
src/sdk/pynni/nni/metis_tuner/Regression_GP/__init__.py
0 → 100644
View file @
85cb472e
src/sdk/pynni/nni/metis_tuner/lib_acquisition_function.py
0 → 100644
View file @
85cb472e
# Copyright (c) Microsoft Corporation
# All rights reserved.
#
# 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
sys
import
numpy
from
scipy.stats
import
norm
from
scipy.optimize
import
minimize
import
nni.metis_tuner.lib_data
as
lib_data
def
next_hyperparameter_expected_improvement
(
fun_prediction
,
fun_prediction_args
,
x_bounds
,
x_types
,
samples_y_aggregation
,
minimize_starting_points
,
minimize_constraints_fun
=
None
):
'''
"Expected Improvement" acquisition function
'''
best_x
=
None
best_acquisition_value
=
None
x_bounds_minmax
=
[[
i
[
0
],
i
[
-
1
]]
for
i
in
x_bounds
]
x_bounds_minmax
=
numpy
.
array
(
x_bounds_minmax
)
for
starting_point
in
numpy
.
array
(
minimize_starting_points
):
res
=
minimize
(
fun
=
_expected_improvement
,
x0
=
starting_point
.
reshape
(
1
,
-
1
),
bounds
=
x_bounds_minmax
,
method
=
"L-BFGS-B"
,
args
=
(
fun_prediction
,
fun_prediction_args
,
x_bounds
,
x_types
,
samples_y_aggregation
,
minimize_constraints_fun
))
if
(
best_acquisition_value
is
None
)
or
\
(
res
.
fun
<
best_acquisition_value
):
res
.
x
=
numpy
.
ndarray
.
tolist
(
res
.
x
)
res
.
x
=
lib_data
.
match_val_type
(
res
.
x
,
x_bounds
,
x_types
)
if
(
minimize_constraints_fun
is
None
)
or
\
(
minimize_constraints_fun
(
res
.
x
)
is
True
):
best_acquisition_value
=
res
.
fun
best_x
=
res
.
x
outputs
=
None
if
best_x
is
not
None
:
mu
,
sigma
=
fun_prediction
(
best_x
,
*
fun_prediction_args
)
outputs
=
{
'hyperparameter'
:
best_x
,
'expected_mu'
:
mu
,
'expected_sigma'
:
sigma
,
'acquisition_func'
:
"ei"
}
return
outputs
def
_expected_improvement
(
x
,
fun_prediction
,
fun_prediction_args
,
x_bounds
,
x_types
,
samples_y_aggregation
,
minimize_constraints_fun
):
# This is only for step-wise optimization
x
=
lib_data
.
match_val_type
(
x
,
x_bounds
,
x_types
)
expected_improvement
=
sys
.
maxsize
if
(
minimize_constraints_fun
is
None
)
or
(
minimize_constraints_fun
(
x
)
is
True
):
mu
,
sigma
=
fun_prediction
(
x
,
*
fun_prediction_args
)
loss_optimum
=
min
(
samples_y_aggregation
)
scaling_factor
=
-
1
# In case sigma equals zero
with
numpy
.
errstate
(
divide
=
"ignore"
):
Z
=
scaling_factor
*
(
mu
-
loss_optimum
)
/
sigma
expected_improvement
=
scaling_factor
*
(
mu
-
loss_optimum
)
*
\
norm
.
cdf
(
Z
)
+
sigma
*
norm
.
pdf
(
Z
)
expected_improvement
=
0.0
if
sigma
==
0.0
else
expected_improvement
# We want expected_improvement to be as large as possible
# (i.e., as small as possible for minimize(...))
expected_improvement
=
-
1
*
expected_improvement
return
expected_improvement
def
next_hyperparameter_lowest_confidence
(
fun_prediction
,
fun_prediction_args
,
x_bounds
,
x_types
,
minimize_starting_points
,
minimize_constraints_fun
=
None
):
'''
"Lowest Confidence" acquisition function
'''
best_x
=
None
best_acquisition_value
=
None
x_bounds_minmax
=
[[
i
[
0
],
i
[
-
1
]]
for
i
in
x_bounds
]
x_bounds_minmax
=
numpy
.
array
(
x_bounds_minmax
)
for
starting_point
in
numpy
.
array
(
minimize_starting_points
):
res
=
minimize
(
fun
=
_lowest_confidence
,
x0
=
starting_point
.
reshape
(
1
,
-
1
),
bounds
=
x_bounds_minmax
,
method
=
"L-BFGS-B"
,
args
=
(
fun_prediction
,
fun_prediction_args
,
x_bounds
,
x_types
,
minimize_constraints_fun
))
if
(
best_acquisition_value
)
is
None
or
(
res
.
fun
<
best_acquisition_value
):
res
.
x
=
numpy
.
ndarray
.
tolist
(
res
.
x
)
res
.
x
=
lib_data
.
match_val_type
(
res
.
x
,
x_bounds
,
x_types
)
if
(
minimize_constraints_fun
is
None
)
or
(
minimize_constraints_fun
(
res
.
x
)
is
True
):
best_acquisition_value
=
res
.
fun
best_x
=
res
.
x
outputs
=
None
if
best_x
is
not
None
:
mu
,
sigma
=
fun_prediction
(
best_x
,
*
fun_prediction_args
)
outputs
=
{
'hyperparameter'
:
best_x
,
'expected_mu'
:
mu
,
'expected_sigma'
:
sigma
,
'acquisition_func'
:
"lc"
}
return
outputs
def
_lowest_confidence
(
x
,
fun_prediction
,
fun_prediction_args
,
x_bounds
,
x_types
,
minimize_constraints_fun
):
# This is only for step-wise optimization
x
=
lib_data
.
match_val_type
(
x
,
x_bounds
,
x_types
)
ci
=
sys
.
maxsize
if
(
minimize_constraints_fun
is
None
)
or
(
minimize_constraints_fun
(
x
)
is
True
):
mu
,
sigma
=
fun_prediction
(
x
,
*
fun_prediction_args
)
ci
=
(
sigma
*
1.96
*
2
)
/
mu
# We want ci to be as large as possible
# (i.e., as small as possible for minimize(...),
# because this would mean lowest confidence
ci
=
-
1
*
ci
return
ci
def
next_hyperparameter_lowest_mu
(
fun_prediction
,
fun_prediction_args
,
x_bounds
,
x_types
,
minimize_starting_points
,
minimize_constraints_fun
=
None
):
'''
"Lowest Mu" acquisition function
'''
best_x
=
None
best_acquisition_value
=
None
x_bounds_minmax
=
[[
i
[
0
],
i
[
-
1
]]
for
i
in
x_bounds
]
x_bounds_minmax
=
numpy
.
array
(
x_bounds_minmax
)
for
starting_point
in
numpy
.
array
(
minimize_starting_points
):
res
=
minimize
(
fun
=
_lowest_mu
,
x0
=
starting_point
.
reshape
(
1
,
-
1
),
bounds
=
x_bounds_minmax
,
method
=
"L-BFGS-B"
,
args
=
(
fun_prediction
,
fun_prediction_args
,
\
x_bounds
,
x_types
,
minimize_constraints_fun
))
if
(
best_acquisition_value
is
None
)
or
(
res
.
fun
<
best_acquisition_value
):
res
.
x
=
numpy
.
ndarray
.
tolist
(
res
.
x
)
res
.
x
=
lib_data
.
match_val_type
(
res
.
x
,
x_bounds
,
x_types
)
if
(
minimize_constraints_fun
is
None
)
or
(
minimize_constraints_fun
(
res
.
x
)
is
True
):
best_acquisition_value
=
res
.
fun
best_x
=
res
.
x
outputs
=
None
if
best_x
is
not
None
:
mu
,
sigma
=
fun_prediction
(
best_x
,
*
fun_prediction_args
)
outputs
=
{
'hyperparameter'
:
best_x
,
'expected_mu'
:
mu
,
'expected_sigma'
:
sigma
,
'acquisition_func'
:
"lm"
}
return
outputs
def
_lowest_mu
(
x
,
fun_prediction
,
fun_prediction_args
,
x_bounds
,
x_types
,
minimize_constraints_fun
):
'''
Calculate the lowest mu
'''
# This is only for step-wise optimization
x
=
lib_data
.
match_val_type
(
x
,
x_bounds
,
x_types
)
mu
=
sys
.
maxsize
if
(
minimize_constraints_fun
is
None
)
or
(
minimize_constraints_fun
(
x
)
is
True
):
mu
,
_
=
fun_prediction
(
x
,
*
fun_prediction_args
)
return
mu
\ No newline at end of file
src/sdk/pynni/nni/metis_tuner/lib_constraint_summation.py
0 → 100644
View file @
85cb472e
# Copyright (c) Microsoft Corporation
# All rights reserved.
#
# 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
math
import
random
from
operator
import
itemgetter
def
check_feasibility
(
x_bounds
,
lowerbound
,
upperbound
):
'''
This can have false positives.
For examples, parameters can only be 0 or 5, and the summation constraint is between 6 and 7.
'''
# x_bounds should be sorted, so even for "discrete_int" type,
# the smallest and the largest number should the first and the last element
x_bounds_lowerbound
=
sum
([
x_bound
[
0
]
for
x_bound
in
x_bounds
])
x_bounds_upperbound
=
sum
([
x_bound
[
-
1
]
for
x_bound
in
x_bounds
])
# return ((x_bounds_lowerbound <= lowerbound) and (x_bounds_upperbound >= lowerbound)) or \
# ((x_bounds_lowerbound <= upperbound) and (x_bounds_upperbound >= upperbound))
return
(
x_bounds_lowerbound
<=
lowerbound
<=
x_bounds_upperbound
)
or
\
(
x_bounds_lowerbound
<=
upperbound
<=
x_bounds_upperbound
)
def
rand
(
x_bounds
,
x_types
,
lowerbound
,
upperbound
,
max_retries
=
100
):
'''
Key idea is that we try to move towards upperbound, by randomly choose one
value for each parameter. However, for the last parameter,
we need to make sure that its value can help us get above lowerbound
'''
outputs
=
None
if
check_feasibility
(
x_bounds
,
lowerbound
,
upperbound
)
is
True
:
# Order parameters by their range size. We want the smallest range first,
# because the corresponding parameter has less numbers to choose from
x_idx_sorted
=
[]
for
i
,
_
in
enumerate
(
x_bounds
):
if
x_types
[
i
]
==
"discrete_int"
:
x_idx_sorted
.
append
([
i
,
len
(
x_bounds
[
i
])])
elif
(
x_types
[
i
]
==
"range_int"
)
or
(
x_types
[
i
]
==
"range_continuous"
):
x_idx_sorted
.
append
([
i
,
math
.
floor
(
x_bounds
[
i
][
1
]
-
x_bounds
[
i
][
0
])])
x_idx_sorted
=
sorted
(
x_idx_sorted
,
key
=
itemgetter
(
1
))
for
_
in
range
(
max_retries
):
budget_allocated
=
0
outputs
=
[
None
]
*
len
(
x_bounds
)
for
i
,
_
in
enumerate
(
x_idx_sorted
):
x_idx
=
x_idx_sorted
[
i
][
0
]
# The amount of unallocated space that we have
budget_max
=
upperbound
-
budget_allocated
# NOT the Last x that we need to assign a random number
if
i
<
(
len
(
x_idx_sorted
)
-
1
):
if
x_bounds
[
x_idx
][
0
]
<=
budget_max
:
if
x_types
[
x_idx
]
==
"discrete_int"
:
# Note the valid integer
temp
=
[]
for
j
in
x_bounds
[
x_idx
]:
if
j
<=
budget_max
:
temp
.
append
(
j
)
# Randomly pick a number from the integer array
if
temp
:
outputs
[
x_idx
]
=
temp
[
random
.
randint
(
0
,
len
(
temp
)
-
1
)]
elif
(
x_types
[
x_idx
]
==
"range_int"
)
or
\
(
x_types
[
x_idx
]
==
"range_continuous"
):
outputs
[
x_idx
]
=
random
.
randint
(
x_bounds
[
x_idx
][
0
],
min
(
x_bounds
[
x_idx
][
-
1
],
budget_max
))
else
:
# The last x that we need to assign a random number
randint_lowerbound
=
lowerbound
-
budget_allocated
randint_lowerbound
=
0
if
randint_lowerbound
<
0
else
randint_lowerbound
# This check:
# is our smallest possible value going to overflow the available budget space,
# and is our largest possible value going to underflow the lower bound
if
(
x_bounds
[
x_idx
][
0
]
<=
budget_max
)
and
\
(
x_bounds
[
x_idx
][
-
1
]
>=
randint_lowerbound
):
if
x_types
[
x_idx
]
==
"discrete_int"
:
temp
=
[]
for
j
in
x_bounds
[
x_idx
]:
# if (j <= budget_max) and (j >= randint_lowerbound):
if
randint_lowerbound
<=
j
<=
budget_max
:
temp
.
append
(
j
)
if
temp
:
outputs
[
x_idx
]
=
temp
[
random
.
randint
(
0
,
len
(
temp
)
-
1
)]
elif
(
x_types
[
x_idx
]
==
"range_int"
)
or
\
(
x_types
[
x_idx
]
==
"range_continuous"
):
outputs
[
x_idx
]
=
random
.
randint
(
randint_lowerbound
,
min
(
x_bounds
[
x_idx
][
1
],
budget_max
))
if
outputs
[
x_idx
]
is
None
:
break
else
:
budget_allocated
+=
outputs
[
x_idx
]
if
None
not
in
outputs
:
break
return
outputs
\ No newline at end of file
src/sdk/pynni/nni/metis_tuner/lib_data.py
0 → 100644
View file @
85cb472e
# Copyright (c) Microsoft Corporation
# All rights reserved.
#
# 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
math
import
random
def
match_val_type
(
vals
,
vals_bounds
,
vals_types
):
'''
Update values in the array, to match their corresponding type
'''
vals_new
=
[]
for
i
,
_
in
enumerate
(
vals_types
):
if
vals_types
[
i
]
==
"discrete_int"
:
# Find the closest integer in the array, vals_bounds
vals_new
.
append
(
min
(
vals_bounds
[
i
],
key
=
lambda
x
:
abs
(
x
-
vals
[
i
])))
elif
vals_types
[
i
]
==
"range_int"
:
# Round down to the nearest integer
vals_new
.
append
(
math
.
floor
(
vals
[
i
]))
elif
vals_types
[
i
]
==
"range_continuous"
:
# Don't do any processing for continous numbers
vals_new
.
append
(
vals
[
i
])
else
:
return
None
return
vals_new
def
rand
(
x_bounds
,
x_types
):
'''
Random generate variable value within their bounds
'''
outputs
=
[]
for
i
,
_
in
enumerate
(
x_bounds
):
if
x_types
[
i
]
==
"discrete_int"
:
temp
=
x_bounds
[
i
][
random
.
randint
(
0
,
len
(
x_bounds
[
i
])
-
1
)]
outputs
.
append
(
temp
)
elif
x_types
[
i
]
==
"range_int"
:
temp
=
random
.
randint
(
x_bounds
[
i
][
0
],
x_bounds
[
i
][
1
])
outputs
.
append
(
temp
)
elif
x_types
[
i
]
==
"range_continuous"
:
temp
=
random
.
uniform
(
x_bounds
[
i
][
0
],
x_bounds
[
i
][
1
])
outputs
.
append
(
temp
)
else
:
return
None
return
outputs
\ No newline at end of file
src/sdk/pynni/nni/metis_tuner/metis_tuner.py
0 → 100644
View file @
85cb472e
This diff is collapsed.
Click to expand it.
src/sdk/pynni/nni/metis_tuner/requirments.txt
0 → 100644
View file @
85cb472e
sklearn
\ No newline at end of file
src/sdk/pynni/requirements.txt
View file @
85cb472e
...
@@ -5,3 +5,6 @@ json_tricks
...
@@ -5,3 +5,6 @@ json_tricks
numpy
numpy
scipy
scipy
hyperopt
hyperopt
# metis tuner
sklearn
src/webui/src/components/Overview.tsx
View file @
85cb472e
...
@@ -209,6 +209,10 @@ class Overview extends React.Component<{}, OverviewState> {
...
@@ -209,6 +209,10 @@ class Overview extends React.Component<{}, OverviewState> {
profile
.
failTrial
+=
1
;
profile
.
failTrial
+=
1
;
break
;
break
;
case
'
RUNNING
'
:
profile
.
runTrial
+=
1
;
break
;
case
'
USER_CANCELED
'
:
case
'
USER_CANCELED
'
:
case
'
SYS_CANCELED
'
:
case
'
SYS_CANCELED
'
:
profile
.
stopTrial
+=
1
;
profile
.
stopTrial
+=
1
;
...
...
src/webui/src/components/TrialsDetail.tsx
View file @
85cb472e
import
*
as
React
from
'
react
'
;
import
*
as
React
from
'
react
'
;
import
axios
from
'
axios
'
;
import
axios
from
'
axios
'
;
import
{
MANAGER_IP
}
from
'
../static/const
'
;
import
{
MANAGER_IP
}
from
'
../static/const
'
;
import
{
Row
,
Col
,
Tabs
,
Input
,
Select
}
from
'
antd
'
;
import
{
Row
,
Col
,
Tabs
,
Input
,
Select
,
Button
}
from
'
antd
'
;
const
Option
=
Select
.
Option
;
const
Option
=
Select
.
Option
;
import
{
TableObj
,
Parameters
,
DetailAccurPoint
,
TooltipForAccuracy
}
from
'
../static/interface
'
;
import
{
TableObj
Fianl
,
Parameters
,
DetailAccurPoint
,
TooltipForAccuracy
}
from
'
../static/interface
'
;
import
{
getFinalResult
}
from
'
../static/function
'
;
import
{
getFinalResult
,
getFinal
}
from
'
../static/function
'
;
import
Accuracy
from
'
./overview/Accuracy
'
;
import
Accuracy
from
'
./overview/Accuracy
'
;
import
Duration
from
'
./trial-detail/Duration
'
;
import
Duration
from
'
./trial-detail/Duration
'
;
import
Title1
from
'
./overview/Title1
'
;
import
Title1
from
'
./overview/Title1
'
;
...
@@ -16,8 +16,8 @@ import '../static/style/trialsDetail.scss';
...
@@ -16,8 +16,8 @@ import '../static/style/trialsDetail.scss';
interface
TrialDetailState
{
interface
TrialDetailState
{
accSource
:
object
;
accSource
:
object
;
accNodata
:
string
;
accNodata
:
string
;
tableListSource
:
Array
<
TableObj
>
;
tableListSource
:
Array
<
TableObj
Fianl
>
;
searchResultSource
:
Array
<
TableObj
>
;
searchResultSource
:
Array
<
TableObj
Fianl
>
;
isHasSearch
:
boolean
;
isHasSearch
:
boolean
;
experimentStatus
:
string
;
experimentStatus
:
string
;
entriesTable
:
number
;
entriesTable
:
number
;
...
@@ -30,6 +30,8 @@ class TrialsDetail extends React.Component<{}, TrialDetailState> {
...
@@ -30,6 +30,8 @@ class TrialsDetail extends React.Component<{}, TrialDetailState> {
public
interTableList
=
1
;
public
interTableList
=
1
;
public
interAllTableList
=
2
;
public
interAllTableList
=
2
;
public
tableList
:
TableList
|
null
;
constructor
(
props
:
{})
{
constructor
(
props
:
{})
{
super
(
props
);
super
(
props
);
...
@@ -40,7 +42,7 @@ class TrialsDetail extends React.Component<{}, TrialDetailState> {
...
@@ -40,7 +42,7 @@ class TrialsDetail extends React.Component<{}, TrialDetailState> {
searchResultSource
:
[],
searchResultSource
:
[],
experimentStatus
:
''
,
experimentStatus
:
''
,
entriesTable
:
20
,
entriesTable
:
20
,
isHasSearch
:
false
isHasSearch
:
false
,
};
};
}
}
// trial accuracy graph
// trial accuracy graph
...
@@ -132,7 +134,7 @@ class TrialsDetail extends React.Component<{}, TrialDetailState> {
...
@@ -132,7 +134,7 @@ class TrialsDetail extends React.Component<{}, TrialDetailState> {
.
then
(
res
=>
{
.
then
(
res
=>
{
if
(
res
.
status
===
200
)
{
if
(
res
.
status
===
200
)
{
const
trialJobs
=
res
.
data
;
const
trialJobs
=
res
.
data
;
const
trialTable
:
Array
<
TableObj
>
=
[];
const
trialTable
:
Array
<
TableObj
Fianl
>
=
[];
Object
.
keys
(
trialJobs
).
map
(
item
=>
{
Object
.
keys
(
trialJobs
).
map
(
item
=>
{
// only succeeded trials have finalMetricData
// only succeeded trials have finalMetricData
let
desc
:
Parameters
=
{
let
desc
:
Parameters
=
{
...
@@ -167,7 +169,7 @@ class TrialsDetail extends React.Component<{}, TrialDetailState> {
...
@@ -167,7 +169,7 @@ class TrialsDetail extends React.Component<{}, TrialDetailState> {
if
(
trialJobs
[
item
].
logPath
!==
undefined
)
{
if
(
trialJobs
[
item
].
logPath
!==
undefined
)
{
desc
.
logPath
=
trialJobs
[
item
].
logPath
;
desc
.
logPath
=
trialJobs
[
item
].
logPath
;
}
}
const
acc
=
getFinal
Result
(
trialJobs
[
item
].
finalMetricData
);
const
acc
=
getFinal
(
trialJobs
[
item
].
finalMetricData
);
trialTable
.
push
({
trialTable
.
push
({
key
:
trialTable
.
length
,
key
:
trialTable
.
length
,
sequenceId
:
trialJobs
[
item
].
sequenceId
,
sequenceId
:
trialJobs
[
item
].
sequenceId
,
...
@@ -185,7 +187,7 @@ class TrialsDetail extends React.Component<{}, TrialDetailState> {
...
@@ -185,7 +187,7 @@ class TrialsDetail extends React.Component<{}, TrialDetailState> {
Object
.
keys
(
searchResultSource
).
map
(
index
=>
{
Object
.
keys
(
searchResultSource
).
map
(
index
=>
{
temp
.
push
(
searchResultSource
[
index
].
id
);
temp
.
push
(
searchResultSource
[
index
].
id
);
});
});
const
searchResultList
:
Array
<
TableObj
>
=
[];
const
searchResultList
:
Array
<
TableObj
Fianl
>
=
[];
for
(
let
i
=
0
;
i
<
temp
.
length
;
i
++
)
{
for
(
let
i
=
0
;
i
<
temp
.
length
;
i
++
)
{
Object
.
keys
(
trialTable
).
map
(
key
=>
{
Object
.
keys
(
trialTable
).
map
(
key
=>
{
const
item
=
trialTable
[
key
];
const
item
=
trialTable
[
key
];
...
@@ -217,7 +219,7 @@ class TrialsDetail extends React.Component<{}, TrialDetailState> {
...
@@ -217,7 +219,7 @@ class TrialsDetail extends React.Component<{}, TrialDetailState> {
.
then
(
res
=>
{
.
then
(
res
=>
{
if
(
res
.
status
===
200
)
{
if
(
res
.
status
===
200
)
{
const
trialJobs
=
res
.
data
;
const
trialJobs
=
res
.
data
;
const
trialTable
:
Array
<
TableObj
>
=
[];
const
trialTable
:
Array
<
TableObj
Fianl
>
=
[];
Object
.
keys
(
trialJobs
).
map
(
item
=>
{
Object
.
keys
(
trialJobs
).
map
(
item
=>
{
// only succeeded trials have finalMetricData
// only succeeded trials have finalMetricData
let
desc
:
Parameters
=
{
let
desc
:
Parameters
=
{
...
@@ -252,7 +254,7 @@ class TrialsDetail extends React.Component<{}, TrialDetailState> {
...
@@ -252,7 +254,7 @@ class TrialsDetail extends React.Component<{}, TrialDetailState> {
if
(
trialJobs
[
item
].
logPath
!==
undefined
)
{
if
(
trialJobs
[
item
].
logPath
!==
undefined
)
{
desc
.
logPath
=
trialJobs
[
item
].
logPath
;
desc
.
logPath
=
trialJobs
[
item
].
logPath
;
}
}
const
acc
=
getFinal
Result
(
trialJobs
[
item
].
finalMetricData
);
const
acc
=
getFinal
(
trialJobs
[
item
].
finalMetricData
);
trialTable
.
push
({
trialTable
.
push
({
key
:
trialTable
.
length
,
key
:
trialTable
.
length
,
sequenceId
:
trialJobs
[
item
].
sequenceId
,
sequenceId
:
trialJobs
[
item
].
sequenceId
,
...
@@ -308,7 +310,7 @@ class TrialsDetail extends React.Component<{}, TrialDetailState> {
...
@@ -308,7 +310,7 @@ class TrialsDetail extends React.Component<{}, TrialDetailState> {
}
else
{
}
else
{
window
.
clearInterval
(
this
.
interAllTableList
);
window
.
clearInterval
(
this
.
interAllTableList
);
const
{
tableListSource
}
=
this
.
state
;
const
{
tableListSource
}
=
this
.
state
;
const
searchResultList
:
Array
<
TableObj
>
=
[];
const
searchResultList
:
Array
<
TableObj
Fianl
>
=
[];
Object
.
keys
(
tableListSource
).
map
(
key
=>
{
Object
.
keys
(
tableListSource
).
map
(
key
=>
{
const
item
=
tableListSource
[
key
];
const
item
=
tableListSource
[
key
];
if
(
item
.
sequenceId
.
toString
()
===
targetValue
||
item
.
id
.
includes
(
targetValue
))
{
if
(
item
.
sequenceId
.
toString
()
===
targetValue
||
item
.
id
.
includes
(
targetValue
))
{
...
@@ -364,6 +366,10 @@ class TrialsDetail extends React.Component<{}, TrialDetailState> {
...
@@ -364,6 +366,10 @@ class TrialsDetail extends React.Component<{}, TrialDetailState> {
}
}
}
}
test
=
()
=>
{
alert
(
'
TableList component was not properly initialized.
'
);
}
componentDidMount
()
{
componentDidMount
()
{
this
.
_isMounted
=
true
;
this
.
_isMounted
=
true
;
...
@@ -429,6 +435,17 @@ class TrialsDetail extends React.Component<{}, TrialDetailState> {
...
@@ -429,6 +435,17 @@ class TrialsDetail extends React.Component<{}, TrialDetailState> {
<
span
>
entries
</
span
>
<
span
>
entries
</
span
>
</
Col
>
</
Col
>
<
Col
span
=
{
12
}
className
=
"right"
>
<
Col
span
=
{
12
}
className
=
"right"
>
<
Row
>
<
Col
span
=
{
12
}
>
<
Button
type
=
"primary"
className
=
"tableButton editStyle"
onClick
=
{
this
.
tableList
?
this
.
tableList
.
addColumn
:
this
.
test
}
>
AddColumn
</
Button
>
</
Col
>
<
Col
span
=
{
12
}
>
{
/* <span>Search:</span> */
}
{
/* <span>Search:</span> */
}
<
Input
<
Input
type
=
"text"
type
=
"text"
...
@@ -438,12 +455,15 @@ class TrialsDetail extends React.Component<{}, TrialDetailState> {
...
@@ -438,12 +455,15 @@ class TrialsDetail extends React.Component<{}, TrialDetailState> {
/>
/>
</
Col
>
</
Col
>
</
Row
>
</
Row
>
</
Col
>
</
Row
>
<
TableList
<
TableList
entries
=
{
entriesTable
}
entries
=
{
entriesTable
}
tableSource
=
{
tableListSource
}
tableSource
=
{
tableListSource
}
updateList
=
{
this
.
drawTableList
}
updateList
=
{
this
.
drawTableList
}
searchResult
=
{
searchResultSource
}
searchResult
=
{
searchResultSource
}
isHasSearch
=
{
isHasSearch
}
isHasSearch
=
{
isHasSearch
}
ref
=
{
(
tabList
)
=>
this
.
tableList
=
tabList
}
/>
/>
</
div
>
</
div
>
);
);
...
...
src/webui/src/components/overview/Progress.tsx
View file @
85cb472e
...
@@ -242,45 +242,45 @@ class Progressed extends React.Component<ProgressProps, ProgressState> {
...
@@ -242,45 +242,45 @@ class Progressed extends React.Component<ProgressProps, ProgressState> {
maxString
=
{
`MaxTrialNumber:
${
trialProfile
.
MaxTrialNum
}
`
}
maxString
=
{
`MaxTrialNumber:
${
trialProfile
.
MaxTrialNum
}
`
}
/>
/>
<
Row
className
=
"basic colorOfbasic mess"
>
<
Row
className
=
"basic colorOfbasic mess"
>
<
p
>
B
est
Default M
etric
</
p
>
<
p
>
b
est
m
etric
</
p
>
<
div
>
{
bestAccuracy
}
</
div
>
<
div
>
{
bestAccuracy
}
</
div
>
</
Row
>
</
Row
>
<
Row
className
=
"mess"
>
<
Row
className
=
"mess"
>
<
Col
span
=
{
8
}
>
<
Col
span
=
{
8
}
>
<
Row
className
=
"basic colorOfbasic"
>
<
Row
className
=
"basic colorOfbasic"
>
<
p
>
Time S
pent
</
p
>
<
p
>
s
pent
</
p
>
<
div
>
{
convertTime
(
trialProfile
.
execDuration
)
}
</
div
>
<
div
>
{
convertTime
(
trialProfile
.
execDuration
)
}
</
div
>
</
Row
>
</
Row
>
</
Col
>
</
Col
>
<
Col
span
=
{
9
}
>
<
Col
span
=
{
9
}
>
<
Row
className
=
"basic colorOfbasic"
>
<
Row
className
=
"basic colorOfbasic"
>
<
p
>
R
emaining
Time
</
p
>
<
p
>
r
emaining
</
p
>
<
div
>
{
remaining
}
</
div
>
<
div
>
{
remaining
}
</
div
>
</
Row
>
</
Row
>
</
Col
>
</
Col
>
<
Col
span
=
{
7
}
>
<
Col
span
=
{
7
}
>
<
Row
className
=
"basic colorOfbasic"
>
<
Row
className
=
"basic colorOfbasic"
>
<
p
>
MaxDuration
</
p
>
<
p
>
running
</
p
>
<
div
>
{
convertTime
(
trialProfile
.
maxDuration
)
}
</
div
>
<
div
>
{
trialNumber
.
runTrial
}
</
div
>
</
Row
>
</
Row
>
</
Col
>
</
Col
>
</
Row
>
</
Row
>
<
Row
className
=
"mess"
>
<
Row
className
=
"mess"
>
<
Col
span
=
{
8
}
>
<
Col
span
=
{
8
}
>
<
Row
className
=
"basic colorOfbasic"
>
<
Row
className
=
"basic colorOfbasic"
>
<
p
>
S
ucceed
Trial
</
p
>
<
p
>
s
ucceed
</
p
>
<
div
>
{
trialNumber
.
succTrial
}
</
div
>
<
div
>
{
trialNumber
.
succTrial
}
</
div
>
</
Row
>
</
Row
>
</
Col
>
</
Col
>
<
Col
span
=
{
9
}
>
<
Col
span
=
{
9
}
>
<
Row
className
=
"basic"
>
<
Row
className
=
"basic"
>
<
p
>
S
topped
Trial
</
p
>
<
p
>
s
topped
</
p
>
<
div
>
{
trialNumber
.
stopTrial
}
</
div
>
<
div
>
{
trialNumber
.
stopTrial
}
</
div
>
</
Row
>
</
Row
>
</
Col
>
</
Col
>
<
Col
span
=
{
7
}
>
<
Col
span
=
{
7
}
>
<
Row
className
=
"basic"
>
<
Row
className
=
"basic"
>
<
p
>
F
ailed
Trial
</
p
>
<
p
>
f
ailed
</
p
>
<
div
>
{
trialNumber
.
failTrial
}
</
div
>
<
div
>
{
trialNumber
.
failTrial
}
</
div
>
</
Row
>
</
Row
>
</
Col
>
</
Col
>
...
...
src/webui/src/components/trial-detail/TableList.tsx
View file @
85cb472e
...
@@ -2,11 +2,13 @@ import * as React from 'react';
...
@@ -2,11 +2,13 @@ import * as React from 'react';
import
axios
from
'
axios
'
;
import
axios
from
'
axios
'
;
import
JSONTree
from
'
react-json-tree
'
;
import
JSONTree
from
'
react-json-tree
'
;
import
ReactEcharts
from
'
echarts-for-react
'
;
import
ReactEcharts
from
'
echarts-for-react
'
;
import
{
Row
,
Table
,
Button
,
Popconfirm
,
Modal
,
message
}
from
'
antd
'
;
import
{
Row
,
Table
,
Button
,
Popconfirm
,
Modal
,
message
,
Checkbox
}
from
'
antd
'
;
import
{
MANAGER_IP
,
trialJobStatus
}
from
'
../../static/const
'
;
const
CheckboxGroup
=
Checkbox
.
Group
;
import
{
MANAGER_IP
,
trialJobStatus
,
COLUMN
,
COLUMN_INDEX
}
from
'
../../static/const
'
;
import
{
convertDuration
}
from
'
../../static/function
'
;
import
{
convertDuration
}
from
'
../../static/function
'
;
import
{
TableObj
,
TrialJob
}
from
'
../../static/interface
'
;
import
{
TableObj
Fianl
,
TrialJob
}
from
'
../../static/interface
'
;
import
LogPath
from
'
../logPath/LogPath
'
;
import
LogPath
from
'
../logPath/LogPath
'
;
import
'
../../static/style/search.scss
'
;
require
(
'
../../static/style/tableStatus.css
'
);
require
(
'
../../static/style/tableStatus.css
'
);
require
(
'
../../static/style/logPath.scss
'
);
require
(
'
../../static/style/logPath.scss
'
);
require
(
'
../../static/style/search.scss
'
);
require
(
'
../../static/style/search.scss
'
);
...
@@ -22,8 +24,8 @@ echarts.registerTheme('my_theme', {
...
@@ -22,8 +24,8 @@ echarts.registerTheme('my_theme', {
interface
TableListProps
{
interface
TableListProps
{
entries
:
number
;
entries
:
number
;
tableSource
:
Array
<
TableObj
>
;
tableSource
:
Array
<
TableObj
Fianl
>
;
searchResult
:
Array
<
TableObj
>
;
searchResult
:
Array
<
TableObj
Fianl
>
;
updateList
:
Function
;
updateList
:
Function
;
isHasSearch
:
boolean
;
isHasSearch
:
boolean
;
}
}
...
@@ -31,6 +33,14 @@ interface TableListProps {
...
@@ -31,6 +33,14 @@ interface TableListProps {
interface
TableListState
{
interface
TableListState
{
intermediateOption
:
object
;
intermediateOption
:
object
;
modalVisible
:
boolean
;
modalVisible
:
boolean
;
isObjFinal
:
boolean
;
isShowColumn
:
boolean
;
columnSelected
:
Array
<
string
>
;
// user select columnKeys
}
interface
ColumnIndex
{
name
:
string
;
index
:
number
;
}
}
class
TableList
extends
React
.
Component
<
TableListProps
,
TableListState
>
{
class
TableList
extends
React
.
Component
<
TableListProps
,
TableListState
>
{
...
@@ -41,7 +51,10 @@ class TableList extends React.Component<TableListProps, TableListState> {
...
@@ -41,7 +51,10 @@ class TableList extends React.Component<TableListProps, TableListState> {
this
.
state
=
{
this
.
state
=
{
intermediateOption
:
{},
intermediateOption
:
{},
modalVisible
:
false
modalVisible
:
false
,
isObjFinal
:
false
,
isShowColumn
:
false
,
columnSelected
:
COLUMN
,
};
};
}
}
...
@@ -79,6 +92,14 @@ class TableList extends React.Component<TableListProps, TableListState> {
...
@@ -79,6 +92,14 @@ class TableList extends React.Component<TableListProps, TableListState> {
}
}
}
}
hideShowColumnModal
=
()
=>
{
if
(
this
.
_isMounted
)
{
this
.
setState
({
isShowColumn
:
false
});
}
}
intermediateGraphOption
=
(
intermediateArr
:
number
[],
id
:
string
)
=>
{
intermediateGraphOption
=
(
intermediateArr
:
number
[],
id
:
string
)
=>
{
const
sequence
:
number
[]
=
[];
const
sequence
:
number
[]
=
[];
const
lengthInter
=
intermediateArr
.
length
;
const
lengthInter
=
intermediateArr
.
length
;
...
@@ -143,6 +164,67 @@ class TableList extends React.Component<TableListProps, TableListState> {
...
@@ -143,6 +164,67 @@ class TableList extends React.Component<TableListProps, TableListState> {
});
});
}
}
// click add column btn, just show the modal of addcolumn
addColumn
=
()
=>
{
// show user select check button
if
(
this
.
_isMounted
)
{
this
.
setState
({
isShowColumn
:
true
});
}
}
// checkbox for coloumn
selectedColumn
=
(
checkedValues
:
Array
<
string
>
)
=>
{
let
count
=
6
;
const
want
:
Array
<
object
>
=
[];
const
finalKeys
:
Array
<
string
>
=
[];
const
wantResult
:
Array
<
string
>
=
[];
Object
.
keys
(
checkedValues
).
map
(
m
=>
{
switch
(
checkedValues
[
m
])
{
case
'
Trial No
'
:
case
'
id
'
:
case
'
duration
'
:
case
'
status
'
:
case
'
Operation
'
:
case
'
Default
'
:
case
'
Intermediate Result
'
:
break
;
default
:
finalKeys
.
push
(
checkedValues
[
m
]);
}
});
Object
.
keys
(
finalKeys
).
map
(
n
=>
{
want
.
push
({
name
:
finalKeys
[
n
],
index
:
count
++
});
});
Object
.
keys
(
checkedValues
).
map
(
item
=>
{
const
temp
=
checkedValues
[
item
];
Object
.
keys
(
COLUMN_INDEX
).
map
(
key
=>
{
const
index
=
COLUMN_INDEX
[
key
];
if
(
index
.
name
===
temp
)
{
want
.
push
(
index
);
}
});
});
want
.
sort
((
a
:
ColumnIndex
,
b
:
ColumnIndex
)
=>
{
return
a
.
index
-
b
.
index
;
});
Object
.
keys
(
want
).
map
(
i
=>
{
wantResult
.
push
(
want
[
i
].
name
);
});
if
(
this
.
_isMounted
)
{
this
.
setState
(()
=>
({
columnSelected
:
wantResult
}));
}
}
componentDidMount
()
{
componentDidMount
()
{
this
.
_isMounted
=
true
;
this
.
_isMounted
=
true
;
}
}
...
@@ -154,7 +236,27 @@ class TableList extends React.Component<TableListProps, TableListState> {
...
@@ -154,7 +236,27 @@ class TableList extends React.Component<TableListProps, TableListState> {
render
()
{
render
()
{
const
{
entries
,
tableSource
,
searchResult
,
isHasSearch
}
=
this
.
props
;
const
{
entries
,
tableSource
,
searchResult
,
isHasSearch
}
=
this
.
props
;
const
{
intermediateOption
,
modalVisible
}
=
this
.
state
;
const
{
intermediateOption
,
modalVisible
,
isShowColumn
,
columnSelected
,
}
=
this
.
state
;
let
showTitle
=
COLUMN
;
if
(
tableSource
.
length
>=
1
)
{
const
temp
=
tableSource
[
0
].
acc
;
if
(
temp
!==
undefined
&&
typeof
temp
===
'
object
'
)
{
if
(
this
.
_isMounted
)
{
// concat default column and finalkeys
const
item
=
Object
.
keys
(
temp
);
const
want
:
Array
<
string
>
=
[];
Object
.
keys
(
item
).
map
(
key
=>
{
if
(
item
[
key
]
!==
'
default
'
)
{
want
.
push
(
item
[
key
]);
}
});
showTitle
=
COLUMN
.
concat
(
want
);
}
}
}
let
bgColor
=
''
;
let
bgColor
=
''
;
const
trialJob
:
Array
<
TrialJob
>
=
[];
const
trialJob
:
Array
<
TrialJob
>
=
[];
trialJobStatus
.
map
(
item
=>
{
trialJobStatus
.
map
(
item
=>
{
...
@@ -163,35 +265,47 @@ class TableList extends React.Component<TableListProps, TableListState> {
...
@@ -163,35 +265,47 @@ class TableList extends React.Component<TableListProps, TableListState> {
value
:
item
value
:
item
});
});
});
});
const
showColumn
:
Array
<
object
>
=
[];
const
columns
=
[{
Object
.
keys
(
columnSelected
).
map
(
key
=>
{
const
item
=
columnSelected
[
key
];
switch
(
item
)
{
case
'
Trial No
'
:
showColumn
.
push
({
title
:
'
Trial No.
'
,
title
:
'
Trial No.
'
,
dataIndex
:
'
sequenceId
'
,
dataIndex
:
'
sequenceId
'
,
key
:
'
sequenceId
'
,
key
:
'
sequenceId
'
,
width
:
120
,
width
:
120
,
className
:
'
tableHead
'
,
className
:
'
tableHead
'
,
sorter
:
(
a
:
TableObj
,
b
:
TableObj
)
=>
(
a
.
sequenceId
as
number
)
-
(
b
.
sequenceId
as
number
)
sorter
:
},
{
(
a
:
TableObjFianl
,
b
:
TableObjFianl
)
=>
(
a
.
sequenceId
as
number
)
-
(
b
.
sequenceId
as
number
)
});
break
;
case
'
id
'
:
showColumn
.
push
({
title
:
'
Id
'
,
title
:
'
Id
'
,
dataIndex
:
'
id
'
,
dataIndex
:
'
id
'
,
key
:
'
id
'
,
key
:
'
id
'
,
width
:
60
,
width
:
60
,
className
:
'
tableHead idtitle
'
,
className
:
'
tableHead idtitle
'
,
// the sort of string
// the sort of string
sorter
:
(
a
:
TableObj
,
b
:
TableObj
):
number
=>
a
.
id
.
localeCompare
(
b
.
id
),
sorter
:
(
a
:
TableObj
Fianl
,
b
:
TableObj
Fianl
):
number
=>
a
.
id
.
localeCompare
(
b
.
id
),
render
:
(
text
:
string
,
record
:
TableObj
)
=>
{
render
:
(
text
:
string
,
record
:
TableObj
Fianl
)
=>
{
return
(
return
(
<
div
>
{
record
.
id
}
</
div
>
<
div
>
{
record
.
id
}
</
div
>
);
);
}
}
},
{
});
break
;
case
'
duration
'
:
showColumn
.
push
({
title
:
'
Duration
'
,
title
:
'
Duration
'
,
dataIndex
:
'
duration
'
,
dataIndex
:
'
duration
'
,
key
:
'
duration
'
,
key
:
'
duration
'
,
width
:
140
,
width
:
140
,
// the sort of number
// the sort of number
sorter
:
(
a
:
TableObj
,
b
:
TableObj
)
=>
(
a
.
duration
as
number
)
-
(
b
.
duration
as
number
),
sorter
:
(
a
:
TableObj
Fianl
,
b
:
TableObj
Fianl
)
=>
(
a
.
duration
as
number
)
-
(
b
.
duration
as
number
),
render
:
(
text
:
string
,
record
:
TableObj
)
=>
{
render
:
(
text
:
string
,
record
:
TableObj
Fianl
)
=>
{
let
duration
;
let
duration
;
if
(
record
.
duration
!==
undefined
&&
record
.
duration
>
0
)
{
if
(
record
.
duration
!==
undefined
&&
record
.
duration
>
0
)
{
duration
=
convertDuration
(
record
.
duration
);
duration
=
convertDuration
(
record
.
duration
);
...
@@ -202,29 +316,44 @@ class TableList extends React.Component<TableListProps, TableListState> {
...
@@ -202,29 +316,44 @@ class TableList extends React.Component<TableListProps, TableListState> {
<
div
className
=
"durationsty"
><
div
>
{
duration
}
</
div
></
div
>
<
div
className
=
"durationsty"
><
div
>
{
duration
}
</
div
></
div
>
);
);
},
},
},
{
});
break
;
case
'
status
'
:
showColumn
.
push
({
title
:
'
Status
'
,
title
:
'
Status
'
,
dataIndex
:
'
status
'
,
dataIndex
:
'
status
'
,
key
:
'
status
'
,
key
:
'
status
'
,
width
:
150
,
width
:
150
,
className
:
'
tableStatus
'
,
className
:
'
tableStatus
'
,
render
:
(
text
:
string
,
record
:
TableObj
)
=>
{
render
:
(
text
:
string
,
record
:
TableObj
Fianl
)
=>
{
bgColor
=
record
.
status
;
bgColor
=
record
.
status
;
return
(
return
(
<
span
className
=
{
`
${
bgColor
}
commonStyle`
}
>
{
record
.
status
}
</
span
>
<
span
className
=
{
`
${
bgColor
}
commonStyle`
}
>
{
record
.
status
}
</
span
>
);
);
},
},
filters
:
trialJob
,
filters
:
trialJob
,
onFilter
:
(
value
:
string
,
record
:
TableObj
)
=>
record
.
status
.
indexOf
(
value
)
===
0
,
onFilter
:
(
value
:
string
,
record
:
TableObjFianl
)
=>
record
.
status
.
indexOf
(
value
)
===
0
,
sorter
:
(
a
:
TableObj
,
b
:
TableObj
):
number
=>
a
.
status
.
localeCompare
(
b
.
status
)
sorter
:
(
a
:
TableObjFianl
,
b
:
TableObjFianl
):
number
=>
a
.
status
.
localeCompare
(
b
.
status
)
},
{
});
break
;
case
'
Default
'
:
showColumn
.
push
({
title
:
'
Default Metric
'
,
title
:
'
Default Metric
'
,
dataIndex
:
'
acc
'
,
dataIndex
:
'
acc
'
,
key
:
'
acc
'
,
key
:
'
acc
'
,
width
:
200
,
width
:
200
,
sorter
:
(
a
:
TableObj
,
b
:
TableObj
)
=>
(
a
.
acc
as
number
)
-
(
b
.
acc
as
number
),
sorter
:
(
a
:
TableObjFianl
,
b
:
TableObjFianl
)
=>
{
render
:
(
text
:
string
,
record
:
TableObj
)
=>
{
if
(
a
.
acc
!==
undefined
&&
b
.
acc
!==
undefined
)
{
const
accuracy
=
record
.
acc
;
return
JSON
.
parse
(
a
.
acc
.
default
)
-
JSON
.
parse
(
b
.
acc
.
default
);
}
else
{
return
NaN
;
}
},
render
:
(
text
:
string
,
record
:
TableObjFianl
)
=>
{
let
accuracy
;
if
(
record
.
acc
!==
undefined
)
{
accuracy
=
record
.
acc
.
default
;
}
let
wei
=
0
;
let
wei
=
0
;
if
(
accuracy
)
{
if
(
accuracy
)
{
if
(
accuracy
.
toString
().
indexOf
(
'
.
'
)
!==
-
1
)
{
if
(
accuracy
.
toString
().
indexOf
(
'
.
'
)
!==
-
1
)
{
...
@@ -234,25 +363,28 @@ class TableList extends React.Component<TableListProps, TableListState> {
...
@@ -234,25 +363,28 @@ class TableList extends React.Component<TableListProps, TableListState> {
return
(
return
(
<
div
>
<
div
>
{
{
record
.
acc
record
.
acc
&&
record
.
acc
.
default
?
?
wei
>
6
wei
>
6
?
?
record
.
acc
.
toFixed
(
6
)
JSON
.
parse
(
record
.
acc
.
default
).
toFixed
(
6
)
:
:
record
.
acc
record
.
acc
.
default
:
:
'
--
'
'
--
'
}
}
</
div
>
</
div
>
);
);
}
}
},
{
});
break
;
case
'
Operation
'
:
showColumn
.
push
({
title
:
'
Operation
'
,
title
:
'
Operation
'
,
dataIndex
:
'
operation
'
,
dataIndex
:
'
operation
'
,
key
:
'
operation
'
,
key
:
'
operation
'
,
width
:
90
,
width
:
90
,
render
:
(
text
:
string
,
record
:
TableObj
)
=>
{
render
:
(
text
:
string
,
record
:
TableObj
Fianl
)
=>
{
let
trialStatus
=
record
.
status
;
let
trialStatus
=
record
.
status
;
let
flagKill
=
false
;
let
flagKill
=
false
;
if
(
trialStatus
===
'
RUNNING
'
)
{
if
(
trialStatus
===
'
RUNNING
'
)
{
...
@@ -283,12 +415,16 @@ class TableList extends React.Component<TableListProps, TableListState> {
...
@@ -283,12 +415,16 @@ class TableList extends React.Component<TableListProps, TableListState> {
)
)
);
);
},
},
},
{
});
break
;
case
'
Intermediate Result
'
:
showColumn
.
push
({
title
:
'
Intermediate Result
'
,
title
:
'
Intermediate Result
'
,
dataIndex
:
'
intermediate
'
,
dataIndex
:
'
intermediate
'
,
key
:
'
intermediate
'
,
key
:
'
intermediate
'
,
width
:
'
16%
'
,
width
:
'
16%
'
,
render
:
(
text
:
string
,
record
:
TableObj
)
=>
{
render
:
(
text
:
string
,
record
:
TableObj
Fianl
)
=>
{
return
(
return
(
<
Button
<
Button
type
=
"primary"
type
=
"primary"
...
@@ -299,10 +435,32 @@ class TableList extends React.Component<TableListProps, TableListState> {
...
@@ -299,10 +435,32 @@ class TableList extends React.Component<TableListProps, TableListState> {
</
Button
>
</
Button
>
);
);
},
},
});
break
;
default
:
showColumn
.
push
({
title
:
item
,
dataIndex
:
item
,
key
:
item
,
width
:
150
,
render
:
(
text
:
string
,
record
:
TableObjFianl
)
=>
{
return
(
<
div
>
{
record
.
acc
?
record
.
acc
[
item
]
:
'
--
'
}
</
div
>
);
}
}
];
});
}
});
const
openRow
=
(
record
:
TableObj
)
=>
{
const
openRow
=
(
record
:
TableObj
Fianl
)
=>
{
let
isHasParameters
=
true
;
let
isHasParameters
=
true
;
if
(
record
.
description
.
parameters
.
error
)
{
if
(
record
.
description
.
parameters
.
error
)
{
isHasParameters
=
false
;
isHasParameters
=
false
;
...
@@ -341,12 +499,13 @@ class TableList extends React.Component<TableListProps, TableListState> {
...
@@ -341,12 +499,13 @@ class TableList extends React.Component<TableListProps, TableListState> {
<
Row
className
=
"tableList"
>
<
Row
className
=
"tableList"
>
<
div
id
=
"tableList"
>
<
div
id
=
"tableList"
>
<
Table
<
Table
columns
=
{
c
olumn
s
}
columns
=
{
showC
olumn
}
expandedRowRender
=
{
openRow
}
expandedRowRender
=
{
openRow
}
dataSource
=
{
isHasSearch
?
searchResult
:
tableSource
}
dataSource
=
{
isHasSearch
?
searchResult
:
tableSource
}
className
=
"commonTableStyle"
className
=
"commonTableStyle"
pagination
=
{
{
pageSize
:
entries
}
}
pagination
=
{
{
pageSize
:
entries
}
}
/>
/>
{
/* Intermediate Result Modal */
}
<
Modal
<
Modal
title
=
"Intermediate Result"
title
=
"Intermediate Result"
visible
=
{
modalVisible
}
visible
=
{
modalVisible
}
...
@@ -365,6 +524,22 @@ class TableList extends React.Component<TableListProps, TableListState> {
...
@@ -365,6 +524,22 @@ class TableList extends React.Component<TableListProps, TableListState> {
/>
/>
</
Modal
>
</
Modal
>
</
div
>
</
div
>
{
/* Add Column Modal */
}
<
Modal
title
=
"Table Title"
visible
=
{
isShowColumn
}
onCancel
=
{
this
.
hideShowColumnModal
}
footer
=
{
null
}
destroyOnClose
=
{
true
}
width
=
"40%"
>
<
CheckboxGroup
options
=
{
showTitle
}
defaultValue
=
{
columnSelected
}
onChange
=
{
this
.
selectedColumn
}
className
=
"titleColumn"
/>
</
Modal
>
</
Row
>
</
Row
>
);
);
}
}
...
...
src/webui/src/static/const.ts
View file @
85cb472e
export
const
MANAGER_IP
=
`/api/v1/nni`
;
const
MANAGER_IP
=
`/api/v1/nni`
;
export
const
DOWNLOAD_IP
=
`/logs`
;
const
DOWNLOAD_IP
=
`/logs`
;
export
const
trialJobStatus
=
[
const
trialJobStatus
=
[
'
UNKNOWN
'
,
'
UNKNOWN
'
,
'
WAITING
'
,
'
WAITING
'
,
'
RUNNING
'
,
'
RUNNING
'
,
...
@@ -10,12 +10,47 @@ export const trialJobStatus = [
...
@@ -10,12 +10,47 @@ export const trialJobStatus = [
'
SYS_CANCELED
'
,
'
SYS_CANCELED
'
,
'
EARLY_STOPPED
'
'
EARLY_STOPPED
'
];
];
export
const
CONTROLTYPE
=
[
const
CONTROLTYPE
=
[
'
SEARCH_SPACE
'
,
'
SEARCH_SPACE
'
,
'
TRIAL_CONCURRENCY
'
,
'
TRIAL_CONCURRENCY
'
,
'
MAX_EXEC_DURATION
'
'
MAX_EXEC_DURATION
'
];
];
export
const
MONACO
=
{
const
MONACO
=
{
readOnly
:
true
,
readOnly
:
true
,
automaticLayout
:
true
automaticLayout
:
true
};
};
const
COLUMN_INDEX
=
[
{
name
:
'
Trial No
'
,
index
:
1
},
{
name
:
'
id
'
,
index
:
2
},
{
name
:
'
duration
'
,
index
:
3
},
{
name
:
'
status
'
,
index
:
4
},
{
name
:
'
Default
'
,
index
:
5
},
{
name
:
'
Operation
'
,
index
:
10000
},
{
name
:
'
Intermediate Result
'
,
index
:
10001
}
];
const
COLUMN
=
[
'
Trial No
'
,
'
id
'
,
'
duration
'
,
'
status
'
,
'
Default
'
,
'
Operation
'
,
'
Intermediate Result
'
];
export
{
MANAGER_IP
,
DOWNLOAD_IP
,
trialJobStatus
,
CONTROLTYPE
,
MONACO
,
COLUMN
,
COLUMN_INDEX
};
src/webui/src/static/function.ts
View file @
85cb472e
import
{
FinalResult
}
from
'
./interface
'
;
import
{
FinalResult
,
FinalType
}
from
'
./interface
'
;
const
convertTime
=
(
num
:
number
)
=>
{
const
convertTime
=
(
num
:
number
)
=>
{
if
(
num
%
3600
===
0
)
{
if
(
num
%
3600
===
0
)
{
...
@@ -28,6 +28,7 @@ const convertDuration = (num: number) => {
...
@@ -28,6 +28,7 @@ const convertDuration = (num: number) => {
};
};
// get final result value
// get final result value
// draw Accuracy point graph
const
getFinalResult
=
(
final
:
FinalResult
)
=>
{
const
getFinalResult
=
(
final
:
FinalResult
)
=>
{
let
acc
;
let
acc
;
let
showDefault
=
0
;
let
showDefault
=
0
;
...
@@ -46,6 +47,21 @@ const getFinalResult = (final: FinalResult) => {
...
@@ -46,6 +47,21 @@ const getFinalResult = (final: FinalResult) => {
}
}
};
};
// get final result value // acc obj
const
getFinal
=
(
final
:
FinalResult
)
=>
{
let
showDefault
:
FinalType
;
if
(
final
)
{
showDefault
=
JSON
.
parse
(
final
[
0
].
data
);
if
(
typeof
showDefault
===
'
number
'
)
{
showDefault
=
{
default
:
showDefault
};
}
return
showDefault
;
}
else
{
return
undefined
;
}
};
export
{
export
{
convertTime
,
convertDuration
,
getFinalResult
convertTime
,
convertDuration
,
getFinalResult
,
getFinal
};
};
src/webui/src/static/interface.ts
View file @
85cb472e
// draw accuracy graph data interface
interface
TableObj
{
interface
TableObj
{
key
:
number
;
key
:
number
;
sequenceId
:
number
;
sequenceId
:
number
;
id
:
string
;
id
:
string
;
duration
:
number
;
duration
:
number
;
status
:
string
;
status
:
string
;
acc
?:
number
;
acc
?:
number
;
// draw accuracy graph
description
:
Parameters
;
description
:
Parameters
;
color
?:
string
;
color
?:
string
;
}
}
interface
TableObjFianl
{
key
:
number
;
sequenceId
:
number
;
id
:
string
;
duration
:
number
;
status
:
string
;
acc
?:
FinalType
;
description
:
Parameters
;
color
?:
string
;
}
interface
FinalType
{
default
:
string
;
}
interface
ErrorParameter
{
interface
ErrorParameter
{
error
?:
string
;
error
?:
string
;
}
}
interface
Parameters
{
interface
Parameters
{
parameters
:
ErrorParameter
;
parameters
:
ErrorParameter
;
logPath
?:
string
;
logPath
?:
string
;
...
@@ -93,5 +111,6 @@ export {
...
@@ -93,5 +111,6 @@ export {
TableObj
,
Parameters
,
Experiment
,
TableObj
,
Parameters
,
Experiment
,
AccurPoint
,
TrialNumber
,
TrialJob
,
AccurPoint
,
TrialNumber
,
TrialJob
,
DetailAccurPoint
,
TooltipForAccuracy
,
DetailAccurPoint
,
TooltipForAccuracy
,
ParaObj
,
VisualMapValue
,
Dimobj
,
FinalResult
ParaObj
,
VisualMapValue
,
Dimobj
,
FinalResult
,
TableObjFianl
,
FinalType
};
};
src/webui/src/static/style/search.scss
View file @
85cb472e
/* some buttons about trial-detail table */
.allList
{
.allList
{
width
:
96%
;
width
:
96%
;
margin
:
0
auto
;
margin
:
0
auto
;
...
@@ -17,4 +18,17 @@
...
@@ -17,4 +18,17 @@
}
}
}
}
.titleColumn
{
.ant-checkbox-group-item
{
display
:
block
;
}
}
.applyfooter
{
/* apply button style */
.apply
{
text-align
:
right
;
}
}
tools/nni_cmd/config_schema.py
View file @
85cb472e
...
@@ -68,6 +68,16 @@ Optional('tuner'): Or({
...
@@ -68,6 +68,16 @@ Optional('tuner'): Or({
Optional
(
'n_output_node'
):
int
,
Optional
(
'n_output_node'
):
int
,
},
},
Optional
(
'gpuNum'
):
And
(
int
,
lambda
x
:
0
<=
x
<=
99999
),
Optional
(
'gpuNum'
):
And
(
int
,
lambda
x
:
0
<=
x
<=
99999
),
},{
'builtinTunerName'
:
'MetisTuner'
,
'classArgs'
:
{
Optional
(
'optimize_mode'
):
Or
(
'maximize'
,
'minimize'
),
Optional
(
'no_resampling'
):
bool
,
Optional
(
'no_candidates'
):
bool
,
Optional
(
'selection_num_starting_points'
):
int
,
Optional
(
'cold_start_num'
):
int
,
},
Optional
(
'gpuNum'
):
And
(
int
,
lambda
x
:
0
<=
x
<=
99999
),
},{
},{
'codeDir'
:
os
.
path
.
exists
,
'codeDir'
:
os
.
path
.
exists
,
'classFileName'
:
str
,
'classFileName'
:
str
,
...
...
tools/nni_cmd/launcher_utils.py
View file @
85cb472e
...
@@ -21,7 +21,7 @@
...
@@ -21,7 +21,7 @@
import
os
import
os
import
json
import
json
from
.config_schema
import
LOCAL_CONFIG_SCHEMA
,
REMOTE_CONFIG_SCHEMA
,
PAI_CONFIG_SCHEMA
,
KUBEFLOW_CONFIG_SCHEMA
,
FRAMEWORKCONTROLLER_CONFIG_SCHEMA
from
.config_schema
import
LOCAL_CONFIG_SCHEMA
,
REMOTE_CONFIG_SCHEMA
,
PAI_CONFIG_SCHEMA
,
KUBEFLOW_CONFIG_SCHEMA
,
FRAMEWORKCONTROLLER_CONFIG_SCHEMA
from
.common_utils
import
get_json_content
,
print_error
,
print_warning
from
.common_utils
import
get_json_content
,
print_error
,
print_warning
,
print_normal
def
expand_path
(
experiment_config
,
key
):
def
expand_path
(
experiment_config
,
key
):
'''Change '~' to user home directory'''
'''Change '~' to user home directory'''
...
@@ -32,7 +32,7 @@ def parse_relative_path(root_path, experiment_config, key):
...
@@ -32,7 +32,7 @@ def parse_relative_path(root_path, experiment_config, key):
'''Change relative path to absolute path'''
'''Change relative path to absolute path'''
if
experiment_config
.
get
(
key
)
and
not
os
.
path
.
isabs
(
experiment_config
.
get
(
key
)):
if
experiment_config
.
get
(
key
)
and
not
os
.
path
.
isabs
(
experiment_config
.
get
(
key
)):
absolute_path
=
os
.
path
.
join
(
root_path
,
experiment_config
.
get
(
key
))
absolute_path
=
os
.
path
.
join
(
root_path
,
experiment_config
.
get
(
key
))
print_
warning
(
'expand %s: %s to %s '
%
(
key
,
experiment_config
[
key
],
absolute_path
))
print_
normal
(
'expand %s: %s to %s '
%
(
key
,
experiment_config
[
key
],
absolute_path
))
experiment_config
[
key
]
=
absolute_path
experiment_config
[
key
]
=
absolute_path
def
parse_time
(
experiment_config
):
def
parse_time
(
experiment_config
):
...
...
tools/nni_trial_tool/log_utils.py
View file @
85cb472e
...
@@ -129,6 +129,7 @@ class PipeLogReader(threading.Thread):
...
@@ -129,6 +129,7 @@ class PipeLogReader(threading.Thread):
self
.
pipeReader
=
os
.
fdopen
(
self
.
fdRead
)
self
.
pipeReader
=
os
.
fdopen
(
self
.
fdRead
)
self
.
orig_stdout
=
sys
.
__stdout__
self
.
orig_stdout
=
sys
.
__stdout__
self
.
_is_read_completed
=
False
self
.
_is_read_completed
=
False
self
.
process_exit
=
False
def
_populateQueue
(
stream
,
queue
):
def
_populateQueue
(
stream
,
queue
):
'''
'''
...
@@ -136,6 +137,7 @@ class PipeLogReader(threading.Thread):
...
@@ -136,6 +137,7 @@ class PipeLogReader(threading.Thread):
'''
'''
time
.
sleep
(
5
)
time
.
sleep
(
5
)
while
True
:
while
True
:
cur_process_exit
=
self
.
process_exit
try
:
try
:
line
=
self
.
queue
.
get
(
True
,
5
)
line
=
self
.
queue
.
get
(
True
,
5
)
try
:
try
:
...
@@ -145,6 +147,7 @@ class PipeLogReader(threading.Thread):
...
@@ -145,6 +147,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
:
self
.
_is_read_completed
=
True
self
.
_is_read_completed
=
True
break
break
...
@@ -176,3 +179,7 @@ class PipeLogReader(threading.Thread):
...
@@ -176,3 +179,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
):
self
.
process_exit
=
True
return
self
.
process_exit
\ No newline at end of file
Prev
1
2
3
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