cwyodmodules 0.3.54__py3-none-any.whl → 0.3.55__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- cwyodmodules/mgmt_config.py +209 -0
- {cwyodmodules-0.3.54.dist-info → cwyodmodules-0.3.55.dist-info}/METADATA +1 -1
- {cwyodmodules-0.3.54.dist-info → cwyodmodules-0.3.55.dist-info}/RECORD +6 -5
- {cwyodmodules-0.3.54.dist-info → cwyodmodules-0.3.55.dist-info}/WHEEL +0 -0
- {cwyodmodules-0.3.54.dist-info → cwyodmodules-0.3.55.dist-info}/licenses/LICENSE +0 -0
- {cwyodmodules-0.3.54.dist-info → cwyodmodules-0.3.55.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,209 @@
|
|
1
|
+
"""
|
2
|
+
Azure Project Management Configuration Template
|
3
|
+
|
4
|
+
This template provides standardized configuration for Azure logging and identity
|
5
|
+
management across projects. It creates singleton instances of AzureLogger and
|
6
|
+
AzureIdentity that can be imported and used throughout your application.
|
7
|
+
|
8
|
+
Usage:
|
9
|
+
from mgmt_config import logger, identity
|
10
|
+
|
11
|
+
logger.info("Application started")
|
12
|
+
credential = identity.get_credential()
|
13
|
+
"""
|
14
|
+
|
15
|
+
import os
|
16
|
+
from typing import Optional, Dict, Any
|
17
|
+
from azpaddypy.mgmt.logging import create_app_logger, create_function_logger
|
18
|
+
from azpaddypy.mgmt.identity import create_azure_identity
|
19
|
+
from azpaddypy.resources.keyvault import create_azure_keyvault
|
20
|
+
from azpaddypy.mgmt.local_env_manager import create_local_env_manager
|
21
|
+
|
22
|
+
# Alias for import in other packages
|
23
|
+
|
24
|
+
# =============================================================================
|
25
|
+
# SERVICE CONFIGURATION
|
26
|
+
# =============================================================================
|
27
|
+
|
28
|
+
# Service identity - customize these for your project
|
29
|
+
SERVICE_NAME = os.getenv("SERVICE_NAME", __name__)
|
30
|
+
SERVICE_VERSION = os.getenv("SERVICE_VERSION", "1.0.0")
|
31
|
+
|
32
|
+
# =============================================================================
|
33
|
+
# LOGGING CONFIGURATION
|
34
|
+
# =============================================================================
|
35
|
+
|
36
|
+
# Enable console output (useful for local development)
|
37
|
+
LOGGER_ENABLE_CONSOLE = os.getenv("LOGGER_ENABLE_CONSOLE", "true").lower() == "true"
|
38
|
+
|
39
|
+
# Application Insights connection string (optional, will use environment variable if not set)
|
40
|
+
LOGGER_CONNECTION_STRING = os.getenv("APPLICATIONINSIGHTS_CONNECTION_STRING")
|
41
|
+
|
42
|
+
# Local development settings
|
43
|
+
LOCAL_SETTINGS = {
|
44
|
+
"AzureWebJobsStorage": "UseDevelopmentStorage=true",
|
45
|
+
"AzureWebJobsDashboard": "UseDevelopmentStorage=true",
|
46
|
+
"input_queue_connection__queueServiceUri": "UseDevelopmentStorage=true",
|
47
|
+
"AzureWebJobsStorage__accountName": "UseDevelopmentStorage=true",
|
48
|
+
"AzureWebJobsStorage__blobServiceUri": "UseDevelopmentStorage=true",
|
49
|
+
"AZURE_CLIENT_ID": "aa73da4a-2888-4cb7-896e-5d51125f11f0"
|
50
|
+
}
|
51
|
+
|
52
|
+
# Configure which Azure SDK components to instrument
|
53
|
+
LOGGER_INSTRUMENTATION_OPTIONS = {
|
54
|
+
"azure_sdk": {"enabled": True},
|
55
|
+
"django": {"enabled": False},
|
56
|
+
"fastapi": {"enabled": False},
|
57
|
+
"flask": {"enabled": True},
|
58
|
+
"psycopg2": {"enabled": True},
|
59
|
+
"requests": {"enabled": True},
|
60
|
+
"urllib": {"enabled": True},
|
61
|
+
"urllib3": {"enabled": True},
|
62
|
+
}
|
63
|
+
|
64
|
+
# =============================================================================
|
65
|
+
# IDENTITY CONFIGURATION
|
66
|
+
# =============================================================================
|
67
|
+
|
68
|
+
# Token caching settings
|
69
|
+
IDENTITY_ENABLE_TOKEN_CACHE = os.getenv("IDENTITY_ENABLE_TOKEN_CACHE", "true").lower() == "true"
|
70
|
+
IDENTITY_ALLOW_UNENCRYPTED_STORAGE = os.getenv("IDENTITY_ALLOW_UNENCRYPTED_STORAGE", "true").lower() == "true"
|
71
|
+
|
72
|
+
# Custom credential options (None means use defaults)
|
73
|
+
IDENTITY_CUSTOM_CREDENTIAL_OPTIONS: Optional[Dict[str, Any]] = None
|
74
|
+
|
75
|
+
# Connection string for identity logging (uses same as logger by default)
|
76
|
+
IDENTITY_CONNECTION_STRING = LOGGER_CONNECTION_STRING
|
77
|
+
|
78
|
+
# =============================================================================
|
79
|
+
# KEYVAULT CONFIGURATION
|
80
|
+
# =============================================================================
|
81
|
+
|
82
|
+
# Azure Key Vault URL (required for Key Vault operations)
|
83
|
+
KEYVAULT_URL = os.getenv("key_vault_uri")
|
84
|
+
HEAD_KEYVAULT_URL = os.getenv("head_key_vault_uri")
|
85
|
+
|
86
|
+
# Enable specific Key Vault client types
|
87
|
+
KEYVAULT_ENABLE_SECRETS = os.getenv("KEYVAULT_ENABLE_SECRETS", "true").lower() == "true"
|
88
|
+
KEYVAULT_ENABLE_KEYS = os.getenv("KEYVAULT_ENABLE_KEYS", "false").lower() == "true"
|
89
|
+
KEYVAULT_ENABLE_CERTIFICATES = os.getenv("KEYVAULT_ENABLE_CERTIFICATES", "false").lower() == "true"
|
90
|
+
|
91
|
+
# Connection string for keyvault logging (uses same as logger by default)
|
92
|
+
KEYVAULT_CONNECTION_STRING = LOGGER_CONNECTION_STRING
|
93
|
+
|
94
|
+
# =============================================================================
|
95
|
+
# INITIALIZE SERVICES
|
96
|
+
# =============================================================================
|
97
|
+
|
98
|
+
# Create logger instance
|
99
|
+
logger = create_function_logger(
|
100
|
+
function_app_name=os.getenv("REFLECTION_NAME", "app"),
|
101
|
+
function_name=os.getenv("REFLECTION_KIND", "app"),
|
102
|
+
service_version=SERVICE_VERSION,
|
103
|
+
connection_string=LOGGER_CONNECTION_STRING,
|
104
|
+
instrumentation_options=LOGGER_INSTRUMENTATION_OPTIONS,
|
105
|
+
)
|
106
|
+
logger.info("Function logger initialized")
|
107
|
+
|
108
|
+
# Create local development settings instance
|
109
|
+
local_env_manager = create_local_env_manager(
|
110
|
+
file_path=".env",
|
111
|
+
settings=LOCAL_SETTINGS,
|
112
|
+
logger=logger,
|
113
|
+
override_json=True,
|
114
|
+
override_dotenv=True,
|
115
|
+
override_settings=True,
|
116
|
+
)
|
117
|
+
|
118
|
+
# Create identity instance with shared logger
|
119
|
+
identity = create_azure_identity(
|
120
|
+
service_name=SERVICE_NAME,
|
121
|
+
service_version=SERVICE_VERSION,
|
122
|
+
enable_token_cache=IDENTITY_ENABLE_TOKEN_CACHE,
|
123
|
+
allow_unencrypted_storage=IDENTITY_ALLOW_UNENCRYPTED_STORAGE,
|
124
|
+
custom_credential_options=IDENTITY_CUSTOM_CREDENTIAL_OPTIONS,
|
125
|
+
connection_string=IDENTITY_CONNECTION_STRING,
|
126
|
+
logger=logger,
|
127
|
+
)
|
128
|
+
|
129
|
+
# Create keyvault instance with shared logger and identity (if URL is configured)
|
130
|
+
keyvault = None
|
131
|
+
if KEYVAULT_URL:
|
132
|
+
keyvault = create_azure_keyvault(
|
133
|
+
vault_url=KEYVAULT_URL,
|
134
|
+
azure_identity=identity,
|
135
|
+
service_name=SERVICE_NAME,
|
136
|
+
service_version=SERVICE_VERSION,
|
137
|
+
logger=logger,
|
138
|
+
connection_string=KEYVAULT_CONNECTION_STRING,
|
139
|
+
enable_secrets=KEYVAULT_ENABLE_SECRETS,
|
140
|
+
enable_keys=KEYVAULT_ENABLE_KEYS,
|
141
|
+
enable_certificates=KEYVAULT_ENABLE_CERTIFICATES,
|
142
|
+
)
|
143
|
+
|
144
|
+
head_keyvault = None
|
145
|
+
if HEAD_KEYVAULT_URL:
|
146
|
+
head_keyvault = create_azure_keyvault(
|
147
|
+
vault_url=HEAD_KEYVAULT_URL,
|
148
|
+
azure_identity=identity,
|
149
|
+
service_name=SERVICE_NAME,
|
150
|
+
service_version=SERVICE_VERSION,
|
151
|
+
logger=logger,
|
152
|
+
connection_string=KEYVAULT_CONNECTION_STRING,
|
153
|
+
enable_secrets=KEYVAULT_ENABLE_SECRETS,
|
154
|
+
enable_keys=KEYVAULT_ENABLE_KEYS,
|
155
|
+
enable_certificates=KEYVAULT_ENABLE_CERTIFICATES,
|
156
|
+
)
|
157
|
+
|
158
|
+
# =============================================================================
|
159
|
+
# VALIDATION & STARTUP
|
160
|
+
# =============================================================================
|
161
|
+
|
162
|
+
# Validate critical configuration
|
163
|
+
if SERVICE_NAME == __name__:
|
164
|
+
logger.warning(
|
165
|
+
"SERVICE_NAME is not configured. Please set SERVICE_NAME environment variable or update this template.",
|
166
|
+
extra={"configuration_issue": "service_name_not_set"}
|
167
|
+
)
|
168
|
+
|
169
|
+
if not LOGGER_CONNECTION_STRING:
|
170
|
+
logger.info(
|
171
|
+
"No Application Insights connection string configured. Telemetry will be disabled.",
|
172
|
+
extra={"telemetry_status": "disabled"}
|
173
|
+
)
|
174
|
+
|
175
|
+
if not KEYVAULT_URL:
|
176
|
+
logger.info(
|
177
|
+
"No Key Vault URL configured. Key Vault operations will be disabled.",
|
178
|
+
extra={"keyvault_status": "disabled"}
|
179
|
+
)
|
180
|
+
|
181
|
+
if not HEAD_KEYVAULT_URL:
|
182
|
+
logger.info(
|
183
|
+
"No Head Key Vault URL configured. Head Key Vault operations will be disabled.",
|
184
|
+
extra={"head_keyvault_status": "disabled"}
|
185
|
+
)
|
186
|
+
|
187
|
+
# Log successful initialization
|
188
|
+
logger.info(
|
189
|
+
f"Management configuration initialized for service '{SERVICE_NAME}' v{SERVICE_VERSION}",
|
190
|
+
extra={
|
191
|
+
"service_name": SERVICE_NAME,
|
192
|
+
"service_version": SERVICE_VERSION,
|
193
|
+
"console_logging": LOGGER_ENABLE_CONSOLE,
|
194
|
+
"token_cache_enabled": IDENTITY_ENABLE_TOKEN_CACHE,
|
195
|
+
"telemetry_enabled": bool(LOGGER_CONNECTION_STRING),
|
196
|
+
"keyvault_enabled": bool(KEYVAULT_URL),
|
197
|
+
"head_keyvault_enabled": bool(HEAD_KEYVAULT_URL),
|
198
|
+
"keyvault_secrets_enabled": KEYVAULT_ENABLE_SECRETS if KEYVAULT_URL else False,
|
199
|
+
"keyvault_keys_enabled": KEYVAULT_ENABLE_KEYS if KEYVAULT_URL else False,
|
200
|
+
"keyvault_certificates_enabled": KEYVAULT_ENABLE_CERTIFICATES if KEYVAULT_URL else False,
|
201
|
+
}
|
202
|
+
)
|
203
|
+
|
204
|
+
# =============================================================================
|
205
|
+
# EXPORTS
|
206
|
+
# =============================================================================
|
207
|
+
|
208
|
+
# Export logger, identity, and keyvault for use in applications
|
209
|
+
__all__ = ["logger", "local_env_manager", "identity", "keyvault", "head_keyvault"]
|
@@ -1,4 +1,5 @@
|
|
1
1
|
cwyodmodules/__init__.py,sha256=frcCV1k9oG9oKj3dpUqdJg1PxRT2RSN_XKdLCPjaYaY,2
|
2
|
+
cwyodmodules/mgmt_config.py,sha256=8_44C151sT6sFrxjygWVhevVg4Wi0jVU9va8XLHvY7Y,8405
|
2
3
|
cwyodmodules/api/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
3
4
|
cwyodmodules/api/chat_history.py,sha256=bVXFmhTHIfEiHv_nBrfizO-cQRHhKgrdcZ07OD1b0Tw,20683
|
4
5
|
cwyodmodules/batch/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
@@ -108,8 +109,8 @@ cwyodmodules/graphrag/query/generate.py,sha256=BZiB6iw7PkIovw-CyYFogMHnDxK0Qu_4u
|
|
108
109
|
cwyodmodules/graphrag/query/graph_search.py,sha256=95h3ecSWx4864XgKABtG0fh3Nk8HkqJVzoCrO8daJ-Y,7724
|
109
110
|
cwyodmodules/graphrag/query/types.py,sha256=1Iq1dp4I4a56_cuFjOZ0NTgd0A2_MpVFznp_czgt6cI,617
|
110
111
|
cwyodmodules/graphrag/query/vector_search.py,sha256=9Gwu9LPjtoAYUU8WKqCvbCHAIg3dpk71reoYd1scLnQ,1807
|
111
|
-
cwyodmodules-0.3.
|
112
|
-
cwyodmodules-0.3.
|
113
|
-
cwyodmodules-0.3.
|
114
|
-
cwyodmodules-0.3.
|
115
|
-
cwyodmodules-0.3.
|
112
|
+
cwyodmodules-0.3.55.dist-info/licenses/LICENSE,sha256=UqBDTipijsSW2ZSOXyTZnMsXmLoEHTgNEM0tL4g-Sso,1150
|
113
|
+
cwyodmodules-0.3.55.dist-info/METADATA,sha256=OD9JKPHxXcaAQGblPWbMjjqaeVPXcD2ZV_-OT1KNzaU,2002
|
114
|
+
cwyodmodules-0.3.55.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
115
|
+
cwyodmodules-0.3.55.dist-info/top_level.txt,sha256=99RENLbkdRX-qpJvsxZ5AfmTL5s6shSaKOWYpz1vwzg,13
|
116
|
+
cwyodmodules-0.3.55.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|