Skip to content

Commit

Permalink
delete obsolete data in db (#315)
Browse files Browse the repository at this point in the history
* delete obsolete data in db

* add delete study test

* make sure trials and workers deleted when study deleted in ut test
  • Loading branch information
hougangliu authored and k8s-ci-robot committed Jan 7, 2019
1 parent fae6aa5 commit f78a108
Show file tree
Hide file tree
Showing 15 changed files with 957 additions and 398 deletions.
11 changes: 11 additions & 0 deletions cmd/manager/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,17 @@ func (s *server) CreateStudy(ctx context.Context, in *api_pb.CreateStudyRequest)
return &api_pb.CreateStudyReply{StudyId: studyID}, nil
}

func (s *server) DeleteStudy(ctx context.Context, in *api_pb.DeleteStudyRequest) (*api_pb.DeleteStudyReply, error) {
if in == nil || in.StudyId == "" {
return &api_pb.DeleteStudyReply{}, errors.New("StudyId is missing.")
}
err := dbIf.DeleteStudy(in.StudyId)
if err != nil {
return &api_pb.DeleteStudyReply{}, err
}
return &api_pb.DeleteStudyReply{StudyId: in.StudyId}, nil
}

func (s *server) GetStudy(ctx context.Context, in *api_pb.GetStudyRequest) (*api_pb.GetStudyReply, error) {
sc, err := dbIf.GetStudyConfig(in.StudyId)
return &api_pb.GetStudyReply{StudyConfig: sc}, err
Expand Down
549 changes: 314 additions & 235 deletions pkg/api/api.pb.go

Large diffs are not rendered by default.

60 changes: 60 additions & 0 deletions pkg/api/api.pb.gw.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 22 additions & 0 deletions pkg/api/api.proto
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,14 @@ service Manager {
};
};
/**
* Delete a Study from DB by Study ID.
*/
rpc DeleteStudy(DeleteStudyRequest) returns (DeleteStudyReply){
option (google.api.http) = {
get: "/api/Manager/DeleteStudy/{study_id}"
};
};
/**
* Get all Study Configs from DB.
*/
rpc GetStudyList(GetStudyListRequest) returns (GetStudyListReply){
Expand Down Expand Up @@ -413,6 +421,20 @@ message CreateStudyReply {
}

/**
* Delete a Study from DB by Study ID.
*/
message DeleteStudyRequest {
string study_id = 1;
}

/**
* Return deleted Study ID.
*/
message DeleteStudyReply {
string study_id = 1;
}

/**
* Get a Study Config from DB by ID of Study.
*/
message GetStudyRequest {
Expand Down
36 changes: 35 additions & 1 deletion pkg/api/api.swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,31 @@
]
}
},
"/api/Manager/DeleteStudy/{study_id}": {
"get": {
"summary": "* \nDelete a Study from DB by Study ID.",
"operationId": "DeleteStudy",
"responses": {
"200": {
"description": "",
"schema": {
"$ref": "#/definitions/apiDeleteStudyReply"
}
}
},
"parameters": [
{
"name": "study_id",
"in": "path",
"required": true,
"type": "string"
}
],
"tags": [
"Manager"
]
}
},
"/api/Manager/GetEarlyStoppingParameterList/{study_id}": {
"get": {
"operationId": "GetEarlyStoppingParameterList",
Expand Down Expand Up @@ -211,7 +236,7 @@
},
"/api/Manager/GetStudyList": {
"get": {
"summary": "* \nGet all Study Configs from DB.",
"summary": "*\nGet all Study Configs from DB.",
"operationId": "GetStudyList",
"responses": {
"200": {
Expand Down Expand Up @@ -689,6 +714,15 @@
}
}
},
"apiDeleteStudyReply": {
"type": "object",
"properties": {
"study_id": {
"type": "string"
}
},
"description": "*\nReturn deleted Study ID."
},
"apiEarlyStoppingParameter": {
"type": "object",
"properties": {
Expand Down
33 changes: 33 additions & 0 deletions pkg/api/gen-doc/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
- [CreateTrialReply](#api.CreateTrialReply)
- [CreateTrialRequest](#api.CreateTrialRequest)
- [DataSetInfo](#api.DataSetInfo)
- [DeleteStudyReply](#api.DeleteStudyReply)
- [DeleteStudyRequest](#api.DeleteStudyRequest)
- [EarlyStoppingParameter](#api.EarlyStoppingParameter)
- [EarlyStoppingParameterSet](#api.EarlyStoppingParameterSet)
- [FeasibleSpace](#api.FeasibleSpace)
Expand Down Expand Up @@ -178,6 +180,36 @@ Generate an unique ID and store the Trial to DB.



<a name="api.DeleteStudyReply"/>

### DeleteStudyReply
Return deleted Study ID.


| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| study_id | [string](#string) | | |






<a name="api.DeleteStudyRequest"/>

### DeleteStudyRequest
Delete a Study from DB by Study ID.


| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| study_id | [string](#string) | | |






<a name="api.EarlyStoppingParameter"/>

### EarlyStoppingParameter
Expand Down Expand Up @@ -1330,6 +1362,7 @@ https://cloud.google.com/service-infrastructure/docs/service-management/referenc
| ----------- | ------------ | ------------- | ------------|
| CreateStudy | [CreateStudyRequest](#api.CreateStudyRequest) | [CreateStudyReply](#api.CreateStudyRequest) | Create a Study from Study Config. Generate a unique ID and store the Study to DB. |
| GetStudy | [GetStudyRequest](#api.GetStudyRequest) | [GetStudyReply](#api.GetStudyRequest) | Get a Study Config from DB by ID of Study. |
| DeleteStudy | [DeleteStudyRequest](#api.DeleteStudyRequest) | [DeleteStudyReply](#api.DeleteStudyRequest) | Delete a Study from DB by Study ID. |
| GetStudyList | [GetStudyListRequest](#api.GetStudyListRequest) | [GetStudyListReply](#api.GetStudyListRequest) | Get all Study Configs from DB. |
| CreateTrial | [CreateTrialRequest](#api.CreateTrialRequest) | [CreateTrialReply](#api.CreateTrialRequest) | Create a Trial from Trial Config. Generate a unique ID and store the Trial to DB. |
| GetTrials | [GetTrialsRequest](#api.GetTrialsRequest) | [GetTrialsReply](#api.GetTrialsRequest) | Get a Trial Configs from DB by ID of Study. |
Expand Down
61 changes: 61 additions & 0 deletions pkg/api/gen-doc/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,14 @@ <h2>Table of Contents</h2>
<a href="#api.DataSetInfo"><span class="badge">M</span>DataSetInfo</a>
</li>

<li>
<a href="#api.DeleteStudyReply"><span class="badge">M</span>DeleteStudyReply</a>
</li>

<li>
<a href="#api.DeleteStudyRequest"><span class="badge">M</span>DeleteStudyRequest</a>
</li>

<li>
<a href="#api.EarlyStoppingParameter"><span class="badge">M</span>EarlyStoppingParameter</a>
</li>
Expand Down Expand Up @@ -638,6 +646,52 @@ <h3 id="api.DataSetInfo">DataSetInfo</h3>



<h3 id="api.DeleteStudyReply">DeleteStudyReply</h3>
<p>Return deleted Study ID.</p>


<table class="field-table">
<thead>
<tr><td>Field</td><td>Type</td><td>Label</td><td>Description</td></tr>
</thead>
<tbody>

<tr>
<td>study_id</td>
<td><a href="#string">string</a></td>
<td></td>
<td><p> </p></td>
</tr>

</tbody>
</table>




<h3 id="api.DeleteStudyRequest">DeleteStudyRequest</h3>
<p>Delete a Study from DB by Study ID.</p>


<table class="field-table">
<thead>
<tr><td>Field</td><td>Type</td><td>Label</td><td>Description</td></tr>
</thead>
<tbody>

<tr>
<td>study_id</td>
<td><a href="#string">string</a></td>
<td></td>
<td><p> </p></td>
</tr>

</tbody>
</table>




<h3 id="api.EarlyStoppingParameter">EarlyStoppingParameter</h3>
<p>Parameter for EarlyStopping service. Key-value format.</p>

Expand Down Expand Up @@ -2773,6 +2827,13 @@ <h3 id="api.Manager">Manager</h3>
<td><p>Get a Study Config from DB by ID of Study.</p></td>
</tr>

<tr>
<td>DeleteStudy</td>
<td><a href="#api.DeleteStudyRequest">DeleteStudyRequest</a></td>
<td><a href="#api.DeleteStudyReply">DeleteStudyReply</a></td>
<td><p>Delete a Study from DB by Study ID.</p></td>
</tr>

<tr>
<td>GetStudyList</td>
<td><a href="#api.GetStudyListRequest">GetStudyListRequest</a></td>
Expand Down
Loading

0 comments on commit f78a108

Please sign in to comment.