-
Notifications
You must be signed in to change notification settings - Fork 6
feat: evaluation context mappers #87
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
base: main
Are you sure you want to change the base?
Conversation
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 good, with a handful of comments.
| module EvaluationContext | ||
| module Mappers | ||
| # Using integer constant instead of -Float::INFINITY because the JSON serializer rejects infinity values | ||
| HIGHEST_PRIORITY = 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.
Just for safety, I'd prefer this to be lower than 0. Also, our naming convention for these constants is strongest-weakest:
| HIGHEST_PRIORITY = 0 | |
| STRONGEST_PRIORITY = -99_999_999 |
| end | ||
|
|
||
| # Create hash of the overrides to group identities with same overrides | ||
| overrides_hash = Digest::SHA1.hexdigest(overrides_key.to_json) |
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.
Consider one of the following alternatives.
- Using
inspectinstead ofto_jsonmight be more performant, and doesn't require us to avoidInf:
| overrides_hash = Digest::SHA1.hexdigest(overrides_key.to_json) | |
| overrides_hash = Digest::SHA1.hexdigest(overrides_key.inspect) |
- I'm not too familiar with Ruby's
Object::hash, but it could be sufficient in our case. We could drop thedigestdependency that way:
| overrides_hash = Digest::SHA1.hexdigest(overrides_key.to_json) | |
| overrides_hash = overrides_key.hash |
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 actually reverting this change to inspect as I discovered that the hash is not consistent over application restarts
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.
We're not persisting this hash anywhere, so I don't think it's a requirement for it to be consistent across runtimes? Am I missing something?
Co-authored-by: Kim Gustyr <[email protected]>
Thanks for submitting a PR! Please check the boxes below:
docs/if required so people know about the feature!Changes
Contributes to #81
This is pass 1 of 4.
map_environment_model_to_evaluation_context,map_identity_overrides_to_segments,map_segment_rule_to_model,map_identity_model_to_identity_context)How did you test this code?