Skip to content

Commit 9201cb5

Browse files
authored
feat: python local evaluation implementation (#52)
1 parent 883a3f3 commit 9201cb5

37 files changed

+1844
-2044
lines changed

.github/workflows/publish-to-pypi.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@ jobs:
3131
with:
3232
fetch-depth: 0
3333

34-
- name: Set up Python 3.7
34+
- name: Set up Python 3.8
3535
uses: actions/setup-python@v3
3636
with:
37-
python-version: 3.7
37+
python-version: 3.8
3838

3939
- name: Install dependencies
4040
run: python -m pip install build setuptools wheel twine amplitude_analytics parameterized python-dotenv~=0.21.1 python-semantic-release==7.34.6

.github/workflows/publish-to-test-pypi.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ jobs:
2121
steps:
2222
- uses: actions/checkout@v3
2323

24-
- name: Set up Python 3.7
24+
- name: Set up Python 3.8
2525
uses: actions/setup-python@v3
2626
with:
27-
python-version: 3.7
27+
python-version: 3.8
2828

2929
- name: Install dependencies
3030
run: python -m pip install build setuptools wheel twine amplitude_analytics parameterized

.github/workflows/test-arm.yml

Lines changed: 0 additions & 33 deletions
This file was deleted.

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ jobs:
88
environment: Unit Test
99
strategy:
1010
matrix:
11-
python-version: [ "3.7" ]
11+
python-version: [ "3.8" ]
1212
steps:
1313
- name: Checkout source code
1414
uses: actions/checkout@v3

requirements-dev.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
parameterized~=0.9.0
22
python-dotenv~=0.21.1
3+
requests~=2.31.0

requirements.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
amplitude_analytics~=1.1.1
1+
amplitude_analytics~=1.1.1
2+
dataclasses-json~=0.6.7

src/amplitude_experiment/deployment/deployment_runner.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,12 @@ def __update_flag_configs(self):
5656
self.logger.warning(f'Failed to fetch flag configs: {e}')
5757
raise e
5858

59-
flag_keys = {flag['key'] for flag in flag_configs}
60-
self.flag_config_storage.remove_if(lambda f: f['key'] not in flag_keys)
59+
flag_keys = {flag.key for flag in flag_configs}
60+
self.flag_config_storage.remove_if(lambda f: f.key not in flag_keys)
6161

6262
if not self.cohort_loader:
6363
for flag_config in flag_configs:
64-
self.logger.debug(f"Putting non-cohort flag {flag_config['key']}")
64+
self.logger.debug(f"Putting non-cohort flag {flag_config.key}")
6565
self.flag_config_storage.put_flag_config(flag_config)
6666
return
6767

@@ -83,11 +83,11 @@ def __update_flag_configs(self):
8383
# iterate through new flag configs and check if their required cohorts exist
8484
for flag_config in flag_configs:
8585
cohort_ids = get_all_cohort_ids_from_flag(flag_config)
86-
self.logger.debug(f"Storing flag {flag_config['key']}")
86+
self.logger.debug(f"Storing flag {flag_config.key}")
8787
self.flag_config_storage.put_flag_config(flag_config)
8888
missing_cohorts = cohort_ids - updated_cohort_ids
8989
if missing_cohorts:
90-
self.logger.warning(f"Flag {flag_config['key']} - failed to load cohorts: {missing_cohorts}")
90+
self.logger.warning(f"Flag {flag_config.key} - failed to load cohorts: {missing_cohorts}")
9191

9292
# delete unused cohorts
9393
self._delete_unused_cohorts()

src/amplitude_experiment/evaluation/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)