confit.registry
VisibleDeprecationWarning [source]
Bases: UserWarning
Visible deprecation warning.
By default, python will not show deprecation warnings, so this class can be used when a very visible warning is helpful, for example because the usage is most likely a user bug.
Copied from https://github.com/numpy/numpy/blob/965b41d418e6100c1afae0b6f818a7ef152bc25d/numpy/_globals.py#L44-L51
Registry [source]
Bases: Registry
A registry that validates the input arguments of the registered functions.
Initialize the registry.
Parameters
| PARAMETER | DESCRIPTION |
|---|---|
namespace | The namespace of the registry TYPE: |
entry_points | Should we use entry points to load the registered functions TYPE: |
Source code in confit/registry.py
302 303 304 305 306 307 308 309 310 311 312 313 314 | |
register [source]
This is a convenience wrapper around catalogue.Registry.register, that additionally validates the input arguments of the registered function and saves the result of any call to a mapping to its arguments.
Parameters
| PARAMETER | DESCRIPTION |
|---|---|
name | The name of the function TYPE: |
func | The function to register TYPE: |
save_params | Additional parameters to save with the call arguments, defaults to the registry name when omitted or empty TYPE: |
skip_save_params | List of parameters to skip when saving the function parameters TYPE: |
invoker | An optional invoker to apply to the function before registering it. It is better to use this than to apply the invoker to the function to preserve the signature of the function or the class and enable validating its parameters. TYPE: |
deprecated | The deprecated registry names for the function TYPE: |
Source code in confit/registry.py
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 | |
get_entry_points [source]
Get registered entry points from other packages for this namespace.
RETURNS (Dict[str, Any]): Entry points, keyed by name.
Source code in confit/registry.py
402 403 404 405 406 407 | |
get [source]
Get the registered function for a given name.
Modified from catalogue.Registry.get to avoid importing all entry points when lookup fails, but rather list the available entry points.
Parameters
| PARAMETER | DESCRIPTION |
|---|---|
name | The name of the function TYPE: |
| RETURNS | DESCRIPTION |
|---|---|
Func | |
Source code in confit/registry.py
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 | |
get_available [source]
Get all functions for a given namespace.
namespace (Tuple[str]): The namespace to get. RETURNS (Dict[str, Any]): The functions, keyed by name.
Source code in confit/registry.py
444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 | |
MetaRegistryCollection [source]
Bases: type
A metaclass for the registry collection that adds it as the registry collection of all registries defined in the body of the class.
Initialize the registry collection by adding it-self as the registry collection of all registries.
Parameters
| PARAMETER | DESCRIPTION |
|---|---|
name |
|
bases |
|
dct |
|
Source code in confit/registry.py
475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 | |
RegistryCollection [source]
A collection of registries.
```python class MyRegistries(RegistryCollection): my_registry = Registry(("package_name", "my_registry"), entry_points=True) my_other_registry = Registry(("package_name", "my_other_registry"))
make_wrapper [source]
Prepare validation once, then resolve and execute each registered call
Source code in confit/registry.py
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 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 | |
validate_arguments [source]
Validate function or constructor arguments and support deferred calls with draft
Parameters
| PARAMETER | DESCRIPTION |
|---|---|
func | The function or class to call TYPE: |
config | The validation configuration object TYPE: |
invoker | An optional invoker to apply on the validated function TYPE: |
registry | The registry to use to resolve the default parameters TYPE: |
| RETURNS | DESCRIPTION |
|---|---|
Callable[[Callable[P, R]], Draftable[P, R]]: | |
Source code in confit/registry.py
198 199 200 201 202 203 204 205 206 207 208 209 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 236 237 238 239 240 241 242 243 244 245 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 | |
get_default_registry [source]
Get the default registered registry.
| RETURNS | DESCRIPTION |
|---|---|
Registry | |
Source code in confit/registry.py
503 504 505 506 507 508 509 510 511 | |
set_default_registry [source]
Set the default registered registry. This is used in Config.resolve() when no registry is provided.
Parameters
| PARAMETER | DESCRIPTION |
|---|---|
registry | TYPE: |
| RETURNS | DESCRIPTION |
|---|---|
Registry | |
Source code in confit/registry.py
517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 | |