Skip to content

Commit a70b4b4

Browse files
fix: Use also VO as parameter (in case DIRAC has a bad VO)
1 parent 75282ad commit a70b4b4

File tree

5 files changed

+26
-7
lines changed

5 files changed

+26
-7
lines changed

diracx-client/src/diracx/client/_generated/models/_models.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,8 @@ class BodyPilotsAddPilotStamps(_serialization.Model):
101101
102102
:ivar pilot_stamps: List of the pilot stamps we want to add to the db. Required.
103103
:vartype pilot_stamps: list[str]
104+
:ivar vo: Pilot virtual organization. Required.
105+
:vartype vo: str
104106
:ivar grid_type: Grid type of the pilots.
105107
:vartype grid_type: str
106108
:ivar grid_site: Pilots grid site.
@@ -116,10 +118,12 @@ class BodyPilotsAddPilotStamps(_serialization.Model):
116118

117119
_validation = {
118120
"pilot_stamps": {"required": True},
121+
"vo": {"required": True},
119122
}
120123

121124
_attribute_map = {
122125
"pilot_stamps": {"key": "pilot_stamps", "type": "[str]"},
126+
"vo": {"key": "vo", "type": "str"},
123127
"grid_type": {"key": "grid_type", "type": "str"},
124128
"grid_site": {"key": "grid_site", "type": "str"},
125129
"destination_site": {"key": "destination_site", "type": "str"},
@@ -131,6 +135,7 @@ def __init__(
131135
self,
132136
*,
133137
pilot_stamps: List[str],
138+
vo: str,
134139
grid_type: str = "Dirac",
135140
grid_site: str = "Unknown",
136141
destination_site: str = "NotAssigned",
@@ -141,6 +146,8 @@ def __init__(
141146
"""
142147
:keyword pilot_stamps: List of the pilot stamps we want to add to the db. Required.
143148
:paramtype pilot_stamps: list[str]
149+
:keyword vo: Pilot virtual organization. Required.
150+
:paramtype vo: str
144151
:keyword grid_type: Grid type of the pilots.
145152
:paramtype grid_type: str
146153
:keyword grid_site: Pilots grid site.
@@ -155,6 +162,7 @@ def __init__(
155162
"""
156163
super().__init__(**kwargs)
157164
self.pilot_stamps = pilot_stamps
165+
self.vo = vo
158166
self.grid_type = grid_type
159167
self.grid_site = grid_site
160168
self.destination_site = destination_site

diracx-client/src/diracx/client/patches/pilots/common.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ class AddPilotStampsBody(TypedDict, total=False):
9898
grid_site: str
9999
pilot_references: dict[str, str]
100100
pilot_status: PilotStatus
101+
vo: str
101102

102103
class AddPilotStampsKwargs(AddPilotStampsBody, ResponseExtra): ...
103104

@@ -111,7 +112,7 @@ def make_add_pilot_stamps_body(**kwargs: Unpack[AddPilotStampsKwargs]) -> Underl
111112
for key in AddPilotStampsBody.__optional_keys__:
112113
if key not in kwargs:
113114
continue
114-
key = cast(Literal["pilot_stamps", "grid_type", "grid_site", "pilot_references", "pilot_status"], key)
115+
key = cast(Literal["pilot_stamps", "grid_type", "grid_site", "pilot_references", "pilot_status", "vo"], key)
115116
value = kwargs.pop(key)
116117
if value is not None:
117118
body[key] = value

diracx-routers/src/diracx/routers/pilots/management.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ async def add_pilot_stamps(
4141
list[str],
4242
Body(description="List of the pilot stamps we want to add to the db."),
4343
],
44+
vo: Annotated[str, Body(description="Pilot virtual organization.")],
4445
check_permissions: CheckPilotManagementPolicyCallable,
4546
user_info: Annotated[AuthorizedUserInfo, Depends(verify_dirac_access_token)],
4647
grid_type: Annotated[str, Body(description="Grid type of the pilots.")] = "Dirac",
@@ -79,7 +80,7 @@ async def add_pilot_stamps(
7980
await register_new_pilots(
8081
pilot_db=pilot_db,
8182
pilot_stamps=pilot_stamps,
82-
vo=user_info.vo,
83+
vo=vo,
8384
grid_type=grid_type,
8485
grid_site=grid_site,
8586
destination_site=destination_site,

diracx-routers/tests/pilots/test_pilot_creation.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ async def test_create_pilots(normal_test_client):
4141
pilot_stamps = [f"stamps_{i}" for i in range(N)]
4242

4343
# -------------- Bulk insert --------------
44-
body = {"pilot_stamps": pilot_stamps}
44+
body = {"pilot_stamps": pilot_stamps, "vo": MAIN_VO}
4545

4646
r = normal_test_client.post(
4747
"/api/pilots/",
@@ -54,6 +54,7 @@ async def test_create_pilots(normal_test_client):
5454

5555
body = {
5656
"pilot_stamps": [pilot_stamps[0], pilot_stamps[0] + "_new_one"],
57+
"vo": MAIN_VO,
5758
}
5859

5960
r = normal_test_client.post(
@@ -73,7 +74,7 @@ async def test_create_pilots(normal_test_client):
7374
# -------------- Register a pilot that does not exists **but** was called before in an error --------------
7475
# To prove that, if I tried to register a pilot that does not exist with one that already exists,
7576
# i can normally add the one that did not exist before (it should not have added it before)
76-
body = {"pilot_stamps": [pilot_stamps[0] + "_new_one"]}
77+
body = {"pilot_stamps": [pilot_stamps[0] + "_new_one"], "vo": MAIN_VO}
7778

7879
r = normal_test_client.post(
7980
"/api/pilots/",
@@ -90,7 +91,7 @@ async def test_create_pilot_and_delete_it(normal_test_client):
9091
pilot_stamp = "stamps_1"
9192

9293
# -------------- Insert --------------
93-
body = {"pilot_stamps": [pilot_stamp]}
94+
body = {"pilot_stamps": [pilot_stamp], "vo": MAIN_VO}
9495

9596
# Create a pilot
9697
r = normal_test_client.post(
@@ -134,7 +135,7 @@ async def test_create_pilot_and_modify_it(normal_test_client):
134135
pilot_stamps = ["stamps_1", "stamp_2"]
135136

136137
# -------------- Insert --------------
137-
body = {"pilot_stamps": pilot_stamps}
138+
body = {"pilot_stamps": pilot_stamps, "vo": MAIN_VO}
138139

139140
# Create pilots
140141
r = normal_test_client.post(
@@ -191,7 +192,7 @@ async def test_delete_pilots_by_age_and_stamp(normal_test_client):
191192
pilot_stamps = [f"stamp_{i}" for i in range(100)]
192193

193194
# -------------- Insert all pilots --------------
194-
body = {"pilot_stamps": pilot_stamps}
195+
body = {"pilot_stamps": pilot_stamps, "vo": MAIN_VO}
195196
r = normal_test_client.post("/api/pilots/", json=body)
196197
assert r.status_code == 200, r.json()
197198

extensions/gubbins/gubbins-client/src/gubbins/client/_generated/models/_models.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,8 @@ class BodyPilotsAddPilotStamps(_serialization.Model):
101101
102102
:ivar pilot_stamps: List of the pilot stamps we want to add to the db. Required.
103103
:vartype pilot_stamps: list[str]
104+
:ivar vo: Pilot virtual organization. Required.
105+
:vartype vo: str
104106
:ivar grid_type: Grid type of the pilots.
105107
:vartype grid_type: str
106108
:ivar grid_site: Pilots grid site.
@@ -116,10 +118,12 @@ class BodyPilotsAddPilotStamps(_serialization.Model):
116118

117119
_validation = {
118120
"pilot_stamps": {"required": True},
121+
"vo": {"required": True},
119122
}
120123

121124
_attribute_map = {
122125
"pilot_stamps": {"key": "pilot_stamps", "type": "[str]"},
126+
"vo": {"key": "vo", "type": "str"},
123127
"grid_type": {"key": "grid_type", "type": "str"},
124128
"grid_site": {"key": "grid_site", "type": "str"},
125129
"destination_site": {"key": "destination_site", "type": "str"},
@@ -131,6 +135,7 @@ def __init__(
131135
self,
132136
*,
133137
pilot_stamps: List[str],
138+
vo: str,
134139
grid_type: str = "Dirac",
135140
grid_site: str = "Unknown",
136141
destination_site: str = "NotAssigned",
@@ -141,6 +146,8 @@ def __init__(
141146
"""
142147
:keyword pilot_stamps: List of the pilot stamps we want to add to the db. Required.
143148
:paramtype pilot_stamps: list[str]
149+
:keyword vo: Pilot virtual organization. Required.
150+
:paramtype vo: str
144151
:keyword grid_type: Grid type of the pilots.
145152
:paramtype grid_type: str
146153
:keyword grid_site: Pilots grid site.
@@ -155,6 +162,7 @@ def __init__(
155162
"""
156163
super().__init__(**kwargs)
157164
self.pilot_stamps = pilot_stamps
165+
self.vo = vo
158166
self.grid_type = grid_type
159167
self.grid_site = grid_site
160168
self.destination_site = destination_site

0 commit comments

Comments
 (0)