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
b07309d9
Commit
b07309d9
authored
Oct 30, 2018
by
chicm-ms
Committed by
fishyds
Oct 30, 2018
Browse files
Add sequenceId to TrialJobInfo (#283)
parent
da21bf2c
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
30 additions
and
14 deletions
+30
-14
src/nni_manager/common/datastore.ts
src/nni_manager/common/datastore.ts
+6
-2
src/nni_manager/core/nniDataStore.ts
src/nni_manager/core/nniDataStore.ts
+8
-4
src/nni_manager/core/nnimanager.ts
src/nni_manager/core/nnimanager.ts
+2
-2
src/nni_manager/core/sqlDatabase.ts
src/nni_manager/core/sqlDatabase.ts
+14
-6
No files found.
src/nni_manager/common/datastore.ts
View file @
b07309d9
...
@@ -38,6 +38,7 @@ interface TrialJobEventRecord {
...
@@ -38,6 +38,7 @@ interface TrialJobEventRecord {
readonly
event
:
TrialJobEvent
;
readonly
event
:
TrialJobEvent
;
readonly
data
?:
string
;
readonly
data
?:
string
;
readonly
logPath
?:
string
;
readonly
logPath
?:
string
;
readonly
sequenceId
?:
number
;
}
}
interface
MetricData
{
interface
MetricData
{
...
@@ -59,6 +60,7 @@ interface MetricDataRecord {
...
@@ -59,6 +60,7 @@ interface MetricDataRecord {
interface
TrialJobInfo
{
interface
TrialJobInfo
{
id
:
string
;
id
:
string
;
sequenceId
?:
number
;
status
:
TrialJobStatus
;
status
:
TrialJobStatus
;
startTime
?:
number
;
startTime
?:
number
;
endTime
?:
number
;
endTime
?:
number
;
...
@@ -73,7 +75,8 @@ abstract class DataStore {
...
@@ -73,7 +75,8 @@ abstract class DataStore {
public
abstract
close
():
Promise
<
void
>
;
public
abstract
close
():
Promise
<
void
>
;
public
abstract
storeExperimentProfile
(
experimentProfile
:
ExperimentProfile
):
Promise
<
void
>
;
public
abstract
storeExperimentProfile
(
experimentProfile
:
ExperimentProfile
):
Promise
<
void
>
;
public
abstract
getExperimentProfile
(
experimentId
:
string
):
Promise
<
ExperimentProfile
>
;
public
abstract
getExperimentProfile
(
experimentId
:
string
):
Promise
<
ExperimentProfile
>
;
public
abstract
storeTrialJobEvent
(
event
:
TrialJobEvent
,
trialJobId
:
string
,
data
?:
string
,
logPath
?:
string
):
Promise
<
void
>
;
public
abstract
storeTrialJobEvent
(
event
:
TrialJobEvent
,
trialJobId
:
string
,
hyperParameter
?:
string
,
jobDetail
?:
TrialJobDetail
):
Promise
<
void
>
;
public
abstract
getTrialJobStatistics
():
Promise
<
TrialJobStatistics
[]
>
;
public
abstract
getTrialJobStatistics
():
Promise
<
TrialJobStatistics
[]
>
;
public
abstract
listTrialJobs
(
status
?:
TrialJobStatus
):
Promise
<
TrialJobInfo
[]
>
;
public
abstract
listTrialJobs
(
status
?:
TrialJobStatus
):
Promise
<
TrialJobInfo
[]
>
;
public
abstract
getTrialJob
(
trialJobId
:
string
):
Promise
<
TrialJobInfo
>
;
public
abstract
getTrialJob
(
trialJobId
:
string
):
Promise
<
TrialJobInfo
>
;
...
@@ -87,7 +90,8 @@ abstract class Database {
...
@@ -87,7 +90,8 @@ abstract class Database {
public
abstract
storeExperimentProfile
(
experimentProfile
:
ExperimentProfile
):
Promise
<
void
>
;
public
abstract
storeExperimentProfile
(
experimentProfile
:
ExperimentProfile
):
Promise
<
void
>
;
public
abstract
queryExperimentProfile
(
experimentId
:
string
,
revision
?:
number
):
Promise
<
ExperimentProfile
[]
>
;
public
abstract
queryExperimentProfile
(
experimentId
:
string
,
revision
?:
number
):
Promise
<
ExperimentProfile
[]
>
;
public
abstract
queryLatestExperimentProfile
(
experimentId
:
string
):
Promise
<
ExperimentProfile
>
;
public
abstract
queryLatestExperimentProfile
(
experimentId
:
string
):
Promise
<
ExperimentProfile
>
;
public
abstract
storeTrialJobEvent
(
event
:
TrialJobEvent
,
trialJobId
:
string
,
data
?:
string
,
logPath
?:
string
):
Promise
<
void
>
;
public
abstract
storeTrialJobEvent
(
event
:
TrialJobEvent
,
trialJobId
:
string
,
hyperParameter
?:
string
,
jobDetail
?:
TrialJobDetail
):
Promise
<
void
>
;
public
abstract
queryTrialJobEvent
(
trialJobId
?:
string
,
event
?:
TrialJobEvent
):
Promise
<
TrialJobEventRecord
[]
>
;
public
abstract
queryTrialJobEvent
(
trialJobId
?:
string
,
event
?:
TrialJobEvent
):
Promise
<
TrialJobEventRecord
[]
>
;
public
abstract
storeMetricData
(
trialJobId
:
string
,
data
:
string
):
Promise
<
void
>
;
public
abstract
storeMetricData
(
trialJobId
:
string
,
data
:
string
):
Promise
<
void
>
;
public
abstract
queryMetricData
(
trialJobId
?:
string
,
type
?:
MetricType
):
Promise
<
MetricDataRecord
[]
>
;
public
abstract
queryMetricData
(
trialJobId
?:
string
,
type
?:
MetricType
):
Promise
<
MetricDataRecord
[]
>
;
...
...
src/nni_manager/core/nniDataStore.ts
View file @
b07309d9
...
@@ -29,7 +29,7 @@ import { NNIError } from '../common/errors';
...
@@ -29,7 +29,7 @@ import { NNIError } from '../common/errors';
import
{
getExperimentId
,
isNewExperiment
}
from
'
../common/experimentStartupInfo
'
;
import
{
getExperimentId
,
isNewExperiment
}
from
'
../common/experimentStartupInfo
'
;
import
{
getLogger
,
Logger
}
from
'
../common/log
'
;
import
{
getLogger
,
Logger
}
from
'
../common/log
'
;
import
{
ExperimentProfile
,
TrialJobStatistics
}
from
'
../common/manager
'
;
import
{
ExperimentProfile
,
TrialJobStatistics
}
from
'
../common/manager
'
;
import
{
TrialJobStatus
}
from
'
../common/trainingService
'
;
import
{
TrialJobDetail
,
TrialJobStatus
}
from
'
../common/trainingService
'
;
import
{
getDefaultDatabaseDir
,
mkDirP
}
from
'
../common/utils
'
;
import
{
getDefaultDatabaseDir
,
mkDirP
}
from
'
../common/utils
'
;
class
NNIDataStore
implements
DataStore
{
class
NNIDataStore
implements
DataStore
{
...
@@ -83,10 +83,11 @@ class NNIDataStore implements DataStore {
...
@@ -83,10 +83,11 @@ class NNIDataStore implements DataStore {
return
this
.
db
.
queryLatestExperimentProfile
(
experimentId
);
return
this
.
db
.
queryLatestExperimentProfile
(
experimentId
);
}
}
public
storeTrialJobEvent
(
event
:
TrialJobEvent
,
trialJobId
:
string
,
data
?:
string
,
logPath
?:
string
):
Promise
<
void
>
{
public
storeTrialJobEvent
(
this
.
log
.
debug
(
`storeTrialJobEvent: event:
${
event
}
, data:
${
data
}
, logpath:
${
logPath
}
`
);
event
:
TrialJobEvent
,
trialJobId
:
string
,
hyperParameter
?:
string
,
jobDetail
?:
TrialJobDetail
):
Promise
<
void
>
{
this
.
log
.
debug
(
`storeTrialJobEvent: event:
${
event
}
, data:
${
hyperParameter
}
, jobDetail:
${
JSON
.
stringify
(
jobDetail
)}
`
);
return
this
.
db
.
storeTrialJobEvent
(
event
,
trialJobId
,
data
,
logPath
).
catch
(
return
this
.
db
.
storeTrialJobEvent
(
event
,
trialJobId
,
hyperParameter
,
jobDetail
).
catch
(
(
err
:
Error
)
=>
{
(
err
:
Error
)
=>
{
throw
new
NNIError
(
'
Datastore error
'
,
`Datastore error:
${
err
.
message
}
`
,
err
);
throw
new
NNIError
(
'
Datastore error
'
,
`Datastore error:
${
err
.
message
}
`
,
err
);
}
}
...
@@ -281,6 +282,9 @@ class NNIDataStore implements DataStore {
...
@@ -281,6 +282,9 @@ class NNIDataStore implements DataStore {
assert
(
false
,
'
jobInfo.hyperParameters is undefined
'
);
assert
(
false
,
'
jobInfo.hyperParameters is undefined
'
);
}
}
}
}
if
(
record
.
sequenceId
!==
undefined
&&
jobInfo
.
sequenceId
===
undefined
)
{
jobInfo
.
sequenceId
=
record
.
sequenceId
;
}
map
.
set
(
record
.
trialJobId
,
jobInfo
);
map
.
set
(
record
.
trialJobId
,
jobInfo
);
}
}
...
...
src/nni_manager/core/nnimanager.ts
View file @
b07309d9
...
@@ -355,7 +355,7 @@ class NNIManager implements Manager {
...
@@ -355,7 +355,7 @@ class NNIManager implements Manager {
const
oldTrialJobDetail
:
TrialJobDetail
|
undefined
=
this
.
trialJobs
.
get
(
trialJobId
);
const
oldTrialJobDetail
:
TrialJobDetail
|
undefined
=
this
.
trialJobs
.
get
(
trialJobId
);
if
(
oldTrialJobDetail
!==
undefined
&&
oldTrialJobDetail
.
status
!==
trialJobDetail
.
status
)
{
if
(
oldTrialJobDetail
!==
undefined
&&
oldTrialJobDetail
.
status
!==
trialJobDetail
.
status
)
{
this
.
trialJobs
.
set
(
trialJobId
,
Object
.
assign
({},
trialJobDetail
));
this
.
trialJobs
.
set
(
trialJobId
,
Object
.
assign
({},
trialJobDetail
));
await
this
.
dataStore
.
storeTrialJobEvent
(
trialJobDetail
.
status
,
trialJobDetail
.
id
,
undefined
,
trialJobDetail
.
url
);
await
this
.
dataStore
.
storeTrialJobEvent
(
trialJobDetail
.
status
,
trialJobDetail
.
id
,
undefined
,
trialJobDetail
);
}
}
switch
(
trialJobDetail
.
status
)
{
switch
(
trialJobDetail
.
status
)
{
case
'
SUCCEEDED
'
:
case
'
SUCCEEDED
'
:
...
@@ -461,7 +461,7 @@ class NNIManager implements Manager {
...
@@ -461,7 +461,7 @@ class NNIManager implements Manager {
const
trialJobDetailSnapshot
:
TrialJobDetail
|
undefined
=
this
.
trialJobs
.
get
(
trialJobDetail
.
id
);
const
trialJobDetailSnapshot
:
TrialJobDetail
|
undefined
=
this
.
trialJobs
.
get
(
trialJobDetail
.
id
);
if
(
trialJobDetailSnapshot
!=
undefined
)
{
if
(
trialJobDetailSnapshot
!=
undefined
)
{
await
this
.
dataStore
.
storeTrialJobEvent
(
await
this
.
dataStore
.
storeTrialJobEvent
(
trialJobDetailSnapshot
.
status
,
trialJobDetailSnapshot
.
id
,
hyperParams
,
trialJobDetailSnapshot
.
url
);
trialJobDetailSnapshot
.
status
,
trialJobDetailSnapshot
.
id
,
hyperParams
,
trialJobDetailSnapshot
);
}
else
{
}
else
{
assert
(
false
,
`undefined trialJobDetail in trialJobs:
${
trialJobDetail
.
id
}
`
);
assert
(
false
,
`undefined trialJobDetail in trialJobs:
${
trialJobDetail
.
id
}
`
);
}
}
...
...
src/nni_manager/core/sqlDatabase.ts
View file @
b07309d9
...
@@ -33,11 +33,12 @@ import {
...
@@ -33,11 +33,12 @@ import {
TrialJobEventRecord
TrialJobEventRecord
}
from
'
../common/datastore
'
;
}
from
'
../common/datastore
'
;
import
{
ExperimentProfile
}
from
'
../common/manager
'
;
import
{
ExperimentProfile
}
from
'
../common/manager
'
;
import
{
TrialJobDetail
}
from
'
../common/trainingService
'
;
/* tslint:disable:no-any */
/* tslint:disable:no-any */
const
createTables
:
string
=
`
const
createTables
:
string
=
`
create table TrialJobEvent (timestamp integer, trialJobId text, event text, data text, logPath text);
create table TrialJobEvent (timestamp integer, trialJobId text, event text, data text, logPath text
, sequenceId integer
);
create index TrialJobEvent_trialJobId on TrialJobEvent(trialJobId);
create index TrialJobEvent_trialJobId on TrialJobEvent(trialJobId);
create index TrialJobEvent_event on TrialJobEvent(event);
create index TrialJobEvent_event on TrialJobEvent(event);
...
@@ -51,6 +52,7 @@ create table ExperimentProfile (
...
@@ -51,6 +52,7 @@ create table ExperimentProfile (
execDuration integer,
execDuration integer,
startTime integer,
startTime integer,
endTime integer,
endTime integer,
logDir text,
revision integer);
revision integer);
create index ExperimentProfile_id on ExperimentProfile(id);
create index ExperimentProfile_id on ExperimentProfile(id);
`
;
`
;
...
@@ -62,6 +64,7 @@ function loadExperimentProfile(row: any): ExperimentProfile {
...
@@ -62,6 +64,7 @@ function loadExperimentProfile(row: any): ExperimentProfile {
execDuration
:
row
.
execDuration
,
execDuration
:
row
.
execDuration
,
startTime
:
row
.
startTime
===
null
?
undefined
:
row
.
startTime
,
startTime
:
row
.
startTime
===
null
?
undefined
:
row
.
startTime
,
endTime
:
row
.
endTime
===
null
?
undefined
:
row
.
endTime
,
endTime
:
row
.
endTime
===
null
?
undefined
:
row
.
endTime
,
logDir
:
row
.
logDir
===
null
?
undefined
:
row
.
logDir
,
revision
:
row
.
revision
revision
:
row
.
revision
};
};
}
}
...
@@ -72,7 +75,8 @@ function loadTrialJobEvent(row: any): TrialJobEventRecord {
...
@@ -72,7 +75,8 @@ function loadTrialJobEvent(row: any): TrialJobEventRecord {
trialJobId
:
row
.
trialJobId
,
trialJobId
:
row
.
trialJobId
,
event
:
row
.
event
,
event
:
row
.
event
,
data
:
row
.
data
===
null
?
undefined
:
row
.
data
,
data
:
row
.
data
===
null
?
undefined
:
row
.
data
,
logPath
:
row
.
logPath
===
null
?
undefined
:
row
.
logPath
logPath
:
row
.
logPath
===
null
?
undefined
:
row
.
logPath
,
sequenceId
:
row
.
sequenceId
===
null
?
undefined
:
row
.
sequenceId
};
};
}
}
...
@@ -127,13 +131,14 @@ class SqlDB implements Database {
...
@@ -127,13 +131,14 @@ class SqlDB implements Database {
}
}
public
storeExperimentProfile
(
exp
:
ExperimentProfile
):
Promise
<
void
>
{
public
storeExperimentProfile
(
exp
:
ExperimentProfile
):
Promise
<
void
>
{
const
sql
:
string
=
'
insert into ExperimentProfile values (?,?,?,?,?,?)
'
;
const
sql
:
string
=
'
insert into ExperimentProfile values (?,?,?,?,?,?
,?
)
'
;
const
args
:
any
[]
=
[
const
args
:
any
[]
=
[
JSON
.
stringify
(
exp
.
params
),
JSON
.
stringify
(
exp
.
params
),
exp
.
id
,
exp
.
id
,
exp
.
execDuration
,
exp
.
execDuration
,
exp
.
startTime
===
undefined
?
null
:
exp
.
startTime
,
exp
.
startTime
===
undefined
?
null
:
exp
.
startTime
,
exp
.
endTime
===
undefined
?
null
:
exp
.
endTime
,
exp
.
endTime
===
undefined
?
null
:
exp
.
endTime
,
exp
.
logDir
===
undefined
?
null
:
exp
.
logDir
,
exp
.
revision
exp
.
revision
];
];
...
@@ -168,9 +173,12 @@ class SqlDB implements Database {
...
@@ -168,9 +173,12 @@ class SqlDB implements Database {
return
profiles
[
0
];
return
profiles
[
0
];
}
}
public
storeTrialJobEvent
(
event
:
TrialJobEvent
,
trialJobId
:
string
,
data
?:
string
,
logPath
?:
string
):
Promise
<
void
>
{
public
storeTrialJobEvent
(
const
sql
:
string
=
'
insert into TrialJobEvent values (?,?,?,?,?)
'
;
event
:
TrialJobEvent
,
trialJobId
:
string
,
hyperParameter
?:
string
,
jobDetail
?:
TrialJobDetail
):
Promise
<
void
>
{
const
args
:
any
[]
=
[
Date
.
now
(),
trialJobId
,
event
,
data
,
logPath
];
const
sql
:
string
=
'
insert into TrialJobEvent values (?,?,?,?,?,?)
'
;
const
logPath
:
string
|
undefined
=
jobDetail
===
undefined
?
undefined
:
jobDetail
.
url
;
const
sequenceId
:
number
|
undefined
=
jobDetail
===
undefined
?
undefined
:
jobDetail
.
sequenceId
;
const
args
:
any
[]
=
[
Date
.
now
(),
trialJobId
,
event
,
hyperParameter
,
logPath
,
sequenceId
];
const
deferred
:
Deferred
<
void
>
=
new
Deferred
<
void
>
();
const
deferred
:
Deferred
<
void
>
=
new
Deferred
<
void
>
();
this
.
db
.
run
(
sql
,
args
,
(
err
:
Error
|
null
)
=>
{
this
.
resolve
(
deferred
,
err
);
});
this
.
db
.
run
(
sql
,
args
,
(
err
:
Error
|
null
)
=>
{
this
.
resolve
(
deferred
,
err
);
});
...
...
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