-
Notifications
You must be signed in to change notification settings - Fork 8
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 additional experiment metadata to Fetch Treatment response #36
Add additional experiment metadata to Fetch Treatment response #36
Conversation
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Renaming the interface for consistency and moving both to nested packages.
@@ -0,0 +1,9 @@ | |||
ALTER TABLE experiments ADD version integer NOT NULL DEFAULT 1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The default value automatically takes care of those experiments that have no history.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall LGTM, left some small comments. Thanks @krithika369 ! 🚀
@@ -21,6 +21,23 @@ components: | |||
configuration: | |||
type: object | |||
description: Custom configuration associated with the given treatment | |||
SelectedTreatmentMetadata: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since the parent schema is already prefixed with SelectedTreatment
, should we keep this concise with Metadata
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That might not be advisable, since the schema definitions are shared. The field inside SelectedTreatment
is just called metadata
though.
SELECT t1.id AS id, count(*) AS num_history | ||
FROM experiments t1 INNER JOIN experiment_history t2 ON t1.id = t2.experiment_id | ||
GROUP BY t1.id | ||
) UPDATE experiments SET version = num_history+1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: I think it's neater to start UPDATE
on a newline.
@@ -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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Since we expect versions to start from 1, shall we use 1 instead for these tests?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I intentionally left that field (and previously other properties too) empty - they don't play a role in the test cases. So they are empty values by default.
}, | ||
"metadata": { | ||
"experiment_version": 1, | ||
"experiment_type": "a/b" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the expected value should be "A/B"
right? https://github.com/caraml-dev/xp/blob/main/api/schema.yaml#L368
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's only a mocked test, but I updated it to match the treatment service response anyway. Thanks!
@@ -105,18 +119,19 @@ const ExperimentDetailsView = ({ projectId, experimentId, ...props }) => { | |||
</ExperimentActions> | |||
</EuiPageTemplate.Header> | |||
</Fragment> | |||
)} | |||
) | |||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Formatting looks funny here 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Something was broken with my local hooks, fixed it now.
|
||
<Router primary={false}> | ||
<Redirect from="/" to="details" noThrow /> | ||
<ExperimentConfigView path="details" experiment={data.data} /> | ||
<ListExperimentHistoryView path="history" experiment={data.data} /> | ||
<EditExperimentView path="edit" experimentSpec={data.data} /> | ||
</Router> | ||
</Fragment> | ||
</Fragment > |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Weird spaces at the back here.
Thanks for the review @terryyylim! Will merge this once the CI passes. |
What this PR does / why we need it:
This PR adds additional metadata information to the Fetch Treatment response.
The version field is now added to the database model for experiments, to reliably store the version of the experiment. Consequently, this field is also added to the Experiment Details view.
Summary of Changes
The main changes are summarised below.
Schema
api/proto/experiment.proto
- Add experiment version info in the Pubsub messageapi/schema.yaml
- Add experiment version info in theExperiment
structure,SelectedTreatmentMetadata
into the treatment response structureManagement Service
management-service/database/db-migrations/000003_experiment_version.*.sql
- Migrations for theversion
column in theexperiments table
. Theexperiment_history
table already has this field.management-service/models/experiment.go
- Include the version info when converting the DB model to other formatsmanagement-service/services/experiment_history_service.go
- When creating the history record, we can now just copy the version from the current experiment record.Treatment Service
treatment-service/controller/treatment.go
- Return additional experiment metadata in the final response when an experiment is matchedtreatment-service/services/treatment_service.go
- Return the switchback window Id (where applicable) from theGetTreatment
methodtreatment-service/models/typeconverter.go
- Cater to the newly added version field in the experiment dataUI
ui/src/components/version_badge/VersionBadge.js
- Add new component for use in experiment / experiment history details viewui/src/experiments/details/ExperimentDetailsView.js
,ui/src/experiments/history/details/ExperimentHistoryDetailsView.js
- Include version info as a badgeMiscellaneous Bugfix
A recent PR (#33) refactored the segmenter card layout in the Edit Project Settings form. This caused a small regression - when a segmenter has multiple options for variable mappings, it should be expanded by default, in the Selected Segmenters column. If not, when a new card is dragged to the Selected Segmenters column, there is no visual feedback to the users that some info must be filled (the form submit will be blocked by the yup validation but we can't see where the error is either). This is addressed by adding back the
initialIsOpen
prop inui/src/settings/components/form/components/segmenter_section/SegmenterCard.js
.