convoke.configs
Tools for parsing configuration values from the environment
convoke.configs.env_field
Define a field that pulls config values from the environment.
Fields with missing defaults will be assumed to be required, and if missing will produce an error.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
default |
Any
|
the default value to use, if any, of the expected type. If this is omitted, the field will be required. |
MISSING
|
doc |
str
|
a docstring describing the use of the configuration value, used in generating .env files |
''
|
Source code in src/convoke/configs.py
184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 |
|
convoke.configs.Secret
Bases: str
A string value that should not be revealed in logs, tracebacks, etc.
Source code in src/convoke/configs.py
25 26 27 28 29 30 |
|
convoke.configs.BaseConfig
Base settings common to all configurations
Source code in src/convoke/configs.py
246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 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 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 |
|
as_bool(name, default=UNDEFINED)
Return the named configuration environment value as a boolean value.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
str
|
The name of the configuration value, as defined on this object or in the environment. |
required |
default |
Any
|
A default value, already a boolean. |
UNDEFINED
|
Source code in src/convoke/configs.py
361 362 363 364 365 366 367 |
|
as_bool_tuple(name, default=UNDEFINED)
Return the named configuration environment value as a tuple of boolean values.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
str
|
The name of the configuration value, as defined on this object or in the environment. |
required |
default |
Any
|
A default value, already a tuple of booleans. |
UNDEFINED
|
Source code in src/convoke/configs.py
369 370 371 372 373 374 375 |
|
as_float(name, default=UNDEFINED)
Return the named configuration environment value as a float.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
str
|
The name of the configuration value, as defined on this object or in the environment. |
required |
default |
Any
|
A default value, already a float. |
UNDEFINED
|
Source code in src/convoke/configs.py
393 394 395 396 397 398 399 |
|
as_float_tuple(name, default=UNDEFINED)
Return the named configuration environment value as a tuple of floats.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
str
|
The name of the configuration value, as defined on this object or in the environment. |
required |
default |
Any
|
A default value, already a tuple of floats. |
UNDEFINED
|
Source code in src/convoke/configs.py
401 402 403 404 405 406 407 |
|
as_int(name, default=UNDEFINED)
Return the named configuration environment value as an int.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
str
|
The name of the configuration value, as defined on this object or in the environment. |
required |
default |
Any
|
A default value, already an int. |
UNDEFINED
|
Source code in src/convoke/configs.py
377 378 379 380 381 382 383 |
|
as_int_tuple(name, default=UNDEFINED)
Return the named configuration environment value as a tuple of ints.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
str
|
The name of the configuration value, as defined on this object or in the environment. |
required |
default |
Any
|
A default value, already a tuple of ints. |
UNDEFINED
|
Source code in src/convoke/configs.py
385 386 387 388 389 390 391 |
|
as_object_import(name, default=UNDEFINED)
Return the named configuration environment value as an imported object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
str
|
The name of the configuration value, as defined on this object or in the environment. |
required |
default |
Any
|
A default value, already an object. |
UNDEFINED
|
Source code in src/convoke/configs.py
443 444 445 446 447 448 449 450 |
|
as_object_import_tuple(name, default=UNDEFINED)
Return the named configuration environment value as a tuple of imported objects.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
str
|
The name of the configuration value, as defined on this object or in the environment. |
required |
default |
Any
|
A default value, already a tuple of objects. |
UNDEFINED
|
Source code in src/convoke/configs.py
452 453 454 455 456 457 458 459 |
|
as_package_import(name, default=UNDEFINED)
Return the named configuration environment value as an imported module.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
str
|
The name of the configuration value, as defined on this object or in the environment. |
required |
default |
Any
|
A default value, already a module. |
UNDEFINED
|
Source code in src/convoke/configs.py
425 426 427 428 429 430 431 432 |
|
as_package_import_tuple(name, default=UNDEFINED)
Return the named configuration environment value as a tuple of imported modules.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
str
|
The name of the configuration value, as defined on this object or in the environment. |
required |
default |
Any
|
A default value, already a tuple of modules. |
UNDEFINED
|
Source code in src/convoke/configs.py
434 435 436 437 438 439 440 441 |
|
as_path(name, default=UNDEFINED)
Return the named configuration environment value as a Path.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
str
|
The name of the configuration value, as defined on this object or in the environment. |
required |
default |
Any
|
A default value, already a Path. |
UNDEFINED
|
Source code in src/convoke/configs.py
409 410 411 412 413 414 415 |
|
as_path_tuple(name, default=UNDEFINED)
Return the named configuration environment value as a tuple of Paths.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
str
|
The name of the configuration value, as defined on this object or in the environment. |
required |
default |
Any
|
A default value, already a tuple of Paths. |
UNDEFINED
|
Source code in src/convoke/configs.py
417 418 419 420 421 422 423 |
|
as_secret(name, default=UNDEFINED)
Return the named configuration environment value as a Secret string.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
str
|
The name of the configuration value, as defined on this object or in the environment. |
required |
default |
Any
|
A default value, already a Secret. |
UNDEFINED
|
Source code in src/convoke/configs.py
345 346 347 348 349 350 351 |
|
as_secret_tuple(name, default=UNDEFINED)
Return the named configuration environment value as a sequence of Secret strings.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
str
|
The name of the configuration value, as defined on this object or in the environment. |
required |
default |
Any
|
A default value, already a tuple of Secrets. |
UNDEFINED
|
Source code in src/convoke/configs.py
353 354 355 356 357 358 359 |
|
asdict(keys=())
Return a dictionary with the defined settings
Source code in src/convoke/configs.py
327 328 329 330 331 332 |
|
from_config(config)
classmethod
Derive an instance of this config class from another configuration.
This is really only useful if the passed configuration has overridden (non-environment-derived) values.
Source code in src/convoke/configs.py
254 255 256 257 258 259 260 261 262 263 264 |
|
gather_settings()
classmethod
Gather settings from all loaded configurations.
Source code in src/convoke/configs.py
266 267 268 269 270 271 272 273 274 275 276 277 278 279 |
|
get(name, default=UNDEFINED, caster=UNDEFINED)
Return the named configuration environment value, optionally casting it as specified.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
str
|
The name of the configuration value, as defined on this object or in the environment. |
required |
default |
Any
|
A default value, already the expected type. |
UNDEFINED
|
caster |
Type
|
A type to cast the string value to, if any. |
UNDEFINED
|
Source code in src/convoke/configs.py
306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 |
|
get_tuple(name, default=UNDEFINED, caster=tuple[str])
Return the named configuration environment value as a sequence, optionally casting internal values as specified.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
str
|
The name of the configuration value, as defined on this object or in the environment. |
required |
default |
Any
|
A default value, already the expected type. |
UNDEFINED
|
caster |
Type
|
A type to cast the internal string values to, if any. |
tuple[str]
|
Source code in src/convoke/configs.py
334 335 336 337 338 339 340 341 342 343 |
|
report_settings()
classmethod
Prepare a datastructure reporting on this configuration class's settings.
Source code in src/convoke/configs.py
281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 |
|