Skip to content

Commit 95cf9b4

Browse files
author
Robin VAN DE MERGHEL
committed
fix: Change from status reason to status (cf dirac-admin-add-pilot)
1 parent 951ac0d commit 95cf9b4

File tree

5 files changed

+28
-23
lines changed
  • diracx-client/src/diracx/client/_generated/models
  • diracx-db/src/diracx/db/sql/pilots
  • diracx-logic/src/diracx/logic/pilots
  • diracx-routers/src/diracx/routers/pilots
  • extensions/gubbins/gubbins-client/src/gubbins/client/_generated/models

5 files changed

+28
-23
lines changed

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

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,9 @@ class BodyPilotsAddPilotStamps(_serialization.Model):
144144
:vartype destination_site: str
145145
:ivar pilot_references: Association of a pilot reference with a pilot stamp.
146146
:vartype pilot_references: dict[str, str]
147-
:ivar status_reason: Status reason of the pilots.
148-
:vartype status_reason: str
147+
:ivar pilot_status: Status of the pilots. Known values are: "Submitted", "Waiting", "Running",
148+
"Done", "Failed", "Deleted", "Aborted", and "Unknown".
149+
:vartype pilot_status: str or ~_generated.models.PilotStatus
149150
"""
150151

151152
_validation = {
@@ -160,7 +161,7 @@ class BodyPilotsAddPilotStamps(_serialization.Model):
160161
"grid_site": {"key": "grid_site", "type": "str"},
161162
"destination_site": {"key": "destination_site", "type": "str"},
162163
"pilot_references": {"key": "pilot_references", "type": "{str}"},
163-
"status_reason": {"key": "status_reason", "type": "str"},
164+
"pilot_status": {"key": "pilot_status", "type": "str"},
164165
}
165166

166167
def __init__(
@@ -172,7 +173,7 @@ def __init__(
172173
grid_site: str = "Unknown",
173174
destination_site: str = "NotAssigned",
174175
pilot_references: Optional[Dict[str, str]] = None,
175-
status_reason: str = "Unknown",
176+
pilot_status: Optional[Union[str, "_models.PilotStatus"]] = None,
176177
**kwargs: Any
177178
) -> None:
178179
"""
@@ -188,8 +189,9 @@ def __init__(
188189
:paramtype destination_site: str
189190
:keyword pilot_references: Association of a pilot reference with a pilot stamp.
190191
:paramtype pilot_references: dict[str, str]
191-
:keyword status_reason: Status reason of the pilots.
192-
:paramtype status_reason: str
192+
:keyword pilot_status: Status of the pilots. Known values are: "Submitted", "Waiting",
193+
"Running", "Done", "Failed", "Deleted", "Aborted", and "Unknown".
194+
:paramtype pilot_status: str or ~_generated.models.PilotStatus
193195
"""
194196
super().__init__(**kwargs)
195197
self.pilot_stamps = pilot_stamps
@@ -198,7 +200,7 @@ def __init__(
198200
self.grid_site = grid_site
199201
self.destination_site = destination_site
200202
self.pilot_references = pilot_references
201-
self.status_reason = status_reason
203+
self.pilot_status = pilot_status
202204

203205

204206
class BodyPilotsUpdatePilotFields(_serialization.Model):

diracx-db/src/diracx/db/sql/pilots/db.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
)
1414
from diracx.core.models import (
1515
PilotFieldsMapping,
16+
PilotStatus,
1617
SearchSpec,
1718
SortSpec,
1819
)
@@ -43,7 +44,7 @@ async def add_pilots(
4344
grid_site: str = "Unknown",
4445
destination_site: str = "NotAssigned",
4546
pilot_references: dict[str, str] | None = None,
46-
status_reason: str = "Unknown",
47+
status: str = PilotStatus.SUBMITTED,
4748
):
4849
"""Bulk add pilots in the DB.
4950
@@ -64,8 +65,7 @@ async def add_pilots(
6465
"DestinationSite": destination_site,
6566
"SubmissionTime": now,
6667
"LastUpdateTime": now,
67-
"Status": "Submitted",
68-
"StatusReason": status_reason,
68+
"Status": status,
6969
"PilotStamp": stamp,
7070
}
7171
for stamp in pilot_stamps

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ async def register_new_pilots(
2121
grid_type: str,
2222
grid_site: str,
2323
destination_site: str,
24-
status_reason: str,
24+
status: str,
2525
pilot_job_references: dict[str, str] | None,
2626
):
2727
# [IMPORTANT] Check unicity of pilot references
@@ -43,7 +43,7 @@ async def register_new_pilots(
4343
grid_site=grid_site,
4444
destination_site=destination_site,
4545
pilot_references=pilot_job_references,
46-
status_reason=status_reason,
46+
status=status,
4747
)
4848

4949

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
)
1313
from diracx.core.models import (
1414
PilotFieldsMapping,
15+
PilotStatus,
1516
)
1617
from diracx.logic.pilots.management import (
1718
add_jobs_to_pilot as add_jobs_to_pilot_bl,
@@ -57,9 +58,9 @@ async def add_pilot_stamps(
5758
dict[str, str] | None,
5859
Body(description="Association of a pilot reference with a pilot stamp."),
5960
] = None,
60-
status_reason: Annotated[
61-
str, Body(description="Status reason of the pilots.")
62-
] = "Unknown",
61+
pilot_status: Annotated[
62+
PilotStatus, Body(description="Status of the pilots.")
63+
] = PilotStatus.SUBMITTED,
6364
):
6465
"""Endpoint where a you can create pilots with their references.
6566
@@ -77,7 +78,7 @@ async def add_pilot_stamps(
7778
grid_site=grid_site,
7879
destination_site=destination_site,
7980
pilot_job_references=pilot_references,
80-
status_reason=status_reason,
81+
status=pilot_status,
8182
)
8283
except PilotAlreadyExistsError as e:
8384
raise HTTPException(status_code=status.HTTP_409_CONFLICT, detail=str(e)) from e

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

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,9 @@ class BodyPilotsAddPilotStamps(_serialization.Model):
144144
:vartype destination_site: str
145145
:ivar pilot_references: Association of a pilot reference with a pilot stamp.
146146
:vartype pilot_references: dict[str, str]
147-
:ivar status_reason: Status reason of the pilots.
148-
:vartype status_reason: str
147+
:ivar pilot_status: Status of the pilots. Known values are: "Submitted", "Waiting", "Running",
148+
"Done", "Failed", "Deleted", "Aborted", and "Unknown".
149+
:vartype pilot_status: str or ~_generated.models.PilotStatus
149150
"""
150151

