-
Notifications
You must be signed in to change notification settings - Fork 6
feat: Context values for Segments #220
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
Conversation
|
Minimum allowed coverage is Generated by 🐒 cobertura-action against 58e833a |
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.
Changes look great. Minor questions.
| [submodule "tests/engine_tests/engine-test-data"] | ||
| path = tests/engine_tests/engine-test-data | ||
| url = https://github.com/flagsmith/engine-test-data.git | ||
| branch = feat/context-values |
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.
Reminder to delete.
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.
A discussion point as well as merging Flagsmith/engine-test-data#8 will break CI for all local eval SDKs. It's a good incentive for closing Flagsmith/flagsmith#5676 ASAP, of course, but perhaps we should consider versioning engine-test-data.
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.
Do you mean hard versions? e.g. v1/ and v2/, etc? I support temporary branch pointing at main — given a reasonable plan — unless there's value in the former.
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 meant using version tags in engine-test-data and referencing them instead of main branch in submodules.
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.
Interesting. Yes, I think it makes sense to version the test data.
I guess the original thinking behind not versioning it, is that the test data was to be used for more of a regression test, but I don't think that makes sense here, so I'm happy to go with a versioned approach.
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.
Created https://github.com/Flagsmith/engine-test-data/releases/tag/v1.0.0 for the current SDKs to point to 👍
| context_value: TraitValue, | ||
| ) -> bool: | ||
| return isinstance(trait_value, str) and str(segment_value) not in trait_value | ||
| return isinstance(context_value, str) and str(segment_value) not in context_value |
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.
Unrelated with this PR but I wonder if we should really "None" not in context_value if segment_value is null.
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.
Nice catch, let's come up with a test case for this (outside of this PR)?
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'm writing an issue but is there any use case where segment_value is None other than PERCENTAGE_SPLIT? Do you see how to reproduce this with a real scenario? I think potentially this has never been a problem.
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.
Yeah, I don't think we can have an IN segment with a null value, realistically.
ea3f342 to
93c2310
Compare
93c2310 to
42829fa
Compare
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.
Looks neat overall, added a couple of comments, and keen to see the resolutions on the outstanding comments from @emyller .
| [submodule "tests/engine_tests/engine-test-data"] | ||
| path = tests/engine_tests/engine-test-data | ||
| url = https://github.com/flagsmith/engine-test-data.git | ||
| branch = feat/context-values |
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.
Interesting. Yes, I think it makes sense to version the test data.
I guess the original thinking behind not versioning it, is that the test data was to be used for more of a regression test, but I don't think that makes sense here, so I'm happy to go with a versioned approach.
| ) | ||
| for rule in segment.rules | ||
| return bool(rules := segment.rules) and all( | ||
| context_matches_rule(context=context, rule=rule, segment_key=segment.id) |
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.
This part is particularly interesting (cc @gagantrivedi). This is something that I was chatting to Gagan about regarding the release pipelines work - the reason being is that we can't currently implement a phased rollout using the functionality available in release pipelines since we'd need to use separate segments for each percentage increment. If we allow users to link segments using some kind of other key, then we'd be able to achieve this.
All this is to say, I like the abstraction of segment_key - I don't think there's any changes necessary here right now, I'm just calling it out for Gagan's attention more than anything.
I also don't know if using multiple segments is the right approach for phased rollouts anyway!
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.
Agora vai
Closes #219.