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

Registries share a consistent interface for discovery and introspection:

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 makes it easy to write code that inspects any registry:

from pyrit.registry import ScenarioRegistry

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


show_registry_contents(ScenarioRegistry.get_registry_singleton())

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