Skip to content

Dependencies

FastAPI dependency injection utilities for database access, authentication, and configuration in routers.

Dependencies are used in route handlers to inject common resources like database connections, authenticated users, and configuration objects.

dependencies

Attributes

__all__ = ('Config', 'AuthDB', 'JobDB', 'JobLoggingDB', 'SandboxMetadataDB', 'TaskQueueDB', 'PilotAgentsDB', 'add_settings_annotation', 'AvailableSecurityProperties') module-attribute

T = TypeVar('T') module-attribute

AuthDB = Annotated[_AuthDB, Depends(_AuthDB.transaction)] module-attribute

JobDB = Annotated[_JobDB, Depends(_JobDB.transaction)] module-attribute

JobLoggingDB = Annotated[_JobLoggingDB, Depends(_JobLoggingDB.transaction)] module-attribute

PilotAgentsDB = Annotated[_PilotAgentsDB, Depends(_PilotAgentsDB.transaction)] module-attribute

SandboxMetadataDB = Annotated[_SandboxMetadataDB, Depends(_SandboxMetadataDB.transaction)] module-attribute

TaskQueueDB = Annotated[_TaskQueueDB, Depends(_TaskQueueDB.transaction)] module-attribute

JobParametersDB = Annotated[_JobParametersDB, Depends(_JobParametersDB.session)] module-attribute

Config = Annotated[_Config, Depends(ConfigSource.create)] module-attribute

AvailableSecurityProperties = Annotated[set[SecurityProperty], Depends(SecurityProperty.available_properties)] module-attribute

AuthSettings = Annotated[_AuthSettings, Depends(_AuthSettings.create)] module-attribute

DevelopmentSettings = Annotated[_DevelopmentSettings, Depends(_DevelopmentSettings.create)] module-attribute

SandboxStoreSettings = Annotated[_SandboxStoreSettings, Depends(_SandboxStoreSettings.create)] module-attribute

Classes

Functions

add_settings_annotation(cls)

Add a Depends annotation to a class that has a create classmethod.

Source code in diracx-routers/src/diracx/routers/dependencies.py
def add_settings_annotation(cls: T) -> T:
    """Add a `Depends` annotation to a class that has a `create` classmethod."""
    return Annotated[cls, Depends(cls.create)]  # type: ignore