cwyodmodules 0.3.76__tar.gz → 0.3.78__tar.gz
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-0.3.76 → cwyodmodules-0.3.78}/PKG-INFO +2 -2
- cwyodmodules-0.3.78/cwyodmodules/mgmt_config.py +416 -0
- {cwyodmodules-0.3.76 → cwyodmodules-0.3.78}/cwyodmodules.egg-info/PKG-INFO +2 -2
- {cwyodmodules-0.3.76 → cwyodmodules-0.3.78}/cwyodmodules.egg-info/requires.txt +1 -1
- {cwyodmodules-0.3.76 → cwyodmodules-0.3.78}/pyproject.toml +2 -2
- cwyodmodules-0.3.76/cwyodmodules/mgmt_config.py +0 -246
- {cwyodmodules-0.3.76 → cwyodmodules-0.3.78}/LICENSE +0 -0
- {cwyodmodules-0.3.76 → cwyodmodules-0.3.78}/README.md +0 -0
- {cwyodmodules-0.3.76 → cwyodmodules-0.3.78}/cwyodmodules/__init__.py +0 -0
- {cwyodmodules-0.3.76 → cwyodmodules-0.3.78}/cwyodmodules/api/__init__.py +0 -0
- {cwyodmodules-0.3.76 → cwyodmodules-0.3.78}/cwyodmodules/api/chat_history.py +0 -0
- {cwyodmodules-0.3.76 → cwyodmodules-0.3.78}/cwyodmodules/batch/__init__.py +0 -0
- {cwyodmodules-0.3.76 → cwyodmodules-0.3.78}/cwyodmodules/batch/utilities/__init__.py +0 -0
- {cwyodmodules-0.3.76 → cwyodmodules-0.3.78}/cwyodmodules/batch/utilities/chat_history/auth_utils.py +0 -0
- {cwyodmodules-0.3.76 → cwyodmodules-0.3.78}/cwyodmodules/batch/utilities/chat_history/cosmosdb.py +0 -0
- {cwyodmodules-0.3.76 → cwyodmodules-0.3.78}/cwyodmodules/batch/utilities/chat_history/database_client_base.py +0 -0
- {cwyodmodules-0.3.76 → cwyodmodules-0.3.78}/cwyodmodules/batch/utilities/chat_history/database_factory.py +0 -0
- {cwyodmodules-0.3.76 → cwyodmodules-0.3.78}/cwyodmodules/batch/utilities/chat_history/postgresdbservice.py +0 -0
- {cwyodmodules-0.3.76 → cwyodmodules-0.3.78}/cwyodmodules/batch/utilities/chat_history/sample_user.py +0 -0
- {cwyodmodules-0.3.76 → cwyodmodules-0.3.78}/cwyodmodules/batch/utilities/common/__init__.py +0 -0
- {cwyodmodules-0.3.76 → cwyodmodules-0.3.78}/cwyodmodules/batch/utilities/common/answer.py +0 -0
- {cwyodmodules-0.3.76 → cwyodmodules-0.3.78}/cwyodmodules/batch/utilities/common/source_document.py +0 -0
- {cwyodmodules-0.3.76 → cwyodmodules-0.3.78}/cwyodmodules/batch/utilities/document_chunking/__init__.py +0 -0
- {cwyodmodules-0.3.76 → cwyodmodules-0.3.78}/cwyodmodules/batch/utilities/document_chunking/chunking_strategy.py +0 -0
- {cwyodmodules-0.3.76 → cwyodmodules-0.3.78}/cwyodmodules/batch/utilities/document_chunking/document_chunking_base.py +0 -0
- {cwyodmodules-0.3.76 → cwyodmodules-0.3.78}/cwyodmodules/batch/utilities/document_chunking/fixed_size_overlap.py +0 -0
- {cwyodmodules-0.3.76 → cwyodmodules-0.3.78}/cwyodmodules/batch/utilities/document_chunking/layout.py +0 -0
- {cwyodmodules-0.3.76 → cwyodmodules-0.3.78}/cwyodmodules/batch/utilities/document_chunking/page.py +0 -0
- {cwyodmodules-0.3.76 → cwyodmodules-0.3.78}/cwyodmodules/batch/utilities/document_chunking/paragraph.py +0 -0
- {cwyodmodules-0.3.76 → cwyodmodules-0.3.78}/cwyodmodules/batch/utilities/document_chunking/strategies.py +0 -0
- {cwyodmodules-0.3.76 → cwyodmodules-0.3.78}/cwyodmodules/batch/utilities/document_loading/__init__.py +0 -0
- {cwyodmodules-0.3.76 → cwyodmodules-0.3.78}/cwyodmodules/batch/utilities/document_loading/document_loading_base.py +0 -0
- {cwyodmodules-0.3.76 → cwyodmodules-0.3.78}/cwyodmodules/batch/utilities/document_loading/layout.py +0 -0
- {cwyodmodules-0.3.76 → cwyodmodules-0.3.78}/cwyodmodules/batch/utilities/document_loading/read.py +0 -0
- {cwyodmodules-0.3.76 → cwyodmodules-0.3.78}/cwyodmodules/batch/utilities/document_loading/strategies.py +0 -0
- {cwyodmodules-0.3.76 → cwyodmodules-0.3.78}/cwyodmodules/batch/utilities/document_loading/web.py +0 -0
- {cwyodmodules-0.3.76 → cwyodmodules-0.3.78}/cwyodmodules/batch/utilities/document_loading/word_document.py +0 -0
- {cwyodmodules-0.3.76 → cwyodmodules-0.3.78}/cwyodmodules/batch/utilities/helpers/__init__.py +0 -0
- {cwyodmodules-0.3.76 → cwyodmodules-0.3.78}/cwyodmodules/batch/utilities/helpers/azure_blob_storage_client.py +0 -0
- {cwyodmodules-0.3.76 → cwyodmodules-0.3.78}/cwyodmodules/batch/utilities/helpers/azure_computer_vision_client.py +0 -0
- {cwyodmodules-0.3.76 → cwyodmodules-0.3.78}/cwyodmodules/batch/utilities/helpers/azure_form_recognizer_helper.py +0 -0
- {cwyodmodules-0.3.76 → cwyodmodules-0.3.78}/cwyodmodules/batch/utilities/helpers/azure_postgres_helper.py +0 -0
- {cwyodmodules-0.3.76 → cwyodmodules-0.3.78}/cwyodmodules/batch/utilities/helpers/azure_postgres_helper_light_rag.py +0 -0
- {cwyodmodules-0.3.76 → cwyodmodules-0.3.78}/cwyodmodules/batch/utilities/helpers/azure_search_helper.py +0 -0
- {cwyodmodules-0.3.76 → cwyodmodules-0.3.78}/cwyodmodules/batch/utilities/helpers/config/agent_mode.py +0 -0
- {cwyodmodules-0.3.76 → cwyodmodules-0.3.78}/cwyodmodules/batch/utilities/helpers/config/assistant_strategy.py +0 -0
- {cwyodmodules-0.3.76 → cwyodmodules-0.3.78}/cwyodmodules/batch/utilities/helpers/config/config_helper.py +0 -0
- {cwyodmodules-0.3.76 → cwyodmodules-0.3.78}/cwyodmodules/batch/utilities/helpers/config/conversation_flow.py +0 -0
- {cwyodmodules-0.3.76 → cwyodmodules-0.3.78}/cwyodmodules/batch/utilities/helpers/config/database_type.py +0 -0
- {cwyodmodules-0.3.76 → cwyodmodules-0.3.78}/cwyodmodules/batch/utilities/helpers/config/default.json +0 -0
- {cwyodmodules-0.3.76 → cwyodmodules-0.3.78}/cwyodmodules/batch/utilities/helpers/config/default_contract_assistant_prompt.txt +0 -0
- {cwyodmodules-0.3.76 → cwyodmodules-0.3.78}/cwyodmodules/batch/utilities/helpers/config/default_employee_assistant_prompt.txt +0 -0
- {cwyodmodules-0.3.76 → cwyodmodules-0.3.78}/cwyodmodules/batch/utilities/helpers/config/embedding_config.py +0 -0
- {cwyodmodules-0.3.76 → cwyodmodules-0.3.78}/cwyodmodules/batch/utilities/helpers/document_chunking_helper.py +0 -0
- {cwyodmodules-0.3.76 → cwyodmodules-0.3.78}/cwyodmodules/batch/utilities/helpers/document_loading_helper.py +0 -0
- {cwyodmodules-0.3.76 → cwyodmodules-0.3.78}/cwyodmodules/batch/utilities/helpers/embedders/embedder_base.py +0 -0
- {cwyodmodules-0.3.76 → cwyodmodules-0.3.78}/cwyodmodules/batch/utilities/helpers/embedders/embedder_factory.py +0 -0
- {cwyodmodules-0.3.76 → cwyodmodules-0.3.78}/cwyodmodules/batch/utilities/helpers/embedders/integrated_vectorization_embedder.py +0 -0
- {cwyodmodules-0.3.76 → cwyodmodules-0.3.78}/cwyodmodules/batch/utilities/helpers/embedders/postgres_embedder.py +0 -0
- {cwyodmodules-0.3.76 → cwyodmodules-0.3.78}/cwyodmodules/batch/utilities/helpers/embedders/push_embedder.py +0 -0
- {cwyodmodules-0.3.76 → cwyodmodules-0.3.78}/cwyodmodules/batch/utilities/helpers/env_helper.py +0 -0
- {cwyodmodules-0.3.76 → cwyodmodules-0.3.78}/cwyodmodules/batch/utilities/helpers/lightrag_helper.py +0 -0
- {cwyodmodules-0.3.76 → cwyodmodules-0.3.78}/cwyodmodules/batch/utilities/helpers/llm_helper.py +0 -0
- {cwyodmodules-0.3.76 → cwyodmodules-0.3.78}/cwyodmodules/batch/utilities/helpers/orchestrator_helper.py +0 -0
- {cwyodmodules-0.3.76 → cwyodmodules-0.3.78}/cwyodmodules/batch/utilities/integrated_vectorization/azure_search_datasource.py +0 -0
- {cwyodmodules-0.3.76 → cwyodmodules-0.3.78}/cwyodmodules/batch/utilities/integrated_vectorization/azure_search_index.py +0 -0
- {cwyodmodules-0.3.76 → cwyodmodules-0.3.78}/cwyodmodules/batch/utilities/integrated_vectorization/azure_search_indexer.py +0 -0
- {cwyodmodules-0.3.76 → cwyodmodules-0.3.78}/cwyodmodules/batch/utilities/integrated_vectorization/azure_search_skillset.py +0 -0
- {cwyodmodules-0.3.76 → cwyodmodules-0.3.78}/cwyodmodules/batch/utilities/loggers/conversation_logger.py +0 -0
- {cwyodmodules-0.3.76 → cwyodmodules-0.3.78}/cwyodmodules/batch/utilities/orchestrator/__init__.py +0 -0
- {cwyodmodules-0.3.76 → cwyodmodules-0.3.78}/cwyodmodules/batch/utilities/orchestrator/lang_chain_agent.py +0 -0
- {cwyodmodules-0.3.76 → cwyodmodules-0.3.78}/cwyodmodules/batch/utilities/orchestrator/open_ai_functions.py +0 -0
- {cwyodmodules-0.3.76 → cwyodmodules-0.3.78}/cwyodmodules/batch/utilities/orchestrator/orchestration_strategy.py +0 -0
- {cwyodmodules-0.3.76 → cwyodmodules-0.3.78}/cwyodmodules/batch/utilities/orchestrator/orchestrator_base.py +0 -0
- {cwyodmodules-0.3.76 → cwyodmodules-0.3.78}/cwyodmodules/batch/utilities/orchestrator/prompt_flow.py +0 -0
- {cwyodmodules-0.3.76 → cwyodmodules-0.3.78}/cwyodmodules/batch/utilities/orchestrator/semantic_kernel_orchestrator.py +0 -0
- {cwyodmodules-0.3.76 → cwyodmodules-0.3.78}/cwyodmodules/batch/utilities/orchestrator/strategies.py +0 -0
- {cwyodmodules-0.3.76 → cwyodmodules-0.3.78}/cwyodmodules/batch/utilities/parser/__init__.py +0 -0
- {cwyodmodules-0.3.76 → cwyodmodules-0.3.78}/cwyodmodules/batch/utilities/parser/output_parser_tool.py +0 -0
- {cwyodmodules-0.3.76 → cwyodmodules-0.3.78}/cwyodmodules/batch/utilities/parser/parser_base.py +0 -0
- {cwyodmodules-0.3.76 → cwyodmodules-0.3.78}/cwyodmodules/batch/utilities/plugins/chat_plugin.py +0 -0
- {cwyodmodules-0.3.76 → cwyodmodules-0.3.78}/cwyodmodules/batch/utilities/plugins/outlook_calendar_plugin.py +0 -0
- {cwyodmodules-0.3.76 → cwyodmodules-0.3.78}/cwyodmodules/batch/utilities/plugins/post_answering_plugin.py +0 -0
- {cwyodmodules-0.3.76 → cwyodmodules-0.3.78}/cwyodmodules/batch/utilities/search/azure_search_handler.py +0 -0
- {cwyodmodules-0.3.76 → cwyodmodules-0.3.78}/cwyodmodules/batch/utilities/search/azure_search_handler_light_rag.py +0 -0
- {cwyodmodules-0.3.76 → cwyodmodules-0.3.78}/cwyodmodules/batch/utilities/search/integrated_vectorization_search_handler.py +0 -0
- {cwyodmodules-0.3.76 → cwyodmodules-0.3.78}/cwyodmodules/batch/utilities/search/lightrag_search_handler.py +0 -0
- {cwyodmodules-0.3.76 → cwyodmodules-0.3.78}/cwyodmodules/batch/utilities/search/postgres_search_handler.py +0 -0
- {cwyodmodules-0.3.76 → cwyodmodules-0.3.78}/cwyodmodules/batch/utilities/search/postgres_search_handler_light_rag.py +0 -0
- {cwyodmodules-0.3.76 → cwyodmodules-0.3.78}/cwyodmodules/batch/utilities/search/search.py +0 -0
- {cwyodmodules-0.3.76 → cwyodmodules-0.3.78}/cwyodmodules/batch/utilities/search/search_handler_base.py +0 -0
- {cwyodmodules-0.3.76 → cwyodmodules-0.3.78}/cwyodmodules/batch/utilities/tools/__init__.py +0 -0
- {cwyodmodules-0.3.76 → cwyodmodules-0.3.78}/cwyodmodules/batch/utilities/tools/answer_processing_base.py +0 -0
- {cwyodmodules-0.3.76 → cwyodmodules-0.3.78}/cwyodmodules/batch/utilities/tools/answering_tool_base.py +0 -0
- {cwyodmodules-0.3.76 → cwyodmodules-0.3.78}/cwyodmodules/batch/utilities/tools/content_safety_checker.py +0 -0
- {cwyodmodules-0.3.76 → cwyodmodules-0.3.78}/cwyodmodules/batch/utilities/tools/post_prompt_tool.py +0 -0
- {cwyodmodules-0.3.76 → cwyodmodules-0.3.78}/cwyodmodules/batch/utilities/tools/question_answer_tool.py +0 -0
- {cwyodmodules-0.3.76 → cwyodmodules-0.3.78}/cwyodmodules/batch/utilities/tools/text_processing_tool.py +0 -0
- {cwyodmodules-0.3.76 → cwyodmodules-0.3.78}/cwyodmodules/graphrag/__init__.py +0 -0
- {cwyodmodules-0.3.76 → cwyodmodules-0.3.78}/cwyodmodules/graphrag/config.py +0 -0
- {cwyodmodules-0.3.76 → cwyodmodules-0.3.78}/cwyodmodules/graphrag/database/__init__.py +0 -0
- {cwyodmodules-0.3.76 → cwyodmodules-0.3.78}/cwyodmodules/graphrag/database/base.py +0 -0
- {cwyodmodules-0.3.76 → cwyodmodules-0.3.78}/cwyodmodules/graphrag/database/models.py +0 -0
- {cwyodmodules-0.3.76 → cwyodmodules-0.3.78}/cwyodmodules/graphrag/indexing/__init__.py +0 -0
- {cwyodmodules-0.3.76 → cwyodmodules-0.3.78}/cwyodmodules/graphrag/indexing/chunking.py +0 -0
- {cwyodmodules-0.3.76 → cwyodmodules-0.3.78}/cwyodmodules/graphrag/indexing/extraction.py +0 -0
- {cwyodmodules-0.3.76 → cwyodmodules-0.3.78}/cwyodmodules/graphrag/indexing/types.py +0 -0
- {cwyodmodules-0.3.76 → cwyodmodules-0.3.78}/cwyodmodules/graphrag/indexing/upsert.py +0 -0
- {cwyodmodules-0.3.76 → cwyodmodules-0.3.78}/cwyodmodules/graphrag/indexing/utils.py +0 -0
- {cwyodmodules-0.3.76 → cwyodmodules-0.3.78}/cwyodmodules/graphrag/llm/__init__.py +0 -0
- {cwyodmodules-0.3.76 → cwyodmodules-0.3.78}/cwyodmodules/graphrag/llm/llm.py +0 -0
- {cwyodmodules-0.3.76 → cwyodmodules-0.3.78}/cwyodmodules/graphrag/llm/prompt.py +0 -0
- {cwyodmodules-0.3.76 → cwyodmodules-0.3.78}/cwyodmodules/graphrag/main.py +0 -0
- {cwyodmodules-0.3.76 → cwyodmodules-0.3.78}/cwyodmodules/graphrag/query/__init__.py +0 -0
- {cwyodmodules-0.3.76 → cwyodmodules-0.3.78}/cwyodmodules/graphrag/query/generate.py +0 -0
- {cwyodmodules-0.3.76 → cwyodmodules-0.3.78}/cwyodmodules/graphrag/query/graph_search.py +0 -0
- {cwyodmodules-0.3.76 → cwyodmodules-0.3.78}/cwyodmodules/graphrag/query/types.py +0 -0
- {cwyodmodules-0.3.76 → cwyodmodules-0.3.78}/cwyodmodules/graphrag/query/vector_search.py +0 -0
- {cwyodmodules-0.3.76 → cwyodmodules-0.3.78}/cwyodmodules.egg-info/SOURCES.txt +0 -0
- {cwyodmodules-0.3.76 → cwyodmodules-0.3.78}/cwyodmodules.egg-info/dependency_links.txt +0 -0
- {cwyodmodules-0.3.76 → cwyodmodules-0.3.78}/cwyodmodules.egg-info/top_level.txt +0 -0
- {cwyodmodules-0.3.76 → cwyodmodules-0.3.78}/setup.cfg +0 -0
- {cwyodmodules-0.3.76 → cwyodmodules-0.3.78}/tests/test_api.py +0 -0
- {cwyodmodules-0.3.76 → cwyodmodules-0.3.78}/tests/test_batch.py +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: cwyodmodules
|
3
|
-
Version: 0.3.
|
3
|
+
Version: 0.3.78
|
4
4
|
Summary: Add your description here
|
5
5
|
Author-email: Patrik <patrikhartl@gmail.com>
|
6
6
|
Classifier: Operating System :: OS Independent
|
@@ -40,7 +40,7 @@ Requires-Dist: azure-search-documents==11.6.0b4
|
|
40
40
|
Requires-Dist: semantic-kernel==1.3.0
|
41
41
|
Requires-Dist: pydantic==2.7.4
|
42
42
|
Requires-Dist: pandas>=2.2.3
|
43
|
-
Requires-Dist: azpaddypy>=0.5.
|
43
|
+
Requires-Dist: azpaddypy>=0.5.6
|
44
44
|
Dynamic: license-file
|
45
45
|
|
46
46
|
# paddypy
|
@@ -0,0 +1,416 @@
|
|
1
|
+
"""Azure Project Management Configuration Template.
|
2
|
+
|
3
|
+
This module provides standardized configuration for Azure logging, identity management,
|
4
|
+
and Key Vault access across projects. It creates singleton instances that can be
|
5
|
+
imported and used throughout your application.
|
6
|
+
|
7
|
+
The configuration is driven by environment variables with sensible defaults, allowing
|
8
|
+
for flexible deployment across different environments (local development, staging,
|
9
|
+
production) without code changes.
|
10
|
+
|
11
|
+
Features:
|
12
|
+
- Automatic service detection (app vs function app)
|
13
|
+
- Configurable logging with Application Insights integration
|
14
|
+
- Azure identity management with token caching
|
15
|
+
- Key Vault integration for secrets, keys, and certificates
|
16
|
+
- Docker environment detection
|
17
|
+
- Local development environment setup
|
18
|
+
|
19
|
+
Usage:
|
20
|
+
Basic usage::
|
21
|
+
|
22
|
+
from mgmt_config import logger, identity
|
23
|
+
|
24
|
+
logger.info("Application started")
|
25
|
+
credential = identity.get_credential()
|
26
|
+
|
27
|
+
With Key Vault::
|
28
|
+
|
29
|
+
from mgmt_config import keyvault
|
30
|
+
|
31
|
+
if keyvault:
|
32
|
+
secret_value = keyvault.get_secret("my-secret")
|
33
|
+
|
34
|
+
Environment Variables:
|
35
|
+
Service Configuration:
|
36
|
+
REFLECTION_NAME: Service name for identification
|
37
|
+
REFLECTION_KIND: Service type (app, functionapp, etc.)
|
38
|
+
SERVICE_VERSION: Version of the service (default: "1.0.0")
|
39
|
+
|
40
|
+
Logging Configuration:
|
41
|
+
LOGGER_ENABLE_CONSOLE: Enable console logging (default: "true")
|
42
|
+
APPLICATIONINSIGHTS_CONNECTION_STRING: App Insights connection string
|
43
|
+
|
44
|
+
Identity Configuration:
|
45
|
+
IDENTITY_ENABLE_TOKEN_CACHE: Enable token caching (default: "true")
|
46
|
+
IDENTITY_ALLOW_UNENCRYPTED_STORAGE: Allow unencrypted token storage (default: "true")
|
47
|
+
|
48
|
+
Key Vault Configuration:
|
49
|
+
key_vault_uri: Primary Key Vault URL
|
50
|
+
head_key_vault_uri: Secondary Key Vault URL
|
51
|
+
KEYVAULT_ENABLE_SECRETS: Enable secrets client (default: "true")
|
52
|
+
KEYVAULT_ENABLE_KEYS: Enable keys client (default: "false")
|
53
|
+
KEYVAULT_ENABLE_CERTIFICATES: Enable certificates client (default: "false")
|
54
|
+
|
55
|
+
Examples:
|
56
|
+
Local Development:
|
57
|
+
Set REFLECTION_NAME and ensure .env file exists for local settings.
|
58
|
+
|
59
|
+
Azure Function App:
|
60
|
+
Set REFLECTION_KIND="functionapp" and REFLECTION_NAME to your function app name.
|
61
|
+
|
62
|
+
Web Application:
|
63
|
+
Set REFLECTION_KIND="app" (or leave default) and configure App Insights.
|
64
|
+
"""
|
65
|
+
|
66
|
+
import os
|
67
|
+
from typing import Any, Dict, Optional
|
68
|
+
|
69
|
+
from azpaddypy.mgmt.identity import create_azure_identity
|
70
|
+
from azpaddypy.mgmt.local_env_manager import create_local_env_manager
|
71
|
+
from azpaddypy.mgmt.logging import create_app_logger, create_function_logger
|
72
|
+
from azpaddypy.resources.keyvault import create_azure_keyvault
|
73
|
+
|
74
|
+
# =============================================================================
|
75
|
+
# SERVICE CONFIGURATION
|
76
|
+
# =============================================================================
|
77
|
+
|
78
|
+
def _get_service_configuration() -> tuple[str, str, str]:
|
79
|
+
"""Get service configuration from environment variables.
|
80
|
+
|
81
|
+
Returns:
|
82
|
+
A tuple containing (service_name, service_version, service_kind).
|
83
|
+
|
84
|
+
Note:
|
85
|
+
REFLECTION_KIND has commas replaced with hyphens for compatibility.
|
86
|
+
"""
|
87
|
+
reflection_name = os.getenv("REFLECTION_NAME")
|
88
|
+
reflection_kind = os.getenv("REFLECTION_KIND", "").replace(",", "-")
|
89
|
+
service_name = reflection_name or str(__name__)
|
90
|
+
service_version = os.getenv("SERVICE_VERSION", "1.0.0")
|
91
|
+
|
92
|
+
return service_name, service_version, reflection_kind
|
93
|
+
|
94
|
+
|
95
|
+
SERVICE_NAME, SERVICE_VERSION, REFLECTION_KIND = _get_service_configuration()
|
96
|
+
|
97
|
+
# =============================================================================
|
98
|
+
# DOCKER ENVIRONMENT DETECTION
|
99
|
+
# =============================================================================
|
100
|
+
|
101
|
+
def is_running_in_docker() -> bool:
|
102
|
+
"""Check if the current process is running inside a Docker container.
|
103
|
+
|
104
|
+
This function uses multiple detection methods to reliably identify
|
105
|
+
Docker environments across different container runtimes and orchestrators.
|
106
|
+
|
107
|
+
Returns:
|
108
|
+
True if running in Docker/container, False otherwise.
|
109
|
+
|
110
|
+
Detection Methods:
|
111
|
+
1. Check for /.dockerenv file (standard Docker indicator)
|
112
|
+
2. Check /proc/1/cgroup for container-specific entries
|
113
|
+
3. Handles various container runtimes (Docker, Kubernetes, etc.)
|
114
|
+
"""
|
115
|
+
# Method 1: Check for Docker environment file
|
116
|
+
if os.path.exists('/.dockerenv'):
|
117
|
+
return True
|
118
|
+
|
119
|
+
# Method 2: Check process control groups for container indicators
|
120
|
+
try:
|
121
|
+
with open('/proc/1/cgroup', 'rt', encoding='utf-8') as f:
|
122
|
+
cgroup_content = f.read()
|
123
|
+
return any(indicator in cgroup_content
|
124
|
+
for indicator in ['docker', 'kubepods', 'containerd'])
|
125
|
+
except (FileNotFoundError, PermissionError, OSError):
|
126
|
+
# /proc filesystem not available or accessible (e.g., Windows, macOS)
|
127
|
+
pass
|
128
|
+
|
129
|
+
return False
|
130
|
+
|
131
|
+
|
132
|
+
RUNNING_IN_DOCKER = is_running_in_docker()
|
133
|
+
print(f"is_running_in_docker: {RUNNING_IN_DOCKER}")
|
134
|
+
|
135
|
+
# =============================================================================
|
136
|
+
# LOCAL DEVELOPMENT CONFIGURATION
|
137
|
+
# =============================================================================
|
138
|
+
|
139
|
+
def _get_local_settings() -> Dict[str, str]:
|
140
|
+
"""Get local development settings based on environment.
|
141
|
+
|
142
|
+
Returns:
|
143
|
+
Dictionary of local development settings appropriate for the environment.
|
144
|
+
|
145
|
+
Note:
|
146
|
+
Docker environments get Azure service principal settings,
|
147
|
+
while local environments get Azure Storage Emulator settings.
|
148
|
+
"""
|
149
|
+
if RUNNING_IN_DOCKER:
|
150
|
+
return {
|
151
|
+
"AZURE_CLIENT_ID": "aa73da4a-2888-4cb7-896e-5d51125f11f0",
|
152
|
+
"AZURE_TENANT_ID": "e5590d5d-336c-4cf5-b0ac-b79a598ec797",
|
153
|
+
"AZURE_CLIENT_SECRET": "IQ08Q~4uCfc4B~p2F95D2737GzYvvrtIjursFbCf"
|
154
|
+
}
|
155
|
+
else:
|
156
|
+
return {
|
157
|
+
"AzureWebJobsStorage": "UseDevelopmentStorage=true",
|
158
|
+
"AzureWebJobsDashboard": "UseDevelopmentStorage=true",
|
159
|
+
"input_queue_connection__queueServiceUri": "UseDevelopmentStorage=true",
|
160
|
+
"AzureWebJobsStorage__accountName": "UseDevelopmentStorage=true",
|
161
|
+
"AzureWebJobsStorage__blobServiceUri": "UseDevelopmentStorage=true",
|
162
|
+
}
|
163
|
+
|
164
|
+
|
165
|
+
# Initialize local environment manager
|
166
|
+
local_env_manager = create_local_env_manager(
|
167
|
+
file_path=".env",
|
168
|
+
settings=_get_local_settings(),
|
169
|
+
override_json=True,
|
170
|
+
override_dotenv=True,
|
171
|
+
override_settings=True,
|
172
|
+
)
|
173
|
+
|
174
|
+
# =============================================================================
|
175
|
+
# LOGGING CONFIGURATION
|
176
|
+
# =============================================================================
|
177
|
+
|
178
|
+
def _get_logging_configuration() -> tuple[bool, Optional[str], Dict[str, Dict[str, bool]]]:
|
179
|
+
"""Get logging configuration from environment variables.
|
180
|
+
|
181
|
+
Returns:
|
182
|
+
A tuple containing (console_enabled, connection_string, instrumentation_options).
|
183
|
+
"""
|
184
|
+
console_enabled = os.getenv("LOGGER_ENABLE_CONSOLE", "true").lower() == "true"
|
185
|
+
connection_string = os.getenv("APPLICATIONINSIGHTS_CONNECTION_STRING")
|
186
|
+
|
187
|
+
instrumentation_options = {
|
188
|
+
"azure_sdk": {"enabled": True},
|
189
|
+
"django": {"enabled": False},
|
190
|
+
"fastapi": {"enabled": False},
|
191
|
+
"flask": {"enabled": True},
|
192
|
+
"psycopg2": {"enabled": True},
|
193
|
+
"requests": {"enabled": True},
|
194
|
+
"urllib": {"enabled": True},
|
195
|
+
"urllib3": {"enabled": True},
|
196
|
+
}
|
197
|
+
|
198
|
+
return console_enabled, connection_string, instrumentation_options
|
199
|
+
|
200
|
+
|
201
|
+
LOGGER_ENABLE_CONSOLE, LOGGER_CONNECTION_STRING, LOGGER_INSTRUMENTATION_OPTIONS = _get_logging_configuration()
|
202
|
+
|
203
|
+
# =============================================================================
|
204
|
+
# IDENTITY CONFIGURATION
|
205
|
+
# =============================================================================
|
206
|
+
|
207
|
+
def _get_identity_configuration() -> tuple[bool, bool, Optional[Dict[str, Any]], Optional[str]]:
|
208
|
+
"""Get identity configuration from environment variables.
|
209
|
+
|
210
|
+
Returns:
|
211
|
+
A tuple containing (token_cache_enabled, unencrypted_storage_allowed,
|
212
|
+
custom_options, connection_string).
|
213
|
+
"""
|
214
|
+
token_cache_enabled = os.getenv("IDENTITY_ENABLE_TOKEN_CACHE", "true").lower() == "true"
|
215
|
+
unencrypted_storage_allowed = os.getenv("IDENTITY_ALLOW_UNENCRYPTED_STORAGE", "true").lower() == "true"
|
216
|
+
custom_options = None # Reserved for future custom credential configuration
|
217
|
+
connection_string = LOGGER_CONNECTION_STRING # Share with logger by default
|
218
|
+
|
219
|
+
return token_cache_enabled, unencrypted_storage_allowed, custom_options, connection_string
|
220
|
+
|
221
|
+
|
222
|
+
(IDENTITY_ENABLE_TOKEN_CACHE,
|
223
|
+
IDENTITY_ALLOW_UNENCRYPTED_STORAGE,
|
224
|
+
IDENTITY_CUSTOM_CREDENTIAL_OPTIONS,
|
225
|
+
IDENTITY_CONNECTION_STRING) = _get_identity_configuration()
|
226
|
+
|
227
|
+
# =============================================================================
|
228
|
+
# KEY VAULT CONFIGURATION
|
229
|
+
# =============================================================================
|
230
|
+
|
231
|
+
def _get_keyvault_configuration() -> tuple[Optional[str], Optional[str], bool, bool, bool, Optional[str]]:
|
232
|
+
"""Get Key Vault configuration from environment variables.
|
233
|
+
|
234
|
+
Returns:
|
235
|
+
A tuple containing (vault_url, head_vault_url, secrets_enabled,
|
236
|
+
keys_enabled, certificates_enabled, connection_string).
|
237
|
+
"""
|
238
|
+
vault_url = os.getenv("key_vault_uri")
|
239
|
+
head_vault_url = os.getenv("head_key_vault_uri")
|
240
|
+
secrets_enabled = os.getenv("KEYVAULT_ENABLE_SECRETS", "true").lower() == "true"
|
241
|
+
keys_enabled = os.getenv("KEYVAULT_ENABLE_KEYS", "false").lower() == "true"
|
242
|
+
certificates_enabled = os.getenv("KEYVAULT_ENABLE_CERTIFICATES", "false").lower() == "true"
|
243
|
+
connection_string = LOGGER_CONNECTION_STRING # Share with logger by default
|
244
|
+
|
245
|
+
return vault_url, head_vault_url, secrets_enabled, keys_enabled, certificates_enabled, connection_string
|
246
|
+
|
247
|
+
|
248
|
+
(KEYVAULT_URL,
|
249
|
+
HEAD_KEYVAULT_URL,
|
250
|
+
KEYVAULT_ENABLE_SECRETS,
|
251
|
+
KEYVAULT_ENABLE_KEYS,
|
252
|
+
KEYVAULT_ENABLE_CERTIFICATES,
|
253
|
+
KEYVAULT_CONNECTION_STRING) = _get_keyvault_configuration()
|
254
|
+
|
255
|
+
# =============================================================================
|
256
|
+
# SERVICE INITIALIZATION
|
257
|
+
# =============================================================================
|
258
|
+
|
259
|
+
def _create_logger():
|
260
|
+
"""Create and configure the appropriate logger instance.
|
261
|
+
|
262
|
+
Returns:
|
263
|
+
Configured AzureLogger instance (either app or function logger).
|
264
|
+
|
265
|
+
Note:
|
266
|
+
Logger type is determined by REFLECTION_KIND environment variable.
|
267
|
+
Function apps get specialized function loggers with additional context.
|
268
|
+
"""
|
269
|
+
if "functionapp" in REFLECTION_KIND:
|
270
|
+
logger_instance = create_function_logger(
|
271
|
+
function_app_name=SERVICE_NAME,
|
272
|
+
function_name=REFLECTION_KIND,
|
273
|
+
service_version=SERVICE_VERSION,
|
274
|
+
connection_string=LOGGER_CONNECTION_STRING,
|
275
|
+
instrumentation_options=LOGGER_INSTRUMENTATION_OPTIONS,
|
276
|
+
)
|
277
|
+
logger_instance.info(
|
278
|
+
f"Function logger initialized: {REFLECTION_KIND} {SERVICE_NAME}",
|
279
|
+
extra={"logger_type": "function", "function_name": REFLECTION_KIND}
|
280
|
+
)
|
281
|
+
else:
|
282
|
+
logger_instance = create_app_logger(
|
283
|
+
service_name=SERVICE_NAME,
|
284
|
+
service_version=SERVICE_VERSION,
|
285
|
+
connection_string=LOGGER_CONNECTION_STRING,
|
286
|
+
enable_console_logging=LOGGER_ENABLE_CONSOLE,
|
287
|
+
instrumentation_options=LOGGER_INSTRUMENTATION_OPTIONS,
|
288
|
+
)
|
289
|
+
logger_instance.info(
|
290
|
+
f"App logger initialized: {REFLECTION_KIND} {SERVICE_NAME}",
|
291
|
+
extra={"logger_type": "app", "service_kind": REFLECTION_KIND}
|
292
|
+
)
|
293
|
+
|
294
|
+
return logger_instance
|
295
|
+
|
296
|
+
|
297
|
+
def _create_identity_manager(logger_instance):
|
298
|
+
"""Create and configure the Azure identity manager.
|
299
|
+
|
300
|
+
Args:
|
301
|
+
logger_instance: Shared logger instance for identity operations.
|
302
|
+
|
303
|
+
Returns:
|
304
|
+
Configured AzureIdentity instance.
|
305
|
+
"""
|
306
|
+
return create_azure_identity(
|
307
|
+
service_name=SERVICE_NAME,
|
308
|
+
service_version=SERVICE_VERSION,
|
309
|
+
enable_token_cache=IDENTITY_ENABLE_TOKEN_CACHE,
|
310
|
+
allow_unencrypted_storage=IDENTITY_ALLOW_UNENCRYPTED_STORAGE,
|
311
|
+
custom_credential_options=IDENTITY_CUSTOM_CREDENTIAL_OPTIONS,
|
312
|
+
connection_string=IDENTITY_CONNECTION_STRING,
|
313
|
+
logger=logger_instance,
|
314
|
+
)
|
315
|
+
|
316
|
+
|
317
|
+
def _create_keyvault_client(vault_url: str, identity_instance, logger_instance):
|
318
|
+
"""Create a Key Vault client for the specified vault.
|
319
|
+
|
320
|
+
Args:
|
321
|
+
vault_url: Azure Key Vault URL.
|
322
|
+
identity_instance: Shared identity manager.
|
323
|
+
logger_instance: Shared logger instance.
|
324
|
+
|
325
|
+
Returns:
|
326
|
+
Configured AzureKeyVault instance or None if creation fails.
|
327
|
+
"""
|
328
|
+
if not vault_url:
|
329
|
+
return None
|
330
|
+
|
331
|
+
return create_azure_keyvault(
|
332
|
+
vault_url=vault_url,
|
333
|
+
azure_identity=identity_instance,
|
334
|
+
service_name=SERVICE_NAME,
|
335
|
+
service_version=SERVICE_VERSION,
|
336
|
+
logger=logger_instance,
|
337
|
+
connection_string=KEYVAULT_CONNECTION_STRING,
|
338
|
+
enable_secrets=KEYVAULT_ENABLE_SECRETS,
|
339
|
+
enable_keys=KEYVAULT_ENABLE_KEYS,
|
340
|
+
enable_certificates=KEYVAULT_ENABLE_CERTIFICATES,
|
341
|
+
)
|
342
|
+
|
343
|
+
|
344
|
+
# Initialize core services
|
345
|
+
logger = _create_logger()
|
346
|
+
identity = _create_identity_manager(logger)
|
347
|
+
|
348
|
+
# Initialize Key Vault clients (if URLs are configured)
|
349
|
+
keyvault = _create_keyvault_client(KEYVAULT_URL, identity, logger)
|
350
|
+
head_keyvault = _create_keyvault_client(HEAD_KEYVAULT_URL, identity, logger)
|
351
|
+
|
352
|
+
# =============================================================================
|
353
|
+
# CONFIGURATION VALIDATION & STARTUP LOGGING
|
354
|
+
# =============================================================================
|
355
|
+
|
356
|
+
def _validate_and_log_configuration():
|
357
|
+
"""Validate configuration and log startup information.
|
358
|
+
|
359
|
+
This function performs validation checks and logs important configuration
|
360
|
+
status information for debugging and monitoring purposes.
|
361
|
+
"""
|
362
|
+
# Validate critical configuration
|
363
|
+
if SERVICE_NAME == __name__:
|
364
|
+
logger.warning(
|
365
|
+
"SERVICE_NAME is using module name. Consider setting REFLECTION_NAME environment variable.",
|
366
|
+
extra={"configuration_issue": "service_name_not_set", "current_name": SERVICE_NAME}
|
367
|
+
)
|
368
|
+
|
369
|
+
# Log telemetry status
|
370
|
+
if not LOGGER_CONNECTION_STRING:
|
371
|
+
logger.info(
|
372
|
+
"No Application Insights connection string configured. Telemetry will be disabled.",
|
373
|
+
extra={"telemetry_status": "disabled"}
|
374
|
+
)
|
375
|
+
|
376
|
+
# Log Key Vault status
|
377
|
+
if not KEYVAULT_URL:
|
378
|
+
logger.info(
|
379
|
+
"No Key Vault URL configured. Key Vault operations will be disabled.",
|
380
|
+
extra={"keyvault_status": "disabled"}
|
381
|
+
)
|
382
|
+
|
383
|
+
if not HEAD_KEYVAULT_URL:
|
384
|
+
logger.info(
|
385
|
+
"No Head Key Vault URL configured. Head Key Vault operations will be disabled.",
|
386
|
+
extra={"head_keyvault_status": "disabled"}
|
387
|
+
)
|
388
|
+
|
389
|
+
# Log successful initialization with comprehensive metadata
|
390
|
+
logger.info(
|
391
|
+
f"Management configuration initialized for service '{SERVICE_NAME}' v{SERVICE_VERSION}",
|
392
|
+
extra={
|
393
|
+
"service_name": SERVICE_NAME,
|
394
|
+
"service_version": SERVICE_VERSION,
|
395
|
+
"console_logging": LOGGER_ENABLE_CONSOLE,
|
396
|
+
"token_cache_enabled": IDENTITY_ENABLE_TOKEN_CACHE,
|
397
|
+
"telemetry_enabled": bool(LOGGER_CONNECTION_STRING),
|
398
|
+
"keyvault_enabled": bool(KEYVAULT_URL),
|
399
|
+
"head_keyvault_enabled": bool(HEAD_KEYVAULT_URL),
|
400
|
+
"keyvault_secrets_enabled": KEYVAULT_ENABLE_SECRETS if KEYVAULT_URL else False,
|
401
|
+
"keyvault_keys_enabled": KEYVAULT_ENABLE_KEYS if KEYVAULT_URL else False,
|
402
|
+
"keyvault_certificates_enabled": KEYVAULT_ENABLE_CERTIFICATES if KEYVAULT_URL else False,
|
403
|
+
"running_in_docker": RUNNING_IN_DOCKER,
|
404
|
+
}
|
405
|
+
)
|
406
|
+
|
407
|
+
|
408
|
+
# Perform validation and startup logging
|
409
|
+
_validate_and_log_configuration()
|
410
|
+
|
411
|
+
# =============================================================================
|
412
|
+
# MODULE EXPORTS
|
413
|
+
# =============================================================================
|
414
|
+
|
415
|
+
# Export primary service instances for application use
|
416
|
+
__all__ = ["logger", "local_env_manager", "identity", "keyvault", "head_keyvault"]
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: cwyodmodules
|
3
|
-
Version: 0.3.
|
3
|
+
Version: 0.3.78
|
4
4
|
Summary: Add your description here
|
5
5
|
Author-email: Patrik <patrikhartl@gmail.com>
|
6
6
|
Classifier: Operating System :: OS Independent
|
@@ -40,7 +40,7 @@ Requires-Dist: azure-search-documents==11.6.0b4
|
|
40
40
|
Requires-Dist: semantic-kernel==1.3.0
|
41
41
|
Requires-Dist: pydantic==2.7.4
|
42
42
|
Requires-Dist: pandas>=2.2.3
|
43
|
-
Requires-Dist: azpaddypy>=0.5.
|
43
|
+
Requires-Dist: azpaddypy>=0.5.6
|
44
44
|
Dynamic: license-file
|
45
45
|
|
46
46
|
# paddypy
|
@@ -3,7 +3,7 @@ name = "cwyodmodules"
|
|
3
3
|
authors = [
|
4
4
|
{ name="Patrik", email="patrikhartl@gmail.com" },
|
5
5
|
]
|
6
|
-
version = '0.3.
|
6
|
+
version = '0.3.78'
|
7
7
|
description = "Add your description here"
|
8
8
|
readme = "README.md"
|
9
9
|
requires-python = "==3.11.11"
|
@@ -44,7 +44,7 @@ dependencies = [
|
|
44
44
|
"semantic-kernel==1.3.0",
|
45
45
|
"pydantic==2.7.4",
|
46
46
|
"pandas>=2.2.3",
|
47
|
-
"azpaddypy>=0.5.
|
47
|
+
"azpaddypy>=0.5.6",
|
48
48
|
]
|
49
49
|
|
50
50
|
[tool.uv]
|
@@ -1,246 +0,0 @@
|
|
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("REFLECTION_NAME") or str("cwyodmodules")
|
30
|
-
SERVICE_VERSION = os.getenv("SERVICE_VERSION", "1.0.0")
|
31
|
-
|
32
|
-
def is_running_in_docker():
|
33
|
-
"""
|
34
|
-
Checks if the current process is running inside a Docker container.
|
35
|
-
|
36
|
-
Returns:
|
37
|
-
bool: True if running in Docker, False otherwise.
|
38
|
-
"""
|
39
|
-
# Method 1: Check for /.dockerenv file
|
40
|
-
if os.path.exists('/.dockerenv'):
|
41
|
-
return True
|
42
|
-
|
43
|
-
# Method 2: Check cgroup for "docker"
|
44
|
-
try:
|
45
|
-
with open('/proc/1/cgroup', 'rt') as f:
|
46
|
-
cgroup_content = f.read()
|
47
|
-
if 'docker' in cgroup_content or 'kubepods' in cgroup_content:
|
48
|
-
return True
|
49
|
-
except FileNotFoundError:
|
50
|
-
# /proc/1/cgroup does not exist, not a Linux-like environment
|
51
|
-
pass
|
52
|
-
except Exception:
|
53
|
-
# Handle other potential exceptions, e.g., permissions
|
54
|
-
pass
|
55
|
-
|
56
|
-
return False
|
57
|
-
|
58
|
-
running_in_docker = is_running_in_docker()
|
59
|
-
print("is_running_in_docker: " + str(running_in_docker))
|
60
|
-
|
61
|
-
|
62
|
-
# =============================================================================
|
63
|
-
# LOGGING CONFIGURATION
|
64
|
-
# =============================================================================
|
65
|
-
|
66
|
-
# Enable console output (useful for local development)
|
67
|
-
LOGGER_ENABLE_CONSOLE = os.getenv("LOGGER_ENABLE_CONSOLE", "true").lower() == "true"
|
68
|
-
|
69
|
-
# Application Insights connection string (optional, will use environment variable if not set)
|
70
|
-
LOGGER_CONNECTION_STRING = os.getenv("APPLICATIONINSIGHTS_CONNECTION_STRING")
|
71
|
-
|
72
|
-
# Local development settings
|
73
|
-
if running_in_docker:
|
74
|
-
LOCAL_SETTINGS = {
|
75
|
-
"AZURE_CLIENT_ID": "***",
|
76
|
-
"AZURE_TENANT_ID": "***",
|
77
|
-
"AZURE_CLIENT_SECRET": "***"
|
78
|
-
}
|
79
|
-
else:
|
80
|
-
LOCAL_SETTINGS = {
|
81
|
-
"AzureWebJobsStorage": "UseDevelopmentStorage=true",
|
82
|
-
"AzureWebJobsDashboard": "UseDevelopmentStorage=true",
|
83
|
-
"input_queue_connection__queueServiceUri": "UseDevelopmentStorage=true",
|
84
|
-
"AzureWebJobsStorage__accountName": "UseDevelopmentStorage=true",
|
85
|
-
"AzureWebJobsStorage__blobServiceUri": "UseDevelopmentStorage=true",
|
86
|
-
}
|
87
|
-
|
88
|
-
# Configure which Azure SDK components to instrument
|
89
|
-
LOGGER_INSTRUMENTATION_OPTIONS = {
|
90
|
-
"azure_sdk": {"enabled": True},
|
91
|
-
"django": {"enabled": False},
|
92
|
-
"fastapi": {"enabled": False},
|
93
|
-
"flask": {"enabled": True},
|
94
|
-
"psycopg2": {"enabled": True},
|
95
|
-
"requests": {"enabled": True},
|
96
|
-
"urllib": {"enabled": True},
|
97
|
-
"urllib3": {"enabled": True},
|
98
|
-
}
|
99
|
-
|
100
|
-
# =============================================================================
|
101
|
-
# IDENTITY CONFIGURATION
|
102
|
-
# =============================================================================
|
103
|
-
|
104
|
-
# Token caching settings
|
105
|
-
IDENTITY_ENABLE_TOKEN_CACHE = os.getenv("IDENTITY_ENABLE_TOKEN_CACHE", "true").lower() == "true"
|
106
|
-
IDENTITY_ALLOW_UNENCRYPTED_STORAGE = os.getenv("IDENTITY_ALLOW_UNENCRYPTED_STORAGE", "true").lower() == "true"
|
107
|
-
|
108
|
-
# Custom credential options (None means use defaults)
|
109
|
-
IDENTITY_CUSTOM_CREDENTIAL_OPTIONS: Optional[Dict[str, Any]] = None
|
110
|
-
|
111
|
-
# Connection string for identity logging (uses same as logger by default)
|
112
|
-
IDENTITY_CONNECTION_STRING = LOGGER_CONNECTION_STRING
|
113
|
-
|
114
|
-
# =============================================================================
|
115
|
-
# KEYVAULT CONFIGURATION
|
116
|
-
# =============================================================================
|
117
|
-
|
118
|
-
# Enable specific Key Vault client types
|
119
|
-
KEYVAULT_ENABLE_SECRETS = os.getenv("KEYVAULT_ENABLE_SECRETS", "true").lower() == "true"
|
120
|
-
KEYVAULT_ENABLE_KEYS = os.getenv("KEYVAULT_ENABLE_KEYS", "false").lower() == "true"
|
121
|
-
KEYVAULT_ENABLE_CERTIFICATES = os.getenv("KEYVAULT_ENABLE_CERTIFICATES", "false").lower() == "true"
|
122
|
-
|
123
|
-
# Connection string for keyvault logging (uses same as logger by default)
|
124
|
-
KEYVAULT_CONNECTION_STRING = LOGGER_CONNECTION_STRING
|
125
|
-
|
126
|
-
# =============================================================================
|
127
|
-
# INITIALIZE SERVICES
|
128
|
-
# =============================================================================
|
129
|
-
|
130
|
-
# Create logger instance
|
131
|
-
if "functionapp" in os.getenv("REFLECTION_KIND", "app"):
|
132
|
-
logger = create_function_logger(
|
133
|
-
function_app_name=os.getenv("REFLECTION_NAME", "app"),
|
134
|
-
function_name=os.getenv("REFLECTION_KIND", "app"),
|
135
|
-
service_version=SERVICE_VERSION,
|
136
|
-
connection_string=LOGGER_CONNECTION_STRING,
|
137
|
-
instrumentation_options=LOGGER_INSTRUMENTATION_OPTIONS,
|
138
|
-
)
|
139
|
-
logger.info("Function logger initialized")
|
140
|
-
else:
|
141
|
-
logger = create_app_logger(
|
142
|
-
service_name=SERVICE_NAME,
|
143
|
-
service_version=SERVICE_VERSION,
|
144
|
-
connection_string=LOGGER_CONNECTION_STRING,
|
145
|
-
enable_console_logging=LOGGER_ENABLE_CONSOLE,
|
146
|
-
instrumentation_options=LOGGER_INSTRUMENTATION_OPTIONS,
|
147
|
-
)
|
148
|
-
logger.info("App logger initialized")
|
149
|
-
|
150
|
-
# Create identity instance with shared logger
|
151
|
-
identity = create_azure_identity(
|
152
|
-
service_name=SERVICE_NAME,
|
153
|
-
service_version=SERVICE_VERSION,
|
154
|
-
enable_token_cache=IDENTITY_ENABLE_TOKEN_CACHE,
|
155
|
-
allow_unencrypted_storage=IDENTITY_ALLOW_UNENCRYPTED_STORAGE,
|
156
|
-
custom_credential_options=IDENTITY_CUSTOM_CREDENTIAL_OPTIONS,
|
157
|
-
connection_string=IDENTITY_CONNECTION_STRING,
|
158
|
-
logger=logger,
|
159
|
-
)
|
160
|
-
|
161
|
-
# Azure Key Vault URL (required for Key Vault operations)
|
162
|
-
KEYVAULT_URL = os.getenv("key_vault_uri")
|
163
|
-
HEAD_KEYVAULT_URL = os.getenv("head_key_vault_uri")
|
164
|
-
|
165
|
-
# Create keyvault instance with shared logger and identity (if URL is configured)
|
166
|
-
keyvault = None
|
167
|
-
if KEYVAULT_URL:
|
168
|
-
keyvault = create_azure_keyvault(
|
169
|
-
vault_url=KEYVAULT_URL,
|
170
|
-
azure_identity=identity,
|
171
|
-
service_name=SERVICE_NAME,
|
172
|
-
service_version=SERVICE_VERSION,
|
173
|
-
logger=logger,
|
174
|
-
connection_string=KEYVAULT_CONNECTION_STRING,
|
175
|
-
enable_secrets=KEYVAULT_ENABLE_SECRETS,
|
176
|
-
enable_keys=KEYVAULT_ENABLE_KEYS,
|
177
|
-
enable_certificates=KEYVAULT_ENABLE_CERTIFICATES,
|
178
|
-
)
|
179
|
-
|
180
|
-
head_keyvault = None
|
181
|
-
if HEAD_KEYVAULT_URL:
|
182
|
-
head_keyvault = create_azure_keyvault(
|
183
|
-
vault_url=HEAD_KEYVAULT_URL,
|
184
|
-
azure_identity=identity,
|
185
|
-
service_name=SERVICE_NAME,
|
186
|
-
service_version=SERVICE_VERSION,
|
187
|
-
logger=logger,
|
188
|
-
connection_string=KEYVAULT_CONNECTION_STRING,
|
189
|
-
enable_secrets=KEYVAULT_ENABLE_SECRETS,
|
190
|
-
enable_keys=KEYVAULT_ENABLE_KEYS,
|
191
|
-
enable_certificates=KEYVAULT_ENABLE_CERTIFICATES,
|
192
|
-
)
|
193
|
-
|
194
|
-
# =============================================================================
|
195
|
-
# VALIDATION & STARTUP
|
196
|
-
# =============================================================================
|
197
|
-
|
198
|
-
# Validate critical configuration
|
199
|
-
if SERVICE_NAME == __name__:
|
200
|
-
logger.warning(
|
201
|
-
"SERVICE_NAME is not configured. Please set SERVICE_NAME environment variable or update this template.",
|
202
|
-
extra={"configuration_issue": "service_name_not_set"}
|
203
|
-
)
|
204
|
-
|
205
|
-
if not LOGGER_CONNECTION_STRING:
|
206
|
-
logger.info(
|
207
|
-
"No Application Insights connection string configured. Telemetry will be disabled.",
|
208
|
-
extra={"telemetry_status": "disabled"}
|
209
|
-
)
|
210
|
-
|
211
|
-
if not KEYVAULT_URL:
|
212
|
-
logger.info(
|
213
|
-
"No Key Vault URL configured. Key Vault operations will be disabled.",
|
214
|
-
extra={"keyvault_status": "disabled"}
|
215
|
-
)
|
216
|
-
|
217
|
-
if not HEAD_KEYVAULT_URL:
|
218
|
-
logger.info(
|
219
|
-
"No Head Key Vault URL configured. Head Key Vault operations will be disabled.",
|
220
|
-
extra={"head_keyvault_status": "disabled"}
|
221
|
-
)
|
222
|
-
|
223
|
-
# Log successful initialization
|
224
|
-
logger.info(
|
225
|
-
f"Management configuration initialized for service '{SERVICE_NAME}' v{SERVICE_VERSION}",
|
226
|
-
extra={
|
227
|
-
"service_name": SERVICE_NAME,
|
228
|
-
"service_version": SERVICE_VERSION,
|
229
|
-
"console_logging": LOGGER_ENABLE_CONSOLE,
|
230
|
-
"token_cache_enabled": IDENTITY_ENABLE_TOKEN_CACHE,
|
231
|
-
"telemetry_enabled": bool(LOGGER_CONNECTION_STRING),
|
232
|
-
"keyvault_enabled": bool(KEYVAULT_URL),
|
233
|
-
"head_keyvault_enabled": bool(HEAD_KEYVAULT_URL),
|
234
|
-
"keyvault_secrets_enabled": KEYVAULT_ENABLE_SECRETS if KEYVAULT_URL else False,
|
235
|
-
"keyvault_keys_enabled": KEYVAULT_ENABLE_KEYS if KEYVAULT_URL else False,
|
236
|
-
"keyvault_certificates_enabled": KEYVAULT_ENABLE_CERTIFICATES if KEYVAULT_URL else False,
|
237
|
-
"running_in_docker": running_in_docker,
|
238
|
-
}
|
239
|
-
)
|
240
|
-
|
241
|
-
# =============================================================================
|
242
|
-
# EXPORTS
|
243
|
-
# =============================================================================
|
244
|
-
|
245
|
-
# Export logger, identity, and keyvault for use in applications
|
246
|
-
__all__ = ["logger", "local_env_manager", "identity", "keyvault", "head_keyvault"]
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{cwyodmodules-0.3.76 → cwyodmodules-0.3.78}/cwyodmodules/batch/utilities/chat_history/auth_utils.py
RENAMED
File without changes
|
{cwyodmodules-0.3.76 → cwyodmodules-0.3.78}/cwyodmodules/batch/utilities/chat_history/cosmosdb.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{cwyodmodules-0.3.76 → cwyodmodules-0.3.78}/cwyodmodules/batch/utilities/chat_history/sample_user.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
{cwyodmodules-0.3.76 → cwyodmodules-0.3.78}/cwyodmodules/batch/utilities/common/source_document.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{cwyodmodules-0.3.76 → cwyodmodules-0.3.78}/cwyodmodules/batch/utilities/document_chunking/layout.py
RENAMED
File without changes
|
{cwyodmodules-0.3.76 → cwyodmodules-0.3.78}/cwyodmodules/batch/utilities/document_chunking/page.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{cwyodmodules-0.3.76 → cwyodmodules-0.3.78}/cwyodmodules/batch/utilities/document_loading/layout.py
RENAMED
File without changes
|
{cwyodmodules-0.3.76 → cwyodmodules-0.3.78}/cwyodmodules/batch/utilities/document_loading/read.py
RENAMED
File without changes
|
File without changes
|
{cwyodmodules-0.3.76 → cwyodmodules-0.3.78}/cwyodmodules/batch/utilities/document_loading/web.py
RENAMED
File without changes
|
File without changes
|
{cwyodmodules-0.3.76 → cwyodmodules-0.3.78}/cwyodmodules/batch/utilities/helpers/__init__.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{cwyodmodules-0.3.76 → cwyodmodules-0.3.78}/cwyodmodules/batch/utilities/helpers/config/default.json
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{cwyodmodules-0.3.76 → cwyodmodules-0.3.78}/cwyodmodules/batch/utilities/helpers/env_helper.py
RENAMED
File without changes
|
{cwyodmodules-0.3.76 → cwyodmodules-0.3.78}/cwyodmodules/batch/utilities/helpers/lightrag_helper.py
RENAMED
File without changes
|
{cwyodmodules-0.3.76 → cwyodmodules-0.3.78}/cwyodmodules/batch/utilities/helpers/llm_helper.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{cwyodmodules-0.3.76 → cwyodmodules-0.3.78}/cwyodmodules/batch/utilities/orchestrator/__init__.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{cwyodmodules-0.3.76 → cwyodmodules-0.3.78}/cwyodmodules/batch/utilities/orchestrator/prompt_flow.py
RENAMED
File without changes
|
File without changes
|
{cwyodmodules-0.3.76 → cwyodmodules-0.3.78}/cwyodmodules/batch/utilities/orchestrator/strategies.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
{cwyodmodules-0.3.76 → cwyodmodules-0.3.78}/cwyodmodules/batch/utilities/parser/parser_base.py
RENAMED
File without changes
|
{cwyodmodules-0.3.76 → cwyodmodules-0.3.78}/cwyodmodules/batch/utilities/plugins/chat_plugin.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{cwyodmodules-0.3.76 → cwyodmodules-0.3.78}/cwyodmodules/batch/utilities/tools/post_prompt_tool.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|