-
Notifications
You must be signed in to change notification settings - Fork 429
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
feat: Add a task for writing (edge) identity overrides #3127
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
ea1f9f9
Add new files and update existing files
khvn26 9f5c3f6
fix typeddict on 3.10
khvn26 9c9925a
tidier keys
khvn26 dd19af8
add dynamo wrapper tests, naming improvements
khvn26 7e05c2f
remove unused field
khvn26 48f9289
add task tests
khvn26 5a7a551
accommodate for string environment_id column
khvn26 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
from typing import Any, Literal, TypedDict | ||
|
||
from typing_extensions import NotRequired | ||
|
||
ChangeType = Literal["+", "-", "~"] | ||
|
||
|
||
class FeatureStateChangeDetails(TypedDict): | ||
change_type: ChangeType | ||
old: NotRequired[dict[str, Any]] | ||
new: NotRequired[dict[str, Any]] | ||
|
||
|
||
class IdentityChangeset(TypedDict): | ||
feature_overrides: dict[str, FeatureStateChangeDetails] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import typing | ||
|
||
from flag_engine.features.models import FeatureStateModel | ||
|
||
if typing.TYPE_CHECKING: | ||
from edge_api.identities.types import ChangeType, FeatureStateChangeDetails | ||
|
||
|
||
def generate_change_dict( | ||
change_type: "ChangeType", | ||
identity_id: int | str | None, | ||
new: FeatureStateModel | None = None, | ||
old: FeatureStateModel | None = None, | ||
) -> "FeatureStateChangeDetails": | ||
if not (new or old): | ||
raise ValueError("Must provide one of 'new' or 'old'") | ||
|
||
change_dict = {"change_type": change_type} | ||
if new: | ||
change_dict["new"] = _get_overridden_feature_state_dict( | ||
identity_id=identity_id, | ||
feature_state=new, | ||
) | ||
if old: | ||
change_dict["old"] = _get_overridden_feature_state_dict( | ||
identity_id=identity_id, | ||
feature_state=old, | ||
) | ||
|
||
return change_dict | ||
|
||
|
||
def _get_overridden_feature_state_dict( | ||
identity_id: int | str | None, | ||
feature_state: FeatureStateModel, | ||
) -> dict[str, typing.Any]: | ||
return { | ||
**feature_state.dict(), | ||
"feature_state_value": feature_state.get_value(identity_id), | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
ENVIRONMENTS_V2_PARTITION_KEY = "environment_id" | ||
ENVIRONMENTS_V2_SORT_KEY = "document_key" | ||
|
||
ENVIRONMENTS_V2_SECONDARY_INDEX = "environment_api_key-index" | ||
ENVIRONMENTS_V2_SECONDARY_INDEX_PARTITION_KEY = "environment_api_key" |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 making a note here as well that this is different to the previous behaviour - this used to be
"value"
I think?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.
From what I can tell, this data is used in the
generate_audit_log_records
task (as well as the new task you created) but the value is not actually used so I think this is fine.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.
Yes,
"value"
was not used. I made sure to modify thegenerate_audit_log_records
tests accordingly.