Skip to content

Commit 25916c9

Browse files
committed
Updating imports and constants
1 parent 13c9a2b commit 25916c9

File tree

4 files changed

+40
-57
lines changed

4 files changed

+40
-57
lines changed

sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/provider/_constants.py

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -24,20 +24,6 @@
2424
ETAG_KEY = "ETag"
2525
FEATURE_FLAG_REFERENCE_KEY = "FeatureFlagReference"
2626

27-
PERCENTAGE_FILTER_NAMES = ["Percentage", "PercentageFilter", "Microsoft.Percentage", "Microsoft.PercentageFilter"]
28-
TIME_WINDOW_FILTER_NAMES = ["TimeWindow", "TimeWindowFilter", "Microsoft.TimeWindow", "Microsoft.TimeWindowFilter"]
29-
TARGETING_FILTER_NAMES = ["Targeting", "TargetingFilter", "Microsoft.Targeting", "Microsoft.TargetingFilter"]
30-
31-
CUSTOM_FILTER_KEY = "CSTM" # cspell:disable-line
32-
PERCENTAGE_FILTER_KEY = "PRCNT" # cspell:disable-line
33-
TIME_WINDOW_FILTER_KEY = "TIME"
34-
TARGETING_FILTER_KEY = "TRGT" # cspell:disable-line
35-
36-
FEATURE_FLAG_USES_TELEMETRY_TAG = "Telemetry"
37-
FEATURE_FLAG_USES_SEED_TAG = "Seed"
38-
FEATURE_FLAG_MAX_VARIANTS_KEY = "MaxVariants"
39-
FEATURE_FLAG_FEATURES_KEY = "FFFeatures"
40-
4127
# Mime profiles
4228
APP_CONFIG_AI_MIME_PROFILE = "https://azconfig.io/mime-profiles/ai/"
4329
APP_CONFIG_AICC_MIME_PROFILE = "https://azconfig.io/mime-profiles/ai/chat-completion"

sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/provider/_request_tracing_context.py

Lines changed: 28 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,27 @@
1313
AzureWebAppEnvironmentVariable,
1414
ContainerAppEnvironmentVariable,
1515
KubernetesEnvironmentVariable,
16-
CUSTOM_FILTER_KEY,
17-
PERCENTAGE_FILTER_KEY,
18-
TIME_WINDOW_FILTER_KEY,
19-
TARGETING_FILTER_KEY,
20-
PERCENTAGE_FILTER_NAMES,
21-
TIME_WINDOW_FILTER_NAMES,
22-
TARGETING_FILTER_NAMES,
23-
FEATURE_FLAG_USES_SEED_TAG,
24-
FEATURE_FLAG_USES_TELEMETRY_TAG,
16+
APP_CONFIG_AI_MIME_PROFILE,
2517
)
2618

19+
# Feature flag filter names
20+
PERCENTAGE_FILTER_NAMES = ["Percentage", "PercentageFilter", "Microsoft.Percentage", "Microsoft.PercentageFilter"]
21+
TIME_WINDOW_FILTER_NAMES = ["TimeWindow", "TimeWindowFilter", "Microsoft.TimeWindow", "Microsoft.TimeWindowFilter"]
22+
TARGETING_FILTER_NAMES = ["Targeting", "TargetingFilter", "Microsoft.Targeting", "Microsoft.TargetingFilter"]
23+
24+
CUSTOM_FILTER_KEY = "CSTM" # cspell:disable-line
25+
PERCENTAGE_FILTER_KEY = "PRCNT" # cspell:disable-line
26+
TIME_WINDOW_FILTER_KEY = "TIME"
27+
TARGETING_FILTER_KEY = "TRGT" # cspell:disable-line
28+
29+
FEATURE_FLAG_USES_TELEMETRY_TAG = "Telemetry"
30+
FEATURE_FLAG_USES_SEED_TAG = "Seed"
31+
FEATURE_FLAG_MAX_VARIANTS_KEY = "MaxVariants"
32+
FEATURE_FLAG_FEATURES_KEY = "FFFeatures"
33+
34+
CHAT_COMPLETION_PROFILE = "chat-completion"
35+
36+
2737
# Feature flag constants for telemetry
2838
LOAD_BALANCING_FEATURE = "LB"
2939
AI_CONFIGURATION_FEATURE = "AI"
@@ -33,10 +43,6 @@
3343
# Package name constants
3444
AZURE_AI_PROJECTS_PACKAGE = "azure-ai-projects"
3545

36-
# MIME profile constants
37-
AI_MIME_PROFILE = "https://azconfig.io/mime-profiles/ai"
38-
CHAT_COMPLETION_PROFILE = "chat-completion"
39-
4046
# Correlation context constants
4147
FEATUREMANAGEMENT_PACKAGE = "featuremanagement"
4248
CORRELATION_CONTEXT_HEADER = "Correlation-Context"
@@ -199,7 +205,7 @@ def update_ai_configuration_tracing(self, content_type: Optional[str]) -> None:
199205
return
200206

