Skip to content

Commit

Permalink
feat: Bump flagsmith-flag-engine to 5.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
khvn26 committed Nov 22, 2023
1 parent 7721dc7 commit dcc283f
Show file tree
Hide file tree
Showing 5 changed files with 264 additions and 155 deletions.
3 changes: 1 addition & 2 deletions flagsmith/flagsmith.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

import requests
from flag_engine import engine
from flag_engine.environments.builders import build_environment_model
from flag_engine.environments.models import EnvironmentModel
from flag_engine.identities.models import IdentityModel, TraitModel
from flag_engine.segments.evaluator import get_identity_segments
Expand Down Expand Up @@ -196,7 +195,7 @@ def update_environment(self):

def _get_environment_from_api(self) -> EnvironmentModel:
environment_data = self._get_json_response(self.environment_url, method="GET")
return build_environment_model(environment_data)
return EnvironmentModel.model_validate(environment_data)

def _get_environment_flags_from_document(self) -> Flags:
return Flags.from_feature_state_models(
Expand Down
6 changes: 2 additions & 4 deletions flagsmith/offline_handlers.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import json
from abc import ABC, abstractmethod

from flag_engine.environments.builders import build_environment_model
from flag_engine.environments.models import EnvironmentModel


Expand All @@ -14,8 +12,8 @@ def get_environment(self) -> EnvironmentModel:
class LocalFileHandler(BaseOfflineHandler):
def __init__(self, environment_document_path: str):
with open(environment_document_path) as environment_document:
self.environment = build_environment_model(
json.loads(environment_document.read())
self.environment = EnvironmentModel.model_validate_json(
environment_document.read()
)

def get_environment(self) -> EnvironmentModel:
Expand Down
Loading

0 comments on commit dcc283f

Please sign in to comment.