Description
Create the data layer for RSS in diracx:
- SQLAlchemy 2.0 models in
diracx-db that map the existing ResourceStatusDB tables — no schema changes, DB is shared with legacy DIRAC.
- Pydantic models in
diracx-core for the consumer-facing view — a simplified binary allowed/banned model.
SQLAlchemy models
Note: The ResourceStatusCache table from the legacy schema is not needed — caching is handled by CacheableSource.
Technical details:
- Create
diracx-db/src/diracx/db/sql/rss/ package with schema.py and db.py
- Follow diracx SQLAlchemy 2.0 patterns (
DeclarativeBase, Mapped[T], mapped_column()) — see diracx-db/src/diracx/db/sql/auth/schema.py and job/schema.py for reference
- Create
ResourceStatusDB(BaseSQLDB) with read methods for status queries
- Register via entry point in
pyproject.toml under diracx.dbs.sql
- Must not create or alter tables — schema is owned by legacy DIRAC
Pydantic models
Implement the simplified binary consumer model proposed in the #790 discussion:
from pydantic import BaseModel
from typing import Literal
class AllowedStatus(BaseModel):
allowed: Literal[True]
warnings: list[str] = []
def __bool__(self) -> bool:
return True
class BannedStatus(BaseModel):
allowed: Literal[False]
reason: str = "Unknown"
def __bool__(self) -> bool:
return False
ResourceStatus = AllowedStatus | BannedStatus # Discriminated union on `allowed`
class StorageElementStatus(BaseModel):
read: ResourceStatus
write: ResourceStatus
check: ResourceStatus
remove: ResourceStatus
class ComputeElementStatus(BaseModel):
all: ResourceStatus
class SiteStatus(BaseModel):
all: ResourceStatus
Mapping from DB status to binary model:
- Allowed:
Active, Degraded
- Banned:
Banned, Probing, Error, Unknown
This matches the existing getUsableSites logic in DIRAC (SiteStatus.py).
Reference
Acceptance criteria
Description
Create the data layer for RSS in diracx:
diracx-dbthat map the existingResourceStatusDBtables — no schema changes, DB is shared with legacy DIRAC.diracx-corefor the consumer-facing view — a simplified binary allowed/banned model.SQLAlchemy models
Technical details:
diracx-db/src/diracx/db/sql/rss/package withschema.pyanddb.pyDeclarativeBase,Mapped[T],mapped_column()) — seediracx-db/src/diracx/db/sql/auth/schema.pyandjob/schema.pyfor referenceResourceStatusDB(BaseSQLDB)with read methods for status queriespyproject.tomlunderdiracx.dbs.sqlPydantic models
Implement the simplified binary consumer model proposed in the #790 discussion:
Mapping from DB status to binary model:
Active,DegradedBanned,Probing,Error,UnknownThis matches the existing
getUsableSiteslogic in DIRAC (SiteStatus.py).Reference
DIRAC/ResourceStatusSystem/DB/ResourceStatusDB.py(lines 86–260)Acceptance criteria
ResourceStatusDB(BaseSQLDB)class with read methods forSiteStatusandResourceStatuspyproject.tomlAllowedStatus,BannedStatus,StorageElementStatus,ComputeElementStatus,SiteStatusResourceTypeenum