Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Registry

Registries in PyRIT provide a centralized way to discover, manage, and access components. They support lazy loading, singleton access, and metadata introspection.

Why Registries?

Two Types of Registries

PyRIT has two registry patterns for different use cases:

TypeStoresUse Case
Class RegistryClasses (Type[T])Components instantiated with user-provided parameters
Instance RegistryPre-configured instancesComponents requiring complex setup before use

Common API (RegistryProtocol)

Both registry types implement RegistryProtocol, sharing a consistent interface:

MethodDescription
get_registry_singleton()Get the singleton registry instance
get_names()List all registered names
list_metadata()Get descriptive metadata for all items
reset_instance()Reset the singleton (useful for testing)

This protocol enables writing code that works with any registry type:

from pyrit.registry import RegistryProtocol

def show_registry_contents(registry: RegistryProtocol) -> None:
    for name in registry.get_names():
        print(name)

Key Difference with Class and Instance Registries

AspectClass RegistryInstance Registry
StoresClasses (Type[T])Instances (T)
RegistrationAutomatic discoveryExplicit via register()
ReturnsClass to instantiateReady-to-use instance
InstantiationCaller provides parametersPre-configured by initializer
When to useSelf-contained components with deferred configurationComponents requiring constructor parameters or compositional setup

See Also