Skip to content

Commit b0e7447

Browse files
authored
Jonatan/mon 2641 remove launchdarkly (#382)
1 parent 2e543cf commit b0e7447

File tree

21 files changed

+50
-247
lines changed

21 files changed

+50
-247
lines changed

.github/workflows/e2e-tests.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,6 @@ jobs:
186186
docker image ls -a
187187
# - name: Run e2e tests // TODO: Uncomment when we fix e2e tests
188188
# env:
189-
# LAUCHDARKLY_SDK_KEY: ${{ secrets.LAUCHDARKLY_SDK_KEY }}
190189
# OAUTH_CLIENT_ID: ${{ secrets.OAUTH_CLIENT_ID }}
191190
# OAUTH_CLIENT_SECRET: ${{ secrets.OAUTH_CLIENT_SECRET }}
192191
# run: make cypress
@@ -242,9 +241,9 @@ jobs:
242241
DEEPCHECKS_CI_TOKEN: ${{ secrets.DEEPCHECKS_CI_TOKEN }}
243242
DEEPCHECKS_API_TOKEN: ${{ env.DEEPCHECKS_API_TOKEN }}
244243
DEEPCHECKS_API_HOST: ${{ env.DEEPCHECKS_API_HOST }}
245-
LAUCHDARKLY_SDK_KEY: ${{ secrets.LAUCHDARKLY_SDK_KEY }}
246244
OAUTH_CLIENT_ID: ${{ secrets.OAUTH_CLIENT_ID }}
247245
OAUTH_CLIENT_SECRET: ${{ secrets.OAUTH_CLIENT_SECRET }}
246+
IS_ON_PREM: 'True'
248247
run: |
249248
make env-setup
250249
make docs

backend/deepchecks_monitoring/api/v1/global_api/users.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,9 @@ async def update_complete_details(
9696
resources_provider=ResourcesProviderDep
9797
):
9898
"""Complete user details for final login."""
99+
100+
resources_provider: "ResourcesProvider"
101+
99102
if body.new_organization_name is not None and body.accept_invite is True:
100103
raise BadRequest("Can't accept invitation and create new organization")
101104

backend/deepchecks_monitoring/api/v1/model.py

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -177,18 +177,17 @@ async def get_create_model(
177177
else:
178178
model_count = await session.scalar(sa.func.count(Model.id))
179179
if model_count > 0:
180-
if features_control.max_models != -1:
181-
allowed_models = await features_control.get_allowed_models(session)
182-
if allowed_models == 1:
183-
raise PaymentRequired("Adding more than 1 model requires to set up a subscription. "
184-
f"Set up through {resources_provider.settings.deployment_url}"
185-
f"/workspace-settings")
186-
if allowed_models < model_count:
187-
raise PaymentRequired(f"Subscription currently configured for {allowed_models} models. "
188-
f"Current model amount is {model_count}. "
189-
"please update your subscription if you wish to add more models. "
190-
f"Update through {resources_provider.settings.deployment_url}"
191-
f"/workspace-settings")
180+
allowed_models = await features_control.get_allowed_models(session)
181+
if allowed_models == 1:
182+
raise PaymentRequired("Adding more than 1 model requires to set up a subscription. "
183+
f"Set up through {resources_provider.settings.deployment_url}"
184+
f"/workspace-settings")
185+
if allowed_models is not None and allowed_models < model_count:
186+
raise PaymentRequired(f"Subscription currently configured for {allowed_models} models. "
187+
f"Current model amount is {model_count}. "
188+
"please update your subscription if you wish to add more models. "
189+
f"Update through {resources_provider.settings.deployment_url}"
190+
f"/workspace-settings")
192191
data = model_schema.dict(exclude_none=True)
193192
notes = [ModelNote(created_by=user.id, updated_by=user.id, **it) for it in data.pop("notes", [])]
194193
model = Model(notes=notes, created_by=user.id, updated_by=user.id, **data)

backend/deepchecks_monitoring/config.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ class Settings(
157157
oauth_client_secret: str
158158
mixpanel_id: str | None
159159
enable_analytics: bool = True
160+
parallel_check_executor_flag: bool = True
160161

161162
init_local_ray_instance: str | None = None
162163
total_number_of_check_executor_actors: int = os.cpu_count() or 8

backend/deepchecks_monitoring/ee/config.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ class Settings(
4949

5050
enviroment: str = 'dev'
5151
debug_mode: bool = False
52-
lauchdarkly_sdk_key: str = ''
5352
access_audit: bool = False
5453
hotjar_sv: str = ''
5554
hotjar_id: str = ''
Lines changed: 6 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,16 @@
1-
from ldclient import Context
2-
from ldclient.client import LDClient
3-
from pydantic import BaseModel
41
from sqlalchemy import select
52

63
from deepchecks_monitoring.features_control import FeaturesControl
74
from deepchecks_monitoring.public_models import Billing, User
85

96

10-
class TierConfSchema(BaseModel):
11-
"""Tier configuration which is loaded from launchdarkly."""
12-
13-
custom_checks: bool = False
14-
data_retention_months: int = 3
15-
max_models: int = 1
16-
monthly_predictions_limit: int = 500_000
17-
sso: bool = False
18-
rows_per_minute: int = 500_000
19-
update_roles: bool = False
20-
model_assignment: bool = False
21-
22-
237
class CloudFeaturesControl(FeaturesControl):
248
"""Feature controls class for the cloud version."""
259

26-
def __init__(self, user: User, ld_client: LDClient, settings):
10+
def __init__(self, user: User, settings):
2711
super().__init__(settings)
2812
self.user = user
29-
self.ld_client = ld_client
30-
self._max_models = None
3113
self._allowed_models = None
32-
self._rows_per_minute = None
33-
self._custom_checks_enabled = None
34-
self._data_retention_months = None
35-
self._monthly_predictions_limit = None
36-
self._sso_enabled = None
37-
self._signup_enabled = None
38-
self._onboarding_enabled = None
39-
self._update_roles = None
40-
self._model_assignment = None
41-
42-
@property
43-
def max_models(self) -> int:
44-
if self._max_models is None:
45-
self._load_tier()
46-
return self._max_models
4714

4815
async def get_allowed_models(self, session) -> int:
4916
if self._allowed_models is None:
@@ -57,85 +24,28 @@ async def get_allowed_models(self, session) -> int:
5724

5825
@property
5926
def update_roles(self) -> bool:
60-
if self._update_roles is None:
61-
self._load_tier()
62-
return self._update_roles
27+
return True
6328

6429
@property
6530
def model_assignment(self) -> bool:
66-
if self._model_assignment is None:
67-
self._load_tier()
68-
return self._model_assignment
31+
return True
6932

7033
@property
7134
def signup_enabled(self) -> bool:
72-
if self._signup_enabled is None:
73-
self._load_tier()
74-
return self._signup_enabled
35+
return True
7536

7637
@property
7738
def onboarding_enabled(self) -> bool:
78-
if self._onboarding_enabled is None:
79-
self._load_tier()
80-
return self._onboarding_enabled
39+
return True
8140

8241
@property
8342
def slack_enabled(self) -> bool:
8443
return True
8544

8645
@property
8746
def rows_per_minute(self) -> int:
88-
if self._rows_per_minute is None:
89-
self._load_tier()
90-
return self._rows_per_minute
91-
92-
@property
93-
def custom_checks_enabled(self) -> bool:
94-
if self._custom_checks_enabled is None:
95-
self._load_tier()
96-
return self._custom_checks_enabled
97-
98-
@property
99-
def data_retention_months(self) -> int:
100-
if self._data_retention_months is None:
101-
self._load_tier()
102-
return self._data_retention_months
103-
104-
@property
105-
def monthly_predictions_limit(self) -> int:
106-
if self._monthly_predictions_limit is None:
107-
self._load_tier()
108-
return self._monthly_predictions_limit
109-
110-
@property
111-
def sso_enabled(self) -> bool:
112-
if self._sso_enabled is None:
113-
self._load_tier()
114-
return self._sso_enabled
47+
return 500_000
11548

11649
@property
11750
def multi_tenant(self) -> bool:
11851
return True
119-
120-
def _load_tier(self):
121-
context = Context.builder(self.user.email).set("email", self.user.email)
122-
if self.user.organization:
123-
context.set("organization_id", self.user.organization.id)
124-
context.set("tier", self.user.organization.tier)
125-
126-
ld_user = context.build()
127-
tier_conf = self.ld_client.variation("paid-features", ld_user, default={})
128-
if getattr(self.user, "email_verified", False):
129-
self._signup_enabled = self.ld_client.variation("signUpEnabled", ld_user, default=True)
130-
else:
131-
self._signup_enabled = False
132-
tier_conf = TierConfSchema(**tier_conf)
133-
self._custom_checks_enabled = tier_conf.custom_checks
134-
self._data_retention_months = tier_conf.data_retention_months
135-
self._max_models = tier_conf.max_models
136-
self._monthly_predictions_limit = tier_conf.monthly_predictions_limit
137-
self._sso_enabled = tier_conf.sso
138-
self._rows_per_minute = tier_conf.rows_per_minute
139-
self._update_roles = tier_conf.update_roles
140-
self._model_assignment = tier_conf.model_assignment
141-
self._onboarding_enabled = self.ld_client.variation("onBoardingEnabled", ld_user, default=False)

backend/deepchecks_monitoring/ee/features_control_on_prem.py

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,8 @@ class OnPremFeaturesControl(FeaturesControl):
66
TODO: implement license check :(
77
"""
88

9-
@property
10-
def max_models(self) -> int:
11-
return 9999
12-
13-
async def get_allowed_models(self, session) -> int:
14-
return 10
9+
async def get_allowed_models(self, session) -> None:
10+
return None
1511

1612
@property
1713
def update_roles(self) -> bool:
@@ -37,22 +33,6 @@ def slack_enabled(self) -> bool:
3733
def rows_per_minute(self) -> int:
3834
return 500_000
3935

40-
@property
41-
def custom_checks_enabled(self) -> bool:
42-
return False
43-
44-
@property
45-
def data_retention_months(self) -> int:
46-
return 12
47-
48-
@property
49-
def monthly_predictions_limit(self) -> int:
50-
return 10_000_000
51-
52-
@property
53-
def sso_enabled(self) -> bool:
54-
return False
55-
5636
@property
5737
def multi_tenant(self) -> bool:
5838
return False

backend/deepchecks_monitoring/ee/resources.py

Lines changed: 4 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,6 @@
1212
import logging
1313
from typing import TYPE_CHECKING, cast
1414

15-
import ldclient
16-
from ldclient import Context
17-
from ldclient.client import LDClient
18-
from ldclient.config import Config as LDConfig
19-
2015
from deepchecks_monitoring.ee.config import Settings, SlackSettings
2116
from deepchecks_monitoring.ee.features_control_cloud import CloudFeaturesControl
2217
from deepchecks_monitoring.ee.features_control_on_prem import OnPremFeaturesControl
@@ -38,10 +33,6 @@ class ResourcesProvider(OpenSourceResourcesProvider):
3833

3934
ALERT_NOTIFICATOR_TYPE = EEAlertNotificator
4035

41-
def __init__(self, settings: Settings):
42-
super().__init__(settings)
43-
self._lauchdarkly_client = None
44-
4536
@property
4637
def slack_settings(self) -> SlackSettings:
4738
"""Get the telemetry settings."""
@@ -60,36 +51,18 @@ def email_sender(self) -> EmailSender:
6051
self._email_sender = EmailSender(self.email_settings)
6152
return self._email_sender
6253

63-
@property
64-
def lauchdarkly_client(self) -> LDClient:
65-
"""Launchdarkly client."""
66-
if self.settings.is_cloud is False:
67-
raise Exception("Launchdarkly client is only available in cloud mode")
68-
if self._lauchdarkly_client:
69-
return self._lauchdarkly_client
70-
ldclient.set_config(LDConfig(self.settings.lauchdarkly_sdk_key))
71-
self._lauchdarkly_client = ldclient.get()
72-
return self._lauchdarkly_client
73-
7454
def get_features_control(self, user: User) -> FeaturesControl:
7555
"""Return features control."""
76-
if self.settings.is_cloud:
77-
return CloudFeaturesControl(user, self.lauchdarkly_client, self.settings)
7856
# TODO add license check -
79-
elif self.settings.is_on_prem:
57+
if self.settings.is_on_prem:
8058
return OnPremFeaturesControl(self.settings)
59+
if self.settings.is_cloud:
60+
return CloudFeaturesControl(user, self.settings)
8161
return FeaturesControl(self.settings)
8262

8363
@property
8464
def parallel_check_executors_pool(self) -> "ActorPool | None":
85-
if self.settings.is_cloud is False:
86-
parallel_check_executor_flag = True
87-
else:
88-
parallel_check_executor_flag = self.lauchdarkly_client.variation(
89-
"parallelCheckExecutorEnabled",
90-
context=Context.builder("parallelCheckExecutorEnabled").build(),
91-
default=True
92-
)
65+
parallel_check_executor_flag = self.settings.parallel_check_executor_flag
9366

9467
logging.getLogger("server").info({
9568
"mesage": f"'parallelCheckExecutorEnabled' is set to {parallel_check_executor_flag}"
@@ -101,7 +74,6 @@ def get_client_configuration(self) -> dict:
10174
if self.settings.is_cloud:
10275
settings = cast(Settings, self.settings)
10376
return {
104-
"lauchdarklySdkKey": settings.lauchdarkly_sdk_key,
10577
"environment": settings.enviroment,
10678
"mixpanel_id": settings.mixpanel_id,
10779
"is_cloud": True,

backend/deepchecks_monitoring/features_control.py

Lines changed: 1 addition & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,8 @@
1616
class FeaturesSchema(BaseModel):
1717
"""Schema to be returned to the client for the features control."""
1818

19-
max_models: int
20-
signup_enabled: bool
2119
slack_enabled: bool
2220
rows_per_minute: int
23-
custom_checks_enabled: bool
24-
data_retention_months: int
25-
monthly_predictions_limit: int
26-
sso_enabled: bool
2721
onboarding_enabled: bool
2822
update_roles: bool
2923
model_assignment: bool
@@ -36,12 +30,7 @@ class FeaturesControl:
3630
def __init__(self, settings):
3731
self.settings = settings
3832

39-
@property
40-
def max_models(self) -> int:
41-
"""Maximum number of models allowed for organization."""
42-
return 1
43-
44-
async def get_allowed_models(self, session) -> int: # pylint: disable=unused-argument
33+
async def get_allowed_models(self, session) -> int | None: # pylint: disable=unused-argument
4534
"""For the cloud, number of models which are allowed by subscription."""
4635
return 1
4736

@@ -75,26 +64,6 @@ def rows_per_minute(self) -> int:
7564
"""Maximum number of rows per minute allowed for organization."""
7665
return 500_000
7766

78-
@property
79-
def custom_checks_enabled(self) -> bool:
80-
"""Whether custom checks are enabled."""
81-
return False
82-
83-
@property
84-
def data_retention_months(self) -> int:
85-
"""Get number of months to keep data for."""
86-
return 3
87-
88-
@property
89-
def monthly_predictions_limit(self) -> int:
90-
"""Maximum number of predictions per month allowed for organization."""
91-
return 500_000
92-
93-
@property
94-
def sso_enabled(self) -> bool:
95-
"""Whether SSO is enabled."""
96-
return False
97-
9867
@property
9968
def multi_tenant(self) -> bool:
10069
"""Whether multi-tenant is enabled."""
@@ -108,14 +77,9 @@ def email_enabled(self) -> bool:
10877
def get_all_features(self) -> FeaturesSchema:
10978
"""Get all features for the client."""
11079
return FeaturesSchema(
111-
max_models=self.max_models,
11280
signup_enabled=self.signup_enabled,
11381
slack_enabled=self.slack_enabled,
11482
rows_per_minute=self.rows_per_minute,
115-
custom_checks_enabled=self.custom_checks_enabled,
116-
data_retention_months=self.data_retention_months,
117-
monthly_predictions_limit=self.monthly_predictions_limit,
118-
sso_enabled=self.sso_enabled,
11983
onboarding_enabled=self.onboarding_enabled,
12084
update_roles=self.update_roles,
12185
model_assignment=self.model_assignment,

0 commit comments

Comments
 (0)