201207
# Check for AI mime profiles in content type
202-
if AI_MIME_PROFILE in content_type:
208+
if APP_CONFIG_AI_MIME_PROFILE in content_type:
203209
self.uses_ai_configuration = True
204210
if CHAT_COMPLETION_PROFILE in content_type:
205211
self.uses_aicc_configuration = True
@@ -269,21 +275,19 @@ def update_correlation_context_header(
269275
key_values.append((MAX_VARIANTS_KEY, str(self.max_variants)))
270276

271277
# Add feature flag features if present
272-
if self.uses_seed or self.uses_telemetry:
273-
ff_features_string = self._create_features_string()
274-
if ff_features_string:
275-
key_values.append((FF_FEATURES_KEY, ff_features_string))
278+
ff_features_string = self._create_features_string()
279+
if ff_features_string:
280+
key_values.append((FF_FEATURES_KEY, ff_features_string))
281+
282+
# Add general features if present
283+
features_string = self._get_features_string()
284+
if features_string:
285+
key_values.append((FEATURES_KEY, features_string))
276286

277287
# Add version information
278288
if self.feature_management_version:
279289
key_values.append((FM_PY_VER_KEY, self.feature_management_version))
280290

281-
# Add general features if present
282-
if self.uses_load_balancing or self.uses_ai_configuration or self.uses_aicc_configuration:
283-
features_string = self._get_features_string()
284-
if features_string:
285-
key_values.append((FEATURES_KEY, features_string))
286-
287291
# Add tags
288292
if self.is_key_vault_configured:
289293
tags.append(USES_KEY_VAULT_TAG)

sdk/appconfiguration/azure-appconfiguration-provider/tests/test_azureappconfigurationproviderbase.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,10 @@
2222
from azure.appconfiguration.provider._models import SettingSelector
2323
from azure.appconfiguration.provider._constants import (
2424
NULL_CHAR,
25-
CUSTOM_FILTER_KEY,
26-
PERCENTAGE_FILTER_KEY,
27-
TIME_WINDOW_FILTER_KEY,
28-
TARGETING_FILTER_KEY,
29-
PERCENTAGE_FILTER_NAMES,
30-
TIME_WINDOW_FILTER_NAMES,
31-
TARGETING_FILTER_NAMES,
3225
TELEMETRY_KEY,
3326
METADATA_KEY,
3427
ETAG_KEY,
3528
FEATURE_FLAG_REFERENCE_KEY,
36-
APP_CONFIG_AI_MIME_PROFILE,
37-
APP_CONFIG_AICC_MIME_PROFILE,
3829
)
3930
from azure.appconfiguration.provider._refresh_timer import _RefreshTimer
4031

sdk/appconfiguration/azure-appconfiguration-provider/tests/test_request_tracing_context.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,6 @@
1111
_RequestTracingContext,
1212
HostType,
1313
RequestType,
14-
)
15-
from azure.appconfiguration.provider._constants import (
16-
REQUEST_TRACING_DISABLED_ENVIRONMENT_VARIABLE,
17-
ServiceFabricEnvironmentVariable,
18-
AzureFunctionEnvironmentVariable,
19-
AzureWebAppEnvironmentVariable,
20-
ContainerAppEnvironmentVariable,
21-
KubernetesEnvironmentVariable,
2214
CUSTOM_FILTER_KEY,
2315
PERCENTAGE_FILTER_KEY,
2416
TIME_WINDOW_FILTER_KEY,
@@ -29,6 +21,16 @@
2921
FEATURE_FLAG_USES_SEED_TAG,
3022
FEATURE_FLAG_USES_TELEMETRY_TAG,
3123
)
24+
from azure.appconfiguration.provider._constants import (
25+
REQUEST_TRACING_DISABLED_ENVIRONMENT_VARIABLE,
26+
ServiceFabricEnvironmentVariable,
27+
AzureFunctionEnvironmentVariable,
28+
AzureWebAppEnvironmentVariable,
29+
ContainerAppEnvironmentVariable,
30+
KubernetesEnvironmentVariable,
31+
APP_CONFIG_AI_MIME_PROFILE,
32+
APP_CONFIG_AICC_MIME_PROFILE,
33+
)
3234

3335

3436
class TestRequestTracingContext(unittest.TestCase):
@@ -168,15 +170,15 @@ def test_reset_ai_configuration_tracing(self):
168170

169171
def test_update_ai_configuration_tracing_ai_profile(self):
170172
"""Test update_ai_configuration_tracing with AI profile."""
171-
content_type = "application/json; https://azconfig.io/mime-profiles/ai"
173+
content_type = "application/json; " + APP_CONFIG_AI_MIME_PROFILE
172174
self.context.update_ai_configuration_tracing(content_type)
173175

174176
self.assertTrue(self.context.uses_ai_configuration)
175177
self.assertFalse(self.context.uses_aicc_configuration)
176178

177179
def test_update_ai_configuration_tracing_aicc_profile(self):
178180
"""Test update_ai_configuration_tracing with AI Chat Completion profile."""
179-
content_type = "application/json; https://azconfig.io/mime-profiles/ai+chat-completion"
181+
content_type = "application/json; " + APP_CONFIG_AICC_MIME_PROFILE
180182
self.context.update_ai_configuration_tracing(content_type)
181183

182184
self.assertTrue(self.context.uses_ai_configuration)

0 commit comments

Comments
 (0)