Skip to content

Commit 962c6a4

Browse files
fix: Removing os endpoints
1 parent 6396990 commit 962c6a4

File tree

1 file changed

+7
-78
lines changed
  • diracx-routers/src/diracx/routers/pilots

1 file changed

+7
-78
lines changed
Lines changed: 7 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -1,94 +1,23 @@
11
from __future__ import annotations
22

3-
from os import getenv
43
from typing import Annotated
54

65
from fastapi import (
76
Depends,
8-
HTTPException,
9-
status,
107
)
118

12-
from diracx.core.exceptions import (
13-
PilotAlreadyExistsError,
14-
PilotNotFoundError,
15-
)
16-
17-
from ..dependencies import (
18-
PilotAgentsDB,
19-
)
209
from ..fastapi_classes import DiracxRouter
2110
from ..utils.users import AuthorizedUserInfo, verify_dirac_access_token
2211
from .access_policies import RegisteredPilotAccessPolicyCallable
2312

2413
router = DiracxRouter(require_auth=False)
2514

26-
# Debug only route
27-
# Keep it?
28-
# TODO: Add to the env?
29-
if getenv("production") is None:
30-
31-
@router.get("/info")
32-
async def get_pilot_info(
33-
check_permissions: RegisteredPilotAccessPolicyCallable,
34-
user_info: Annotated[AuthorizedUserInfo, Depends(verify_dirac_access_token)],
35-
):
36-
await check_permissions()
37-
38-
return user_info
39-
40-
@router.post("/register-pilot")
41-
async def add_new_pilot(
42-
pilot_db: PilotAgentsDB,
43-
vo: str = "default-vo",
44-
initial_job_id: int = 0,
45-
current_job_id: int = 0,
46-
benchmark: float = 0.0,
47-
pilot_job_reference: str = "Unknown",
48-
pilot_stamp: str = "",
49-
status: str = "Unknown",
50-
status_reason: str = "Unknown",
51-
queue: str = "Unknown",
52-
grid_site: str = "Unknown",
53-
destination_site: str = "NotAssigned",
54-
grid_type: str = "LCG",
55-
submission_time: str | None = None, # ?
56-
last_update_time: str | None = None, # = now?
57-
accounting_sent: bool = False,
58-
):
59-
return {
60-
"id": await pilot_db.register_new_pilot(
61-
initial_job_id=initial_job_id,
62-
current_job_id=current_job_id,
63-
pilot_job_reference=pilot_job_reference,
64-
pilot_stamp=pilot_stamp,
65-
destination_site=destination_site,
66-
queue=queue,
67-
grid_site=grid_site,
68-
vo=vo,
69-
grid_type=grid_type,
70-
benchmark=benchmark,
71-
submission_time=submission_time,
72-
last_update_time=last_update_time,
73-
status=status,
74-
status_reason=status_reason,
75-
accounting_sent=accounting_sent,
76-
)
77-
}
7815

79-
@router.post("/add-credentials")
80-
async def add_credentials(pilot_db: PilotAgentsDB, pilot_id: int):
81-
try:
82-
return {"secret": await pilot_db.add_pilot_credentials(pilot_id=pilot_id)}
83-
except PilotNotFoundError as e:
84-
raise HTTPException(
85-
status_code=status.HTTP_404_NOT_FOUND, detail=e.detail
86-
) from e
87-
except PilotAlreadyExistsError as e:
88-
raise HTTPException(
89-
status_code=status.HTTP_409_CONFLICT, detail=e.detail
90-
) from e
16+
@router.get("/info")
17+
async def get_pilot_info(
18+
check_permissions: RegisteredPilotAccessPolicyCallable,
19+
user_info: Annotated[AuthorizedUserInfo, Depends(verify_dirac_access_token)],
20+
):
21+
await check_permissions()
9122

92-
@router.post("/get-pilots")
93-
async def get_pilots(pilot_db: PilotAgentsDB):
94-
return await pilot_db.get_pilots()
23+
return user_info

0 commit comments

Comments
 (0)