File tree Expand file tree Collapse file tree 3 files changed +38
-4
lines changed Expand file tree Collapse file tree 3 files changed +38
-4
lines changed Original file line number Diff line number Diff line change @@ -117,13 +117,13 @@ Factory for creating and configuring the Atlan client using application settings
117117```python
118118import logging
119119from pyatlan.client.atlan import AtlanClient
120- from settings import Settings
120+ from settings import get_settings
121121
122122logger = logging.getLogger(__name__)
123123
124124def get_atlan_client() -> AtlanClient:
125125 """Create an Atlan client instance using settings loaded from environment."""
126- settings = Settings ()
126+ settings = get_settings ()
127127 try:
128128 client = AtlanClient(
129129 base_url=settings.ATLAN_BASE_URL, api_key=settings.ATLAN_API_KEY
@@ -134,6 +134,22 @@ def get_atlan_client() -> AtlanClient:
134134 except Exception as e:
135135 logger.error(f"Error creating Atlan client: {e}")
136136 raise Exception(f"Error creating Atlan client: {e}")
137+
138+ _settings: Optional[Settings] = None
139+
140+
141+ def get_settings() -> Settings:
142+ """
143+ Get the singleton Settings instance.
144+ Loads settings once from environment/file and reuses the instance.
145+
146+ Returns:
147+ Settings: The singleton settings instance
148+ """
149+ global _settings
150+ if _settings is None:
151+ _settings = Settings()
152+ return _settings
137153```
138154
139155### tools/ Directory
Original file line number Diff line number Diff line change 44from typing import Optional
55
66from pyatlan .client .atlan import AtlanClient
7- from settings import Settings
7+ from settings import get_settings
88
99logger = logging .getLogger (__name__ )
1010
@@ -24,7 +24,7 @@ def get_atlan_client() -> AtlanClient:
2424 global _client_instance
2525
2626 if _client_instance is None :
27- settings = Settings ()
27+ settings = get_settings ()
2828 try :
2929 _client_instance = AtlanClient (
3030 base_url = settings .ATLAN_BASE_URL , api_key = settings .ATLAN_API_KEY
Original file line number Diff line number Diff line change 11"""Configuration settings for the application."""
22
3+ from typing import Optional
34from pydantic_settings import BaseSettings
45from version import __version__ as MCP_VERSION
56
@@ -29,3 +30,20 @@ class Config:
2930 extra = "allow"
3031 # Allow case-insensitive environment variables
3132 case_sensitive = False
33+
34+
35+ _settings : Optional [Settings ] = None
36+
37+
38+ def get_settings () -> Settings :
39+ """
40+ Get the singleton Settings instance.
41+ Loads settings once from environment/file and reuses the instance.
42+
43+ Returns:
44+ Settings: The singleton settings instance
45+ """
46+ global _settings
47+ if _settings is None :
48+ _settings = Settings ()
49+ return _settings
You can’t perform that action at this time.
0 commit comments