Configuration
Configuration management for QLAM Core.
Config management using generated models
This module wraps the Pydantic-generated config_models to provide
convenience methods for context selection, plugin filtering, and persistence.
Example::
from qlam_core.config.config import Config
config = Config.load()
print(config.current_context.name)
config.save()
Config
Config(data: QshClientConfig, context_name: str | None = None)
Config wrapper that provides additional methods for the generated models.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
QshClientConfig
|
Parsed config data model. |
required |
context_name
|
str | None
|
Optional override for the active context name. |
None
|
Source code in qlam_core/config/config.py
40 41 42 43 44 | |
context_name
property
context_name: str
Get the currently active context name.
Returns:
| Type | Description |
|---|---|
str
|
Active context name. |
context_names
property
context_names: list[str]
Get the names of all configured contexts.
Returns:
| Type | Description |
|---|---|
list[str]
|
List of context name strings. |
contexts
property
contexts: list[Context]
current_context
property
current_context: Context
Get the currently active context.
Returns:
| Type | Description |
|---|---|
Context
|
|
qpu
property
qpu: str
Get QPU from current context, with env override.
Returns:
| Type | Description |
|---|---|
str
|
QPU identifier string. |
get_auth_providers
get_auth_providers() -> List | None
Get list of auth providers for the current context.
Returns:
| Type | Description |
|---|---|
List | None
|
List of provider configs or None. |
Source code in qlam_core/config/config.py
256 257 258 259 260 261 | |
get_config_path
classmethod
get_config_path() -> Path
Get the path to the config file.
Returns:
| Type | Description |
|---|---|
Path
|
Absolute path to config JSON file. |
Source code in qlam_core/config/config.py
122 123 124 125 126 127 128 | |
get_enabled_plugins
get_enabled_plugins(all_plugin_names: set[str]) -> set[str]
Get the set of plugin names that should be enabled.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
all_plugin_names
|
set[str]
|
All discovered plugin names. |
required |
Returns:
| Type | Description |
|---|---|
set[str]
|
Enabled plugin names after filters. |
Source code in qlam_core/config/config.py
237 238 239 240 241 242 243 | |
get_plugin_config
get_plugin_config(plugin_name: str) -> PluginConfig | None
Get configuration for a specific plugin.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
plugin_name
|
str
|
Plugin name key. |
required |
Returns:
| Type | Description |
|---|---|
PluginConfig | None
|
|
Source code in qlam_core/config/config.py
245 246 247 248 249 250 251 252 253 254 | |
load
classmethod
load(context_name: str | None = None) -> Config
Load config from config file with optional context selection.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
context_name
|
str | None
|
Optional context name to activate. |
None
|
Returns:
| Type | Description |
|---|---|
Config
|
Loaded |
Source code in qlam_core/config/config.py
130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 | |
save
save() -> None
Save config to config file with proper permissions.
Returns:
| Type | Description |
|---|---|
None
|
None |
Source code in qlam_core/config/config.py
263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 | |
set_context
set_context(name: str) -> None
Set the active context name (call save() to persist).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Context name to activate. |
required |
Source code in qlam_core/config/config.py
115 116 117 118 119 120 | |
should_load_plugin
should_load_plugin(plugin_name: str) -> bool
Determine if a plugin should be loaded based on include/exclude settings.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
plugin_name
|
str
|
The plugin name to test. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if the plugin should be enabled. Logic: 1. If include_plugins is present and non-empty, only those plugins are enabled 2. If exclude_plugins is present, remove those names from the enabled set 3. If both are present, apply in order: include first, then exclude |
Source code in qlam_core/config/config.py
210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 | |
Context
Bases: BaseModel
flowchart TD
qlam_core.config.config.Context[Context]
click qlam_core.config.config.Context href "" "qlam_core.config.config.Context"
A QSH Client context configuration
auth_providers
class-attribute
instance-attribute
auth_providers: list[Annotated[BasicAuthProvider | OauthAuthProvider | TokenAuthProvider, Field(discriminator='provider')]] | None = None
List of authentication providers available in this context
name
instance-attribute
name: str
Unique name for this context
plugins
class-attribute
instance-attribute
plugins: dict[str, PluginConfig] | None = None
Per-plugin configuration overrides
qpu
instance-attribute
qpu: str
Default QPU for this context