feat: add pilot database and router#570
feat: add pilot database and router#570Robin-Van-de-Merghel wants to merge 9 commits intoDIRACGrid:mainfrom
Conversation
8c655b0 to
2cfe44a
Compare
2cfe44a to
ce03dc2
Compare
65abf0c to
64aece6
Compare
| """Tried to access a value which is asynchronously loaded but not yet available.""" | ||
|
|
||
|
|
||
| class DiracFormattedError(DiracError): |
There was a problem hiding this comment.
All exceptions apart from the 2 below inherit from DiracError, and this one is further customization for only a few related to pilot. What if instead you modify DiracError?
There was a problem hiding this comment.
I don't know really if I should keep as before classes with code duplication, or if a generic thingy will help... I had that in mind, but seems overkill:
class DiracFormattedError(Exception):
http_status_code = HTTPStatus.BAD_REQUEST # 400
pattern = "Error [args]"
def __init__(self, data: dict[str, str], detail: str = ""):
self.data = data
self.detail = detail
super().__init__(self._render_message())
def _render_message(self) -> str:
context = {
**self.data,
"args": self._format_args(),
"detail": self._format_detail(),
}
return re.sub(r'\[([^\]]+)\]', lambda m: context.get(m.group(1), ""), self.pattern)
def _format_args(self) -> str:
if not self.data:
return ""
return " ".join(f"({k}: {v})" for k, v in self.data.items())
def _format_detail(self) -> str:
return f": {self.detail}" if self.detail else ""Then:
class PilotAlreadyExistsError(DiracFormattedError):
http_status_code = HTTPStatus.CONFLICT
pattern = "Pilot [args] already exists[detail]"da86dca to
109525e
Compare
Where an issue?Whether we have a base router with PossibilitiesSplittingLet's start with the routers themselves. We can separate pilots and users endpoints : That brings us:
Using another approachWe could have a bare base router without dependency injection, with sub routers with # Authenticated parent router
protected_router = APIRouter(dependencies=[Depends(verify_dirac_access_token)])
@protected_router.get("/secure")
def secure_route():
return {"msg": "secure"}
# Public sub-router (no auth)
public_router = APIRouter()
@public_router.get("/public")
def public_route():
return {"msg": "public"}Its goal would be to replacer |
4009683 to
60fb4e6
Compare
| ) | ||
|
|
||
|
|
||
| async def clear_pilots( |
There was a problem hiding this comment.
No description provided.
There was a problem hiding this comment.
(For deletePilots: delete mapping also, same later for logs #511 + PilotOutput)
There was a problem hiding this comment.
Left open as a reminder (already did mapping and output)
0181496 to
315a77b
Compare
dae7268 to
95cf9b4
Compare
a9b353d to
4ba2c9b
Compare
20795e5 to
f0e6846
Compare
aa0b56a to
706ab09
Compare
9cb8d15 to
7e63b63
Compare
|
This PR is I think ready for being tested in the certification setup. In the meantime, please review. |
a1062cb to
64f2057
Compare
64f2057 to
6e47a7a
Compare
|
It's ready to be reviewed again @fstagni
|
Split of #421 , first part : pilot management