Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add create time to Trial API #410

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
394 changes: 201 additions & 193 deletions pkg/api/api.pb.go

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions pkg/api/api.proto
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,7 @@ message Trial {
repeated Parameter parameter_set = 3; /// Hyperparameter set
string objective_value = 4; /// Objective Value
repeated Tag tags = 5; /// Tags of Trial.
string create_time = 6; /// Trial create timestamp RFC3339 format.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please explain that the create_time will be filled in the server side even user set the value.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

}

/**
Expand Down
3 changes: 3 additions & 0 deletions pkg/api/api.swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -1464,6 +1464,9 @@
"items": {
"$ref": "#/definitions/apiTag"
}
},
"create_time": {
"type": "string"
}
},
"description": "*\nA set of Hyperparameter.\nIn a study, multiple trials are evaluated by workers.\nSuggestion service will generate next trials."
Expand Down
1 change: 1 addition & 0 deletions pkg/api/gen-doc/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -1306,6 +1306,7 @@ Suggestion service will generate next trials.
| parameter_set | [Parameter](#api.Parameter) | repeated | Hyperparameter set |
| objective_value | [string](#string) | | Objective Value |
| tags | [Tag](#api.Tag) | repeated | Tags of Trial. |
| create_time | [string](#string) | | Trial create timestamp RFC3339 format. |



Expand Down
7 changes: 7 additions & 0 deletions pkg/api/gen-doc/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2708,6 +2708,13 @@ <h3 id="api.Trial">Trial</h3>
<td><p>Tags of Trial. </p></td>
</tr>

<tr>
<td>create_time</td>
<td><a href="#string">string</a></td>
<td></td>
<td><p>Trial create timestamp RFC3339 format. </p></td>
</tr>

</tbody>
</table>

Expand Down
311 changes: 159 additions & 152 deletions pkg/api/python/api_pb2.py

Large diffs are not rendered by default.

16 changes: 12 additions & 4 deletions pkg/db/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -378,13 +378,13 @@ func (d *dbConn) getTrials(trialID string, studyID string) ([]*api.Trial, error)
trial := new(api.Trial)

var parameters, tags string
var timeStamp string
var createTimeStr string
err := rows.Scan(&trial.TrialId,
&trial.StudyId,
&parameters,
&trial.ObjectiveValue,
&tags,
&timeStamp,
&createTimeStr,
)
if err != nil {
return nil, err
Expand Down Expand Up @@ -415,6 +415,14 @@ func (d *dbConn) getTrials(trialID string, studyID string) ([]*api.Trial, error)
}
}
trial.Tags = t

createTimeMysql, errParseTimeMysql := time.Parse(mysqlTimeFmt, createTimeStr)
if errParseTimeMysql != nil {
log.Printf("Error parsing Trial create time %s to mysqlFormat: %v", createTimeStr, errParseTimeMysql)
continue
}
trial.CreateTime = createTimeMysql.UTC().Format(time.RFC3339Nano)

result = append(result, trial)
}

Expand Down Expand Up @@ -478,10 +486,10 @@ func (d *dbConn) CreateTrial(trial *api.Trial) error {
i := 3
for true {
trialID = generateRandid()
timeString := time.Now().UTC().Format(mysqlTimeFmt)
createTimeString := time.Now().UTC().Format(mysqlTimeFmt)
_, err := d.db.Exec("INSERT INTO trials VALUES (?, ?, ?, ?, ?, ?)",
trialID, trial.StudyId, strings.Join(params, ",\n"),
trial.ObjectiveValue, strings.Join(tags, ",\n"), timeString)
trial.ObjectiveValue, strings.Join(tags, ",\n"), createTimeString)
if err == nil {
trial.TrialId = trialID
break
Expand Down