Skip to content

Commit

Permalink
feat: (temporary, 3 fix typing) Restructured pilot logger + new broke…
Browse files Browse the repository at this point in the history
…n test
  • Loading branch information
martynia committed Jan 15, 2025
1 parent 58ad0c0 commit d6e882a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
12 changes: 8 additions & 4 deletions diracx-routers/src/diracx/routers/pilots/access_policies.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

from fastapi import Depends, HTTPException, status

from diracx.core.models import ScalarSearchOperator, ScalarSearchSpec
from diracx.core.properties import (
NORMAL_USER,
)
Expand Down Expand Up @@ -48,11 +49,14 @@ async def policy(
status.HTTP_400_BAD_REQUEST, detail="Action is a mandatory argument"
)
elif action == ActionType.QUERY:
assert pilot_id
search_params = ScalarSearchSpec(
parameter="PilotID",
operator=ScalarSearchOperator.EQUAL,
value=pilot_id,
)

search_params = [
{"parameter": "PilotID", "operator": "eq", "value": pilot_id}
]
total, result = await pilot_agents_db.search(["VO"], search_params, [])
total, result = await pilot_agents_db.search(["VO"], [search_params], [])
print("Total: ", total, "Result: ", result)
if total != 1:
logger.error(
Expand Down
13 changes: 9 additions & 4 deletions diracx-routers/src/diracx/routers/pilots/logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
from fastapi import HTTPException, status
from pydantic import BaseModel

from diracx.core.models import ScalarSearchOperator, ScalarSearchSpec

from ..access_policies import open_access
from ..dependencies import PilotAgentsDB, PilotLogsDB
from ..fastapi_classes import DiracxRouter
Expand Down Expand Up @@ -40,11 +42,14 @@ async def send_message(
) -> int:

# expecting exactly one row:
search_params = [
{"parameter": "PilotStamp", "operator": "eq", "value": data.pilot_stamp}
]
search_params = ScalarSearchSpec(
parameter="PilotStamp",
operator=ScalarSearchOperator.EQUAL,
value=data.pilot_stamp,
)

total, result = await pilot_agents_db.search(
["PilotID", "VO", "SubmissionTime"], search_params, []
["PilotID", "VO", "SubmissionTime"], [search_params], []
)
if total != 1:
logger.error(
Expand Down

0 comments on commit d6e882a

Please sign in to comment.