Skip to content

Commit ce4e682

Browse files
committed
fix: use ServerZone enum for remote evaluation config
1 parent f223bce commit ce4e682

File tree

4 files changed

+12
-11
lines changed

4 files changed

+12
-11
lines changed

src/amplitude_experiment/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@
1212
from .cookie import AmplitudeCookie
1313
from .local.client import LocalEvaluationClient
1414
from .local.config import LocalEvaluationConfig
15-
from .local.config import ServerZone
15+
from .server_zone import ServerZone
1616
from .assignment import AssignmentConfig
1717
from .cohort.cohort_sync_config import CohortSyncConfig

src/amplitude_experiment/local/config.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
from enum import Enum
2-
31
from ..assignment import AssignmentConfig
42
from ..cohort.cohort_sync_config import CohortSyncConfig, DEFAULT_COHORT_SYNC_URL, EU_COHORT_SYNC_URL
3+
from ..server_zone import ServerZone
54

65
DEFAULT_SERVER_URL = 'https://api.lab.amplitude.com'
76
EU_SERVER_URL = 'https://flag.lab.eu.amplitude.com'
@@ -10,11 +9,6 @@
109
EU_STREAM_SERVER_URL = 'https://stream.lab.eu.amplitude.com'
1110

1211

13-
class ServerZone(Enum):
14-
US = "US"
15-
EU = "EU"
16-
17-
1812
class LocalEvaluationConfig:
1913
"""Experiment Local Client Configuration"""
2014

src/amplitude_experiment/remote/config.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from ..server_zone import ServerZone
2+
13
DEFAULT_SERVER_URL = 'https://api.lab.amplitude.com'
24
EU_SERVER_URL = 'https://api.lab.eu.amplitude.com'
35

@@ -12,7 +14,7 @@ def __init__(self, debug=False,
1214
fetch_retry_backoff_max_millis=10000,
1315
fetch_retry_backoff_scalar=1.5,
1416
fetch_retry_timeout_millis=10000,
15-
server_zone='us'):
17+
server_zone: ServerZone = ServerZone.US):
1618
"""
1719
Initialize a config
1820
Parameters:
@@ -27,7 +29,7 @@ def __init__(self, debug=False,
2729
greater than the max, the max is used for all subsequent retries.
2830
fetch_retry_backoff_scalar (float): Scales the minimum backoff exponentially.
2931
fetch_retry_timeout_millis (int): The request timeout for retrying fetch requests.
30-
server_zone (str): Select the Amplitude data center to get flags and variants from, `us` or `eu`.
32+
server_zone (str): Select the Amplitude data center to get flags and variants from, US or EU.
3133
3234
Returns:
3335
The config object
@@ -41,6 +43,6 @@ def __init__(self, debug=False,
4143
self.fetch_retry_backoff_scalar = fetch_retry_backoff_scalar
4244
self.fetch_retry_timeout_millis = fetch_retry_timeout_millis
4345
self.server_zone = server_zone
44-
if server_url == DEFAULT_SERVER_URL and server_zone == 'eu':
46+
if server_url == DEFAULT_SERVER_URL and server_zone == ServerZone.EU:
4547
self.server_url = EU_SERVER_URL
4648

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
from enum import Enum
2+
3+
class ServerZone(Enum):
4+
US = "US"
5+
EU = "EU"

0 commit comments

Comments
 (0)