Skip to content
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(environment): Add toggle for identity override in local eval #4576

Merged
merged 4 commits into from
Sep 4, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Generated by Django 4.2.15 on 2024-09-04 05:40

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
("environments", "0034_alter_environment_project"),
]

operations = [
migrations.AddField(
model_name="environment",
name="use_identity_overrides_in_local_eval",
field=models.BooleanField(
default=False,
help_text="When enabled, identity overrides will be included in the environment document",
),
),
migrations.AddField(
model_name="historicalenvironment",
name="use_identity_overrides_in_local_eval",
field=models.BooleanField(
default=False,
help_text="When enabled, identity overrides will be included in the environment document",
),
),
# Update the default to true for new environments
migrations.AlterField(
model_name="environment",
name="use_identity_overrides_in_local_eval",
field=models.BooleanField(
default=True,
help_text="When enabled, identity overrides will be included in the environment document",
),
),
migrations.AlterField(
model_name="historicalenvironment",
name="use_identity_overrides_in_local_eval",
field=models.BooleanField(
default=True,
help_text="When enabled, identity overrides will be included in the environment document",
),
),
]
7 changes: 5 additions & 2 deletions api/environments/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,12 @@ class Environment(
help_text="If true, will hide sensitive data(e.g: traits, description etc) from the SDK endpoints",
)

objects = EnvironmentManager()

use_v2_feature_versioning = models.BooleanField(default=False)
use_identity_overrides_in_local_eval = models.BooleanField(
default=True,
help_text="When enabled, identity overrides will be included in the environment document",
)
objects = EnvironmentManager()

class Meta:
ordering = ["id"]
Expand Down
1 change: 1 addition & 0 deletions api/environments/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ class Meta:
"use_identity_composite_key_for_hashing",
"hide_sensitive_data",
"use_v2_feature_versioning",
"use_identity_overrides_in_local_eval",
)
read_only_fields = ("use_v2_feature_versioning",)

Expand Down
7 changes: 7 additions & 0 deletions api/tests/unit/environments/test_unit_environments_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,7 @@ def test_should_create_environments(
assert response.status_code == status.HTTP_201_CREATED
assert response.json()["description"] == description
assert response.json()["use_mv_v2_evaluation"] is True
assert response.json()["use_identity_overrides_in_local_eval"] is True
assert response.json()["use_identity_composite_key_for_hashing"] is True

# and user is admin
Expand Down Expand Up @@ -787,6 +788,7 @@ def test_audit_log_entry_created_when_environment_updated(
banner_colour = "#FF0000"
hide_disabled_flags = True
use_identity_composite_key_for_hashing = True
use_identity_override_in_local_eval = True
hide_sensitive_data = True

data = {
Expand All @@ -796,6 +798,7 @@ def test_audit_log_entry_created_when_environment_updated(
"banner_colour": banner_colour,
"hide_disabled_flags": hide_disabled_flags,
"use_identity_composite_key_for_hashing": use_identity_composite_key_for_hashing,
"use_identity_overrides_in_local_eval": use_identity_override_in_local_eval,
"hide_sensitive_data": hide_sensitive_data,
}

Expand All @@ -816,6 +819,10 @@ def test_audit_log_entry_created_when_environment_updated(
assert response.json()["banner_colour"] == banner_colour
assert response.json()["hide_disabled_flags"] == hide_disabled_flags
assert response.json()["hide_sensitive_data"] == hide_sensitive_data
assert (
response.json()["use_identity_overrides_in_local_eval"]
== use_identity_override_in_local_eval
)
assert (
response.json()["use_identity_composite_key_for_hashing"]
== use_identity_composite_key_for_hashing
Expand Down
1 change: 1 addition & 0 deletions api/tests/unit/util/mappers/test_unit_mappers_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,7 @@ def test_map_environment_to_engine__return_expected(
allow_client_traits=environment.allow_client_traits,
updated_at=environment.updated_at,
use_identity_composite_key_for_hashing=environment.use_identity_composite_key_for_hashing,
use_identity_overrides_in_local_eval=environment.use_identity_overrides_in_local_eval,
hide_sensitive_data=environment.hide_sensitive_data,
hide_disabled_flags=environment.hide_disabled_flags,
amplitude_config=None,
Expand Down
1 change: 1 addition & 0 deletions api/util/mappers/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,7 @@ def map_environment_to_engine(
use_identity_composite_key_for_hashing=environment.use_identity_composite_key_for_hashing,
hide_sensitive_data=environment.hide_sensitive_data,
hide_disabled_flags=environment.hide_disabled_flags,
use_identity_overrides_in_local_eval=environment.use_identity_overrides_in_local_eval,
#
# Relationships:
project=project_model,
Expand Down
Loading