|
1 | | -from __future__ import annotations |
2 | | - |
3 | | -__all__ = ( |
4 | | - "Config", |
5 | | - "AuthDB", |
6 | | - "JobDB", |
7 | | - "JobLoggingDB", |
8 | | - "SandboxMetadataDB", |
9 | | - "TaskQueueDB", |
10 | | - "PilotAgentsDB", |
11 | | - "add_settings_annotation", |
12 | | - "AvailableSecurityProperties", |
13 | | -) |
14 | | - |
15 | | -from functools import partial |
16 | | -from typing import Annotated, TypeVar |
17 | | - |
18 | | -from fastapi import Depends |
19 | | - |
20 | | -from diracx.core.config import Config as _Config |
21 | | -from diracx.core.config import ConfigSource |
22 | | -from diracx.core.properties import SecurityProperty |
23 | | -from diracx.core.settings import AuthSettings as _AuthSettings |
24 | | -from diracx.core.settings import DevelopmentSettings as _DevelopmentSettings |
25 | | -from diracx.core.settings import SandboxStoreSettings as _SandboxStoreSettings |
26 | | -from diracx.db.os import JobParametersDB as _JobParametersDB |
27 | | -from diracx.db.sql import AuthDB as _AuthDB |
28 | | -from diracx.db.sql import JobDB as _JobDB |
29 | | -from diracx.db.sql import JobLoggingDB as _JobLoggingDB |
30 | | -from diracx.db.sql import PilotAgentsDB as _PilotAgentsDB |
31 | | -from diracx.db.sql import SandboxMetadataDB as _SandboxMetadataDB |
32 | | -from diracx.db.sql import TaskQueueDB as _TaskQueueDB |
33 | | - |
34 | | -T = TypeVar("T") |
35 | | - |
36 | | -# Use scope="function" to ensure DB commits happen before sending HTTP responses |
37 | | -# This prevents race conditions when DIRAC immediately queries data after DiracX writes it |
38 | | -DBDepends = partial(Depends, scope="function") |
| 1 | +"""Router DI types — re-exported from the canonical definitions in diracx-tasks.""" |
39 | 2 |
|
| 3 | +from __future__ import annotations |
40 | 4 |
|
41 | | -def add_settings_annotation(cls: T) -> T: |
42 | | - """Add a `Depends` annotation to a class that has a `create` classmethod.""" |
43 | | - return Annotated[cls, Depends(cls.create)] # type: ignore |
44 | | - |
45 | | - |
46 | | -# Databases |
47 | | -AuthDB = Annotated[_AuthDB, DBDepends(_AuthDB.transaction)] |
48 | | -JobDB = Annotated[_JobDB, DBDepends(_JobDB.transaction)] |
49 | | -JobLoggingDB = Annotated[_JobLoggingDB, DBDepends(_JobLoggingDB.transaction)] |
50 | | -PilotAgentsDB = Annotated[_PilotAgentsDB, DBDepends(_PilotAgentsDB.transaction)] |
51 | | -SandboxMetadataDB = Annotated[ |
52 | | - _SandboxMetadataDB, DBDepends(_SandboxMetadataDB.transaction) |
53 | | -] |
54 | | -TaskQueueDB = Annotated[_TaskQueueDB, DBDepends(_TaskQueueDB.transaction)] |
55 | | - |
56 | | -# Opensearch databases |
57 | | -JobParametersDB = Annotated[_JobParametersDB, DBDepends(_JobParametersDB.session)] |
58 | | - |
59 | | - |
60 | | -# Miscellaneous |
61 | | -Config = Annotated[_Config, Depends(ConfigSource.create)] |
62 | | -AvailableSecurityProperties = Annotated[ |
63 | | - set[SecurityProperty], Depends(SecurityProperty.available_properties) |
64 | | -] |
65 | | - |
66 | | -AuthSettings = Annotated[_AuthSettings, Depends(_AuthSettings.create)] |
67 | | -DevelopmentSettings = Annotated[ |
68 | | - _DevelopmentSettings, Depends(_DevelopmentSettings.create) |
69 | | -] |
70 | | -SandboxStoreSettings = Annotated[ |
71 | | - _SandboxStoreSettings, Depends(_SandboxStoreSettings.create) |
72 | | -] |
| 5 | +# Re-export everything from the canonical location |
| 6 | +from diracx.tasks.plumbing.depends import * # noqa: F401, F403 |
| 7 | +from diracx.tasks.plumbing.depends import __all__ # noqa: F401 |
0 commit comments