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
050ee2bb
Unverified
Commit
050ee2bb
authored
Nov 10, 2020
by
J-shang
Committed by
GitHub
Nov 10, 2020
Browse files
unify trial job id name (#3053)
Co-authored-by:
Ning Shang
<
nishang@microsoft.com
>
parent
be652aa4
Changes
15
Show whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
37 additions
and
43 deletions
+37
-43
nni/experiment/nni_client.py
nni/experiment/nni_client.py
+2
-8
nni/tools/nnictl/nnictl_utils.py
nni/tools/nnictl/nnictl_utils.py
+6
-6
nni/tools/nnictl/tensorboard_utils.py
nni/tools/nnictl/tensorboard_utils.py
+2
-2
test/nni_test/nnitest/utils.py
test/nni_test/nnitest/utils.py
+1
-1
ts/nni_manager/common/datastore.ts
ts/nni_manager/common/datastore.ts
+2
-2
ts/nni_manager/core/nniDataStore.ts
ts/nni_manager/core/nniDataStore.ts
+6
-6
ts/nni_manager/core/nnimanager.ts
ts/nni_manager/core/nnimanager.ts
+2
-2
ts/nni_manager/core/test/mockedDatastore.ts
ts/nni_manager/core/test/mockedDatastore.ts
+3
-3
ts/nni_manager/core/test/nnimanager.test.ts
ts/nni_manager/core/test/nnimanager.test.ts
+1
-1
ts/nni_manager/rest_server/test/mockedNNIManager.ts
ts/nni_manager/rest_server/test/mockedNNIManager.ts
+3
-3
ts/nni_manager/rest_server/test/restserver.test.ts
ts/nni_manager/rest_server/test/restserver.test.ts
+1
-1
ts/webui/src/components/Overview.tsx
ts/webui/src/components/Overview.tsx
+1
-1
ts/webui/src/static/interface.ts
ts/webui/src/static/interface.ts
+1
-1
ts/webui/src/static/model/trial.ts
ts/webui/src/static/model/trial.ts
+3
-3
ts/webui/src/static/model/trialmanager.ts
ts/webui/src/static/model/trialmanager.ts
+3
-3
No files found.
nni/experiment/nni_client.py
View file @
050ee2bb
...
...
@@ -99,9 +99,6 @@ class TrialResult:
self
.
value
=
None
self
.
trialJobId
=
None
for
key
in
json_obj
.
keys
():
if
key
==
'id'
:
setattr
(
self
,
'trialJobId'
,
json_obj
[
key
])
elif
hasattr
(
self
,
key
):
setattr
(
self
,
key
,
json_obj
[
key
])
self
.
value
=
json
.
loads
(
self
.
value
)
...
...
@@ -219,9 +216,6 @@ class TrialJob:
self
.
finalMetricData
=
None
self
.
stderrPath
=
None
for
key
in
json_obj
.
keys
():
if
key
==
'id'
:
setattr
(
self
,
'trialJobId'
,
json_obj
[
key
])
elif
hasattr
(
self
,
key
):
setattr
(
self
,
key
,
json_obj
[
key
])
if
self
.
hyperParameters
:
self
.
hyperParameters
=
[
TrialHyperParameters
(
json
.
loads
(
e
))
for
e
in
self
.
hyperParameters
]
...
...
nni/tools/nnictl/nnictl_utils.py
View file @
050ee2bb
...
...
@@ -388,9 +388,9 @@ def log_trial(args):
if
response
and
check_response
(
response
):
content
=
json
.
loads
(
response
.
text
)
for
trial
in
content
:
trial_id_list
.
append
(
trial
.
get
(
'
i
d'
))
trial_id_list
.
append
(
trial
.
get
(
'
trialJobI
d'
))
if
trial
.
get
(
'logPath'
):
trial_id_path_dict
[
trial
.
get
(
'
i
d'
)]
=
trial
[
'logPath'
]
trial_id_path_dict
[
trial
.
get
(
'
trialJobI
d'
)]
=
trial
[
'logPath'
]
else
:
print_error
(
'Restful server is not running...'
)
exit
(
1
)
...
...
@@ -674,7 +674,7 @@ def show_experiment_info():
content
=
json
.
loads
(
response
.
text
)
for
index
,
value
in
enumerate
(
content
):
content
[
index
]
=
convert_time_stamp_to_date
(
value
)
print
(
TRIAL_MONITOR_CONTENT
%
(
content
[
index
].
get
(
'
i
d'
),
content
[
index
].
get
(
'startTime'
),
\
print
(
TRIAL_MONITOR_CONTENT
%
(
content
[
index
].
get
(
'
trialJobI
d'
),
content
[
index
].
get
(
'startTime'
),
\
content
[
index
].
get
(
'endTime'
),
content
[
index
].
get
(
'status'
)))
print
(
TRIAL_MONITOR_TAIL
)
...
...
@@ -747,7 +747,7 @@ def export_trials_data(args):
return
intermediate_results
=
groupby_trial_id
(
json
.
loads
(
intermediate_results_response
.
text
))
for
record
in
content
:
record
[
'intermediate'
]
=
intermediate_results
[
record
[
'
i
d'
]]
record
[
'intermediate'
]
=
intermediate_results
[
record
[
'
trialJobI
d'
]]
if
args
.
type
==
'json'
:
with
open
(
args
.
path
,
'w'
)
as
file
:
file
.
write
(
json
.
dumps
(
content
))
...
...
@@ -759,9 +759,9 @@ def export_trials_data(args):
formated_record
[
'intermediate'
]
=
'['
+
','
.
join
(
record
[
'intermediate'
])
+
']'
record_value
=
json
.
loads
(
record
[
'value'
])
if
not
isinstance
(
record_value
,
(
float
,
int
)):
formated_record
.
update
({
**
record
[
'parameter'
],
**
record_value
,
**
{
'
i
d'
:
record
[
'
i
d'
]}})
formated_record
.
update
({
**
record
[
'parameter'
],
**
record_value
,
**
{
'
trialJobI
d'
:
record
[
'
trialJobI
d'
]}})
else
:
formated_record
.
update
({
**
record
[
'parameter'
],
**
{
'reward'
:
record_value
,
'
i
d'
:
record
[
'
i
d'
]}})
formated_record
.
update
({
**
record
[
'parameter'
],
**
{
'reward'
:
record_value
,
'
trialJobI
d'
:
record
[
'
trialJobI
d'
]}})
trial_records
.
append
(
formated_record
)
if
not
trial_records
:
print_error
(
'No trial results collected! Please check your trial log...'
)
...
...
nni/tools/nnictl/tensorboard_utils.py
View file @
050ee2bb
...
...
@@ -19,7 +19,7 @@ def parse_log_path(args, trial_content):
path_list
=
[]
host_list
=
[]
for
trial
in
trial_content
:
if
args
.
trial_id
and
args
.
trial_id
!=
'all'
and
trial
.
get
(
'
i
d'
)
!=
args
.
trial_id
:
if
args
.
trial_id
and
args
.
trial_id
!=
'all'
and
trial
.
get
(
'
trialJobI
d'
)
!=
args
.
trial_id
:
continue
pattern
=
r
'(?P<head>.+)://(?P<host>.+):(?P<path>.*)'
match
=
re
.
search
(
pattern
,
trial
[
'logPath'
])
...
...
@@ -40,7 +40,7 @@ def copy_data_from_remote(args, nni_config, trial_content, path_list, host_list,
machine_dict
[
machine
[
'ip'
]]
=
{
'port'
:
machine
[
'port'
],
'passwd'
:
machine
[
'passwd'
],
'username'
:
machine
[
'username'
],
'sshKeyPath'
:
machine
.
get
(
'sshKeyPath'
),
'passphrase'
:
machine
.
get
(
'passphrase'
)}
for
index
,
host
in
enumerate
(
host_list
):
local_path
=
os
.
path
.
join
(
temp_nni_path
,
trial_content
[
index
].
get
(
'
i
d'
))
local_path
=
os
.
path
.
join
(
temp_nni_path
,
trial_content
[
index
].
get
(
'
trialJobI
d'
))
local_path_list
.
append
(
local_path
)
print_normal
(
'Copying log data from %s to %s'
%
(
host
+
':'
+
path_list
[
index
],
local_path
))
sftp
=
create_ssh_sftp_client
(
host
,
machine_dict
[
host
][
'port'
],
machine_dict
[
host
][
'username'
],
machine_dict
[
host
][
'passwd'
],
...
...
test/nni_test/nnitest/utils.py
View file @
050ee2bb
...
...
@@ -124,7 +124,7 @@ def print_file_content(filepath):
def
print_trial_job_log
(
training_service
,
trial_jobs_url
):
trial_jobs
=
get_trial_jobs
(
trial_jobs_url
)
for
trial_job
in
trial_jobs
:
trial_log_dir
=
os
.
path
.
join
(
get_experiment_dir
(
EXPERIMENT_URL
),
'trials'
,
trial_job
[
'
i
d'
])
trial_log_dir
=
os
.
path
.
join
(
get_experiment_dir
(
EXPERIMENT_URL
),
'trials'
,
trial_job
[
'
trialJobI
d'
])
log_files
=
[
'stderr'
,
'trial.log'
]
if
training_service
==
'local'
else
[
'stdout_log_collection.log'
]
for
log_file
in
log_files
:
print_file_content
(
os
.
path
.
join
(
trial_log_dir
,
log_file
))
...
...
ts/nni_manager/common/datastore.ts
View file @
050ee2bb
...
...
@@ -43,7 +43,7 @@ interface MetricDataRecord {
}
interface
TrialJobInfo
{
i
d
:
string
;
trialJobI
d
:
string
;
sequenceId
?:
number
;
status
:
TrialJobStatus
;
startTime
?:
number
;
...
...
@@ -63,7 +63,7 @@ interface HyperParameterFormat {
interface
ExportedDataFormat
{
parameter
:
Record
<
string
,
any
>
;
value
:
Record
<
string
,
any
>
;
i
d
:
string
;
trialJobI
d
:
string
;
}
abstract
class
DataStore
{
...
...
ts/nni_manager/core/nniDataStore.ts
View file @
050ee2bb
...
...
@@ -168,7 +168,7 @@ class NNIDataStore implements DataStore {
const
oneEntry
:
ExportedDataFormat
=
{
parameter
:
parameters
.
parameters
,
value
:
JSON
.
parse
(
job
.
finalMetricData
[
0
].
data
),
id
:
job
.
i
d
trialJobId
:
job
.
trialJobI
d
};
exportedData
.
push
(
oneEntry
);
}
else
{
...
...
@@ -188,7 +188,7 @@ class NNIDataStore implements DataStore {
const
oneEntry
:
ExportedDataFormat
=
{
parameter
:
value
,
value
:
metricValue
,
id
:
job
.
i
d
trialJobId
:
job
.
trialJobI
d
};
exportedData
.
push
(
oneEntry
);
}
...
...
@@ -229,7 +229,7 @@ class NNIDataStore implements DataStore {
}
if
(
!
(
status
!==
undefined
&&
jobInfo
.
status
!==
status
))
{
if
(
jobInfo
.
status
===
'
SUCCEEDED
'
)
{
jobInfo
.
finalMetricData
=
finalMetricsMap
.
get
(
jobInfo
.
i
d
);
jobInfo
.
finalMetricData
=
finalMetricsMap
.
get
(
jobInfo
.
trialJobI
d
);
}
result
.
push
(
jobInfo
);
}
...
...
@@ -320,7 +320,7 @@ class NNIDataStore implements DataStore {
jobInfo
=
map
.
get
(
record
.
trialJobId
);
}
else
{
jobInfo
=
{
i
d
:
record
.
trialJobId
,
trialJobI
d
:
record
.
trialJobId
,
status
:
this
.
getJobStatusByLatestEvent
(
'
UNKNOWN
'
,
record
.
event
),
hyperParameters
:
[]
};
...
...
@@ -364,14 +364,14 @@ class NNIDataStore implements DataStore {
const
newHParam
:
any
=
this
.
parseHyperParameter
(
record
.
data
);
if
(
newHParam
!==
undefined
)
{
if
(
jobInfo
.
hyperParameters
!==
undefined
)
{
let
hParamIds
:
Set
<
number
>
|
undefined
=
hParamIdMap
.
get
(
jobInfo
.
i
d
);
let
hParamIds
:
Set
<
number
>
|
undefined
=
hParamIdMap
.
get
(
jobInfo
.
trialJobI
d
);
if
(
hParamIds
===
undefined
)
{
hParamIds
=
new
Set
();
}
if
(
!
hParamIds
.
has
(
newHParam
.
parameter_index
))
{
jobInfo
.
hyperParameters
.
push
(
JSON
.
stringify
(
newHParam
));
hParamIds
.
add
(
newHParam
.
parameter_index
);
hParamIdMap
.
set
(
jobInfo
.
i
d
,
hParamIds
);
hParamIdMap
.
set
(
jobInfo
.
trialJobI
d
,
hParamIds
);
}
}
else
{
assert
(
false
,
'
jobInfo.hyperParameters is undefined
'
);
...
...
ts/nni_manager/core/nnimanager.ts
View file @
050ee2bb
...
...
@@ -231,7 +231,7 @@ class NNIManager implements Manager {
// Check the final status for WAITING and RUNNING jobs
await
Promise
.
all
(
allTrialJobs
.
filter
((
job
:
TrialJobInfo
)
=>
job
.
status
===
'
WAITING
'
||
job
.
status
===
'
RUNNING
'
)
.
map
((
job
:
TrialJobInfo
)
=>
this
.
dataStore
.
storeTrialJobEvent
(
'
FAILED
'
,
job
.
i
d
)));
.
map
((
job
:
TrialJobInfo
)
=>
this
.
dataStore
.
storeTrialJobEvent
(
'
FAILED
'
,
job
.
trialJobI
d
)));
// Collect generated trials and imported trials
const
finishedTrialData
:
string
=
await
this
.
exportData
();
...
...
@@ -304,7 +304,7 @@ class NNIManager implements Manager {
// FIXME: can this be undefined?
trial
.
sequenceId
!==
undefined
&&
minSeqId
<=
trial
.
sequenceId
&&
trial
.
sequenceId
<=
maxSeqId
));
const
targetTrialIds
=
new
Set
(
targetTrials
.
map
(
trial
=>
trial
.
i
d
));
const
targetTrialIds
=
new
Set
(
targetTrials
.
map
(
trial
=>
trial
.
trialJobI
d
));
const
allMetrics
=
await
this
.
dataStore
.
getMetricData
();
return
allMetrics
.
filter
(
metric
=>
targetTrialIds
.
has
(
metric
.
trialJobId
));
...
...
ts/nni_manager/core/test/mockedDatastore.ts
View file @
050ee2bb
...
...
@@ -161,7 +161,7 @@ class MockedDataStore implements DataStore {
}
if
(
!
(
status
&&
jobInfo
.
status
!==
status
))
{
if
(
jobInfo
.
status
===
'
SUCCEEDED
'
)
{
jobInfo
.
finalMetricData
=
await
this
.
getFinalMetricData
(
jobInfo
.
i
d
);
jobInfo
.
finalMetricData
=
await
this
.
getFinalMetricData
(
jobInfo
.
trialJobI
d
);
}
result
.
push
(
jobInfo
);
}
...
...
@@ -206,7 +206,7 @@ class MockedDataStore implements DataStore {
public
getTrialJob
(
trialJobId
:
string
):
Promise
<
TrialJobInfo
>
{
return
Promise
.
resolve
({
i
d
:
'
1234
'
,
trialJobI
d
:
'
1234
'
,
status
:
'
SUCCEEDED
'
,
startTime
:
Date
.
now
(),
endTime
:
Date
.
now
()
...
...
@@ -242,7 +242,7 @@ class MockedDataStore implements DataStore {
jobInfo
=
map
.
get
(
record
.
trialJobId
);
}
else
{
jobInfo
=
{
i
d
:
record
.
trialJobId
,
trialJobI
d
:
record
.
trialJobId
,
status
:
this
.
getJobStatusByLatestEvent
(
record
.
event
),
};
}
...
...
ts/nni_manager/core/test/nnimanager.test.ts
View file @
050ee2bb
...
...
@@ -122,7 +122,7 @@ describe('Unit test for nnimanager', function () {
it
(
'
test getTrialJob valid
'
,
()
=>
{
//query a exist id
return
nniManager
.
getTrialJob
(
'
1234
'
).
then
(
function
(
trialJobDetail
)
{
expect
(
trialJobDetail
.
i
d
).
to
.
be
.
equal
(
'
1234
'
);
expect
(
trialJobDetail
.
trialJobI
d
).
to
.
be
.
equal
(
'
1234
'
);
}).
catch
((
error
)
=>
{
assert
.
fail
(
error
);
})
...
...
ts/nni_manager/rest_server/test/mockedNNIManager.ts
View file @
050ee2bb
...
...
@@ -101,7 +101,7 @@ export class MockedNNIManager extends Manager {
public
getTrialJob
(
trialJobId
:
string
):
Promise
<
TrialJobInfo
>
{
const
deferred
:
Deferred
<
TrialJobInfo
>
=
new
Deferred
<
TrialJobInfo
>
();
const
jobInfo
:
TrialJobInfo
=
{
i
d
:
'
1234
'
,
trialJobI
d
:
'
1234
'
,
status
:
'
SUCCEEDED
'
,
startTime
:
Date
.
now
(),
endTime
:
Date
.
now
()
...
...
@@ -152,7 +152,7 @@ export class MockedNNIManager extends Manager {
}
public
listTrialJobs
(
status
?:
TrialJobStatus
):
Promise
<
TrialJobInfo
[]
>
{
const
job1
:
TrialJobInfo
=
{
i
d
:
'
1234
'
,
trialJobI
d
:
'
1234
'
,
status
:
'
SUCCEEDED
'
,
startTime
:
Date
.
now
(),
endTime
:
Date
.
now
(),
...
...
@@ -166,7 +166,7 @@ export class MockedNNIManager extends Manager {
}]
};
const
job2
:
TrialJobInfo
=
{
i
d
:
'
3456
'
,
trialJobI
d
:
'
3456
'
,
status
:
'
FAILED
'
,
startTime
:
Date
.
now
(),
endTime
:
Date
.
now
(),
...
...
ts/nni_manager/rest_server/test/restserver.test.ts
View file @
050ee2bb
...
...
@@ -57,7 +57,7 @@ describe('Unit test for rest server', () => {
assert
.
fail
(
err
.
message
);
}
else
{
expect
(
res
.
statusCode
).
to
.
equal
(
200
);
expect
(
JSON
.
parse
(
body
).
i
d
).
to
.
equal
(
'
1234
'
);
expect
(
JSON
.
parse
(
body
).
trialJobI
d
).
to
.
equal
(
'
1234
'
);
}
done
();
});
...
...
ts/webui/src/components/Overview.tsx
View file @
050ee2bb
...
...
@@ -167,7 +167,7 @@ class Overview extends React.Component<{}, OverviewState> {
</
Stack
>
</
div
>
</
Stack
>
<
SuccessTable
trialIds
=
{
bestTrials
.
map
(
trial
=>
trial
.
info
.
i
d
)
}
/>
<
SuccessTable
trialIds
=
{
bestTrials
.
map
(
trial
=>
trial
.
info
.
trialJobI
d
)
}
/>
</
div
>
<
div
className
=
'overviewCommand1'
>
<
Command1
/>
...
...
ts/webui/src/static/interface.ts
View file @
050ee2bb
...
...
@@ -131,7 +131,7 @@ interface MetricDataRecord {
}
interface
TrialJobInfo
{
i
d
:
string
;
trialJobI
d
:
string
;
sequenceId
:
number
;
status
:
string
;
startTime
?:
number
;
...
...
ts/webui/src/static/model/trial.ts
View file @
050ee2bb
...
...
@@ -144,9 +144,9 @@ class Trial implements TableObj {
}
return
{
key
:
this
.
info
.
i
d
,
key
:
this
.
info
.
trialJobI
d
,
sequenceId
:
this
.
info
.
sequenceId
,
id
:
this
.
info
.
i
d
,
id
:
this
.
info
.
trialJobI
d
,
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
startTime
:
this
.
info
.
startTime
!
,
endTime
:
this
.
info
.
endTime
,
...
...
@@ -169,7 +169,7 @@ class Trial implements TableObj {
}
get
id
():
string
{
return
this
.
info
.
i
d
;
return
this
.
info
.
trialJobI
d
;
}
get
duration
():
number
{
...
...
ts/webui/src/static/model/trialmanager.ts
View file @
050ee2bb
...
...
@@ -172,11 +172,11 @@ class TrialManager {
requestAxios
(
`
${
MANAGER_IP
}
/trial-jobs`
)
.
then
(
data
=>
{
for
(
const
trialInfo
of
data
as
TrialJobInfo
[])
{
if
(
this
.
trials
.
has
(
trialInfo
.
i
d
))
{
if
(
this
.
trials
.
has
(
trialInfo
.
trialJobI
d
))
{
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
updated
=
this
.
trials
.
get
(
trialInfo
.
i
d
)
!
.
updateTrialJobInfo
(
trialInfo
)
||
updated
;
updated
=
this
.
trials
.
get
(
trialInfo
.
trialJobI
d
)
!
.
updateTrialJobInfo
(
trialInfo
)
||
updated
;
}
else
{
this
.
trials
.
set
(
trialInfo
.
i
d
,
new
Trial
(
trialInfo
,
undefined
));
this
.
trials
.
set
(
trialInfo
.
trialJobI
d
,
new
Trial
(
trialInfo
,
undefined
));
updated
=
true
;
}
this
.
maxSequenceId
=
Math
.
max
(
this
.
maxSequenceId
,
trialInfo
.
sequenceId
);
...
...
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