Skip to content

Commit

Permalink
Add additional experiment metadata to Fetch Treatment response (#36)
Browse files Browse the repository at this point in the history
* Add switchback_window_id and experiment_version to the fetch treatment response schema

* Add version field to experiments table

* Treatment service changes for switchback window id and experiment version

* Fix plugin test case

* Fix file formatting

* Address PR comments

* Address PR comments - UI formatting

Co-authored-by: Krithika Sundararajan <[email protected]>
  • Loading branch information
krithika369 and Krithika Sundararajan authored Sep 20, 2022
1 parent fac3bc6 commit 5483d6b
Show file tree
Hide file tree
Showing 32 changed files with 383 additions and 127 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ generate-api:
oapi-codegen -templates api/templates/chi -config api/management/server.conf api/experiments.yaml
oapi-codegen -config api/mockmanagement/server.conf api/experiments.yaml
oapi-codegen -config api/treatment/server.conf api/treatment.yaml
cd clients/management/ && mockery --name=ClientInterface --output=../../clients/testutils/mocks --filename=ManagementClientInterface.go
cd clients/treatment/ && mockery --name=TreatmentClientInterface --output=../../clients/testutils/mocks --filename=TreatmentClientInterface.go
cd clients/management/ && mockery --name=ClientInterface --output=../../clients/testutils/mocks/management --filename=ManagementClientInterface.go
cd clients/treatment/ && mockery --name=ClientInterface --output=../../clients/testutils/mocks/treatment --filename=TreatmentClientInterface.go

# ==================================
# Setup Management & Treatment Services
Expand Down
1 change: 1 addition & 0 deletions api/proto/experiment.proto
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ message Experiment {
repeated ExperimentTreatment treatments = 11;

google.protobuf.Timestamp updated_at = 12;
int64 version = 13; // Experiment version
}

message ExperimentTreatment {
Expand Down
24 changes: 24 additions & 0 deletions api/schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,23 @@ components:
configuration:
type: object
description: Custom configuration associated with the given treatment
SelectedTreatmentMetadata:
required:
- experiment_version
- experiment_type
type: object
properties:
experiment_version:
type: integer
format: int64
experiment_type:
$ref: '#/components/schemas/ExperimentType'
switchback_window_id:
type: integer
format: int64
description: |
The window id since the beginning of the current version of the Switchback experiment.
This field will only be set for Switchback experiments and the window id starts at 0.
ExperimentTreatment:
required:
- configuration
Expand Down Expand Up @@ -116,6 +133,7 @@ components:
- experiment_id
- experiment_name
- treatment
- metadata
type: object
properties:
experiment_id:
Expand All @@ -125,6 +143,8 @@ components:
type: string
treatment:
$ref: '#/components/schemas/SelectedTreatmentData'
metadata:
$ref: '#/components/schemas/SelectedTreatmentMetadata'
Experiment:
required:
- project_id
Expand All @@ -142,6 +162,7 @@ components:
- created_at
- updated_at
- updated_by
- version
type: object
properties:
description:
Expand Down Expand Up @@ -185,6 +206,9 @@ components:
nullable: true
tier:
$ref: '#/components/schemas/ExperimentTier'
version:
type: integer
format: int64
ExperimentHistory:
required:
- experiment_id
Expand Down

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

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

75 changes: 45 additions & 30 deletions common/api/schema/schema.go

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

55 changes: 32 additions & 23 deletions common/pubsub/experiment.pb.go

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

9 changes: 6 additions & 3 deletions management-service/controller/experiment_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ func (s *ExperimentControllerTestSuite) SetupSuite() {
"type": "",
"start_time": "0001-01-01T00:00:00Z",
"updated_at": "0001-01-01T00:00:00Z",
"updated_by": ""
"updated_by": "",
"version": 0
}`,
`{
"project_id": 2,
Expand All @@ -98,7 +99,8 @@ func (s *ExperimentControllerTestSuite) SetupSuite() {
"type": "",
"start_time": "0001-01-01T00:00:00Z",
"updated_at": "0001-01-01T00:00:00Z",
"updated_by": ""
"updated_by": "",
"version": 0
}`,
`{
"project_id": 5,
Expand All @@ -115,7 +117,8 @@ func (s *ExperimentControllerTestSuite) SetupSuite() {
"type": "",
"start_time": "0001-01-01T00:00:00Z",
"updated_at": "0001-01-01T00:00:00Z",
"updated_by": ""
"updated_by": "",
"version": 0
}`,
}
s.expectedErrorResponseFormat = `{"code":"%[1]v", "error":%[2]v, "message":%[2]v}`
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TABLE experiments DROP COLUMN version;
Loading

0 comments on commit 5483d6b

Please sign in to comment.