151152
_validation = {
@@ -160,7 +161,7 @@ class BodyPilotsAddPilotStamps(_serialization.Model):
160161
"grid_site": {"key": "grid_site", "type": "str"},
161162
"destination_site": {"key": "destination_site", "type": "str"},
162163
"pilot_references": {"key": "pilot_references", "type": "{str}"},
163-
"status_reason": {"key": "status_reason", "type": "str"},
164+
"pilot_status": {"key": "pilot_status", "type": "str"},
164165
}
165166

166167
def __init__(
@@ -172,7 +173,7 @@ def __init__(
172173
grid_site: str = "Unknown",
173174
destination_site: str = "NotAssigned",
174175
pilot_references: Optional[Dict[str, str]] = None,
175-
status_reason: str = "Unknown",
176+
pilot_status: Optional[Union[str, "_models.PilotStatus"]] = None,
176177
**kwargs: Any
177178
) -> None:
178179
"""
@@ -188,8 +189,9 @@ def __init__(
188189
:paramtype destination_site: str
189190
:keyword pilot_references: Association of a pilot reference with a pilot stamp.
190191
:paramtype pilot_references: dict[str, str]
191-
:keyword status_reason: Status reason of the pilots.
192-
:paramtype status_reason: str
192+
:keyword pilot_status: Status of the pilots. Known values are: "Submitted", "Waiting",
193+
"Running", "Done", "Failed", "Deleted", "Aborted", and "Unknown".
194+
:paramtype pilot_status: str or ~_generated.models.PilotStatus
193195
"""
194196
super().__init__(**kwargs)
195197
self.pilot_stamps = pilot_stamps
@@ -198,7 +200,7 @@ def __init__(
198200
self.grid_site = grid_site
199201
self.destination_site = destination_site
200202
self.pilot_references = pilot_references
201-
self.status_reason = status_reason
203+
self.pilot_status = pilot_status
202204

203205

204206
class BodyPilotsUpdatePilotFields(_serialization.Model):

0 commit comments

Comments
 (0)