-
Notifications
You must be signed in to change notification settings - Fork 25
Add pilot management: create/delete/patch and query #570
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Add pilot management: create/delete/patch and query #570
Conversation
8c655b0
to
2cfe44a
Compare
2cfe44a
to
ce03dc2
Compare
65abf0c
to
64aece6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First review.
@@ -100,3 +101,43 @@ def __init__(self, job_id, detail: str | None = None): | |||
|
|||
class NotReadyError(DiracError): | |||
"""Tried to access a value which is asynchronously loaded but not yet available.""" | |||
|
|||
|
|||
class DiracFormattedError(DiracError): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No description provided.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(For deletePilots
: delete mapping also, same later for logs #511 + PilotOutput
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left open as a reminder (already did mapping and output)
0181496
to
315a77b
Compare
dae7268
to
95cf9b4
Compare
a9b353d
to
4ba2c9b
Compare
5ab3f07
to
923f296
Compare
6f62d2e
to
efb36bf
Compare
cf59174
to
6674d37
Compare
cae7411
to
f5f434b
Compare
3f801ac
to
bbade5e
Compare
Will need to be cleaned before merge (integration test) |
09cc45c
to
1192a8b
Compare
1192a8b
to
7c6ba77
Compare
@@ -0,0 +1,20 @@ | |||
## Presentation | |||
|
|||
Pilots are a piece of software that is running on *worker nodes*. There are two types of pilots: "DIRAC pilots", and "DiracX pilots". The first type corresponds to pilots with proxies, sent by DIRAC; and the second type corresponds to pilots with secrets. Both kinds will eventually interact with DiracX using tokens (DIRAC pilots by exchanging their proxies for tokens, DiracX by exchanging their secrets for tokens). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This, I am afraid, it is misleading. There are no DiracX pilots, while there are pilots equipped for interacting with DIRAC or DiracX servers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll rephrase it
7c6ba77
to
20795e5
Compare
Split of #421 , first part : pilot management