Skip to content

Commit ff81680

Browse files
authored
Merge pull request #608 from Robin-Van-de-Merghel/robin-generic-search
refactor: Made search and summary generic to reuse it easily
2 parents 186301d + 380da62 commit ff81680

File tree

20 files changed

+376
-341
lines changed

20 files changed

+376
-341
lines changed

diracx-client/src/diracx/client/_generated/aio/operations/_operations.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1826,7 +1826,7 @@ async def patch_metadata(self, body: Union[Dict[str, Dict[str, Any]], IO[bytes]]
18261826
@overload
18271827
async def search(
18281828
self,
1829-
body: Optional[_models.JobSearchParams] = None,
1829+
body: Optional[_models.SearchParams] = None,
18301830
*,
18311831
page: int = 1,
18321832
per_page: int = 100,
@@ -1840,7 +1840,7 @@ async def search(
18401840
**TODO: Add more docs**.
18411841
18421842
:param body: Default value is None.
1843-
:type body: ~_generated.models.JobSearchParams
1843+
:type body: ~_generated.models.SearchParams
18441844
:keyword page: Default value is 1.
18451845
:paramtype page: int
18461846
:keyword per_page: Default value is 100.
@@ -1886,7 +1886,7 @@ async def search(
18861886
@distributed_trace_async
18871887
async def search(
18881888
self,
1889-
body: Optional[Union[_models.JobSearchParams, IO[bytes]]] = None,
1889+
body: Optional[Union[_models.SearchParams, IO[bytes]]] = None,
18901890
*,
18911891
page: int = 1,
18921892
per_page: int = 100,
@@ -1898,8 +1898,8 @@ async def search(
18981898
18991899
**TODO: Add more docs**.
19001900
1901-
:param body: Is either a JobSearchParams type or a IO[bytes] type. Default value is None.
1902-
:type body: ~_generated.models.JobSearchParams or IO[bytes]
1901+
:param body: Is either a SearchParams type or a IO[bytes] type. Default value is None.
1902+
:type body: ~_generated.models.SearchParams or IO[bytes]
19031903
:keyword page: Default value is 1.
19041904
:paramtype page: int
19051905
:keyword per_page: Default value is 100.
@@ -1929,7 +1929,7 @@ async def search(
19291929
_content = body
19301930
else:
19311931
if body is not None:
1932-
_json = self._serialize.body(body, "JobSearchParams")
1932+
_json = self._serialize.body(body, "SearchParams")
19331933
else:
19341934
_json = None
19351935

@@ -1968,14 +1968,14 @@ async def search(
19681968

19691969
@overload
19701970
async def summary(
1971-
self, body: _models.JobSummaryParams, *, content_type: str = "application/json", **kwargs: Any
1971+
self, body: _models.SummaryParams, *, content_type: str = "application/json", **kwargs: Any
19721972
) -> Any:
19731973
"""Summary.
19741974
19751975
Show information suitable for plotting.
19761976
19771977
:param body: Required.
1978-
:type body: ~_generated.models.JobSummaryParams
1978+
:type body: ~_generated.models.SummaryParams
19791979
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
19801980
Default value is "application/json".
19811981
:paramtype content_type: str
@@ -2001,13 +2001,13 @@ async def summary(self, body: IO[bytes], *, content_type: str = "application/jso
20012001
"""
20022002

20032003
@distributed_trace_async
2004-
async def summary(self, body: Union[_models.JobSummaryParams, IO[bytes]], **kwargs: Any) -> Any:
2004+
async def summary(self, body: Union[_models.SummaryParams, IO[bytes]], **kwargs: Any) -> Any:
20052005
"""Summary.
20062006
20072007
Show information suitable for plotting.
20082008
2009-
:param body: Is either a JobSummaryParams type or a IO[bytes] type. Required.
2010-
:type body: ~_generated.models.JobSummaryParams or IO[bytes]
2009+
:param body: Is either a SummaryParams type or a IO[bytes] type. Required.
2010+
:type body: ~_generated.models.SummaryParams or IO[bytes]
20112011
:return: any
20122012
:rtype: any
20132013
:raises ~azure.core.exceptions.HttpResponseError:
@@ -2032,7 +2032,7 @@ async def summary(self, body: Union[_models.JobSummaryParams, IO[bytes]], **kwar
20322032
if isinstance(body, (IOBase, bytes)):
20332033
_content = body
20342034
else:
2035-
_json = self._serialize.body(body, "JobSummaryParams")
2035+
_json = self._serialize.body(body, "SummaryParams")
20362036

20372037
_request = build_jobs_summary_request(
20382038
content_type=content_type,

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,21 @@
2020
InitiateDeviceFlowResponse,
2121
InsertedJob,
2222
JobCommand,
23-
JobSearchParams,
24-
JobSearchParamsSearchItem,
2523
JobStatusUpdate,
26-
JobSummaryParams,
27-
JobSummaryParamsSearchItem,
2824
Metadata,
2925
OpenIDConfiguration,
3026
SandboxDownloadResponse,
3127
SandboxInfo,
3228
SandboxUploadResponse,
3329
ScalarSearchSpec,
3430
ScalarSearchSpecValue,
31+
SearchParams,
32+
SearchParamsSearchItem,
3533
SetJobStatusReturn,
3634
SetJobStatusReturnSuccess,
3735
SortSpec,
36+
SummaryParams,
37+
SummaryParamsSearchItem,
3838
SupportInfo,
3939
TokenResponse,
4040
UserInfoResponse,
@@ -67,21 +67,21 @@
6767
"InitiateDeviceFlowResponse",
6868
"InsertedJob",
6969
"JobCommand",
70-
"JobSearchParams",
71-
"JobSearchParamsSearchItem",
7270
"JobStatusUpdate",
73-
"JobSummaryParams",
74-
"JobSummaryParamsSearchItem",
7571
"Metadata",
7672
"OpenIDConfiguration",
7773
"SandboxDownloadResponse",
7874
"SandboxInfo",
7975
"SandboxUploadResponse",
8076
"ScalarSearchSpec",
8177
"ScalarSearchSpecValue",
78+
"SearchParams",
79+
"SearchParamsSearchItem",
8280
"SetJobStatusReturn",
8381
"SetJobStatusReturnSuccess",
8482
"SortSpec",
83+
"SummaryParams",
84+
"SummaryParamsSearchItem",
8585
"SupportInfo",
8686
"TokenResponse",
8787
"UserInfoResponse",

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

Lines changed: 88 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -358,56 +358,6 @@ def __init__(self, *, job_id: int, command: str, arguments: Optional[str] = None
358358
self.arguments = arguments
359359

360360

361-
class JobSearchParams(_serialization.Model):
362-
"""JobSearchParams.
363-
364-
:ivar parameters: Parameters.
365-
:vartype parameters: list[str]
366-
:ivar search: Search.
367-
:vartype search: list[~_generated.models.JobSearchParamsSearchItem]
368-
:ivar sort: Sort.
369-
:vartype sort: list[~_generated.models.SortSpec]
370-
:ivar distinct: Distinct.
371-
:vartype distinct: bool
372-
"""
373-
374-
_attribute_map = {
375-
"parameters": {"key": "parameters", "type": "[str]"},
376-
"search": {"key": "search", "type": "[JobSearchParamsSearchItem]"},
377-
"sort": {"key": "sort", "type": "[SortSpec]"},
378-
"distinct": {"key": "distinct", "type": "bool"},
379-
}
380-
381-
def __init__(
382-
self,
383-
*,
384-
parameters: Optional[List[str]] = None,
385-
search: List["_models.JobSearchParamsSearchItem"] = [],
386-
sort: List["_models.SortSpec"] = [],
387-
distinct: bool = False,
388-
**kwargs: Any
389-
) -> None:
390-
"""
391-
:keyword parameters: Parameters.
392-
:paramtype parameters: list[str]
393-
:keyword search: Search.
394-
:paramtype search: list[~_generated.models.JobSearchParamsSearchItem]
395-
:keyword sort: Sort.
396-
:paramtype sort: list[~_generated.models.SortSpec]
397-
:keyword distinct: Distinct.
398-
:paramtype distinct: bool
399-
"""
400-
super().__init__(**kwargs)
401-
self.parameters = parameters
402-
self.search = search
403-
self.sort = sort
404-
self.distinct = distinct
405-
406-
407-
class JobSearchParamsSearchItem(_serialization.Model):
408-
"""JobSearchParamsSearchItem."""
409-
410-
411361
class JobStatusUpdate(_serialization.Model):
412362
"""JobStatusUpdate.
413363
@@ -458,44 +408,6 @@ def __init__(
458408
self.source = source
459409

460410

461-
class JobSummaryParams(_serialization.Model):
462-
"""JobSummaryParams.
463-
464-
All required parameters must be populated in order to send to server.
465-
466-
:ivar grouping: Grouping. Required.
467-
:vartype grouping: list[str]
468-
:ivar search: Search.
469-
:vartype search: list[~_generated.models.JobSummaryParamsSearchItem]
470-
"""
471-
472-
_validation = {
473-
"grouping": {"required": True},
474-
}
475-
476-
_attribute_map = {
477-
"grouping": {"key": "grouping", "type": "[str]"},
478-
"search": {"key": "search", "type": "[JobSummaryParamsSearchItem]"},
479-
}
480-
481-
def __init__(
482-
self, *, grouping: List[str], search: List["_models.JobSummaryParamsSearchItem"] = [], **kwargs: Any
483-
) -> None:
484-
"""
485-
:keyword grouping: Grouping. Required.
486-
:paramtype grouping: list[str]
487-
:keyword search: Search.
488-
:paramtype search: list[~_generated.models.JobSummaryParamsSearchItem]
489-
"""
490-
super().__init__(**kwargs)
491-
self.grouping = grouping
492-
self.search = search
493-
494-
495-
class JobSummaryParamsSearchItem(_serialization.Model):
496-
"""JobSummaryParamsSearchItem."""
497-
498-
499411
class Metadata(_serialization.Model):
500412
"""Metadata.
501413
@@ -836,6 +748,56 @@ class ScalarSearchSpecValue(_serialization.Model):
836748
"""Value."""
837749

838750

751+
class SearchParams(_serialization.Model):
752+
"""SearchParams.
753+
754+
:ivar parameters: Parameters.
755+
:vartype parameters: list[str]
756+
:ivar search: Search.
757+
:vartype search: list[~_generated.models.SearchParamsSearchItem]
758+
:ivar sort: Sort.
759+
:vartype sort: list[~_generated.models.SortSpec]
760+
:ivar distinct: Distinct.
761+
:vartype distinct: bool
762+
"""
763+
764+
_attribute_map = {
765+
"parameters": {"key": "parameters", "type": "[str]"},
766+
"search": {"key": "search", "type": "[SearchParamsSearchItem]"},
767+
"sort": {"key": "sort", "type": "[SortSpec]"},
768+
"distinct": {"key": "distinct", "type": "bool"},
769+
}
770+
771+
def __init__(
772+
self,
773+
*,
774+
parameters: Optional[List[str]] = None,
775+
search: List["_models.SearchParamsSearchItem"] = [],
776+
sort: List["_models.SortSpec"] = [],
777+
distinct: bool = False,
778+
**kwargs: Any
779+
) -> None:
780+
"""
781+
:keyword parameters: Parameters.
782+
:paramtype parameters: list[str]
783+
:keyword search: Search.
784+
:paramtype search: list[~_generated.models.SearchParamsSearchItem]
785+
:keyword sort: Sort.
786+
:paramtype sort: list[~_generated.models.SortSpec]
787+
:keyword distinct: Distinct.
788+
:paramtype distinct: bool
789+
"""
790+
super().__init__(**kwargs)
791+
self.parameters = parameters
792+
self.search = search
793+
self.sort = sort
794+
self.distinct = distinct
795+
796+
797+
class SearchParamsSearchItem(_serialization.Model):
798+
"""SearchParamsSearchItem."""
799+
800+
839801
class SetJobStatusReturn(_serialization.Model):
840802
"""SetJobStatusReturn.
841803
@@ -979,6 +941,44 @@ def __init__(self, *, parameter: str, direction: Union[str, "_models.SortDirecti
979941
self.direction = direction
980942

981943

944+
class SummaryParams(_serialization.Model):
945+
"""SummaryParams.
946+
947+
All required parameters must be populated in order to send to server.
948+
949+
:ivar grouping: Grouping. Required.
950+
:vartype grouping: list[str]
951+
:ivar search: Search.
952+
:vartype search: list[~_generated.models.SummaryParamsSearchItem]
953+
"""
954+
955+
_validation = {
956+
"grouping": {"required": True},
957+
}
958+
959+
_attribute_map = {
960+
"grouping": {"key": "grouping", "type": "[str]"},
961+
"search": {"key": "search", "type": "[SummaryParamsSearchItem]"},
962+
}
963+
964+
def __init__(
965+
self, *, grouping: List[str], search: List["_models.SummaryParamsSearchItem"] = [], **kwargs: Any
966+
) -> None:
967+
"""
968+
:keyword grouping: Grouping. Required.
969+
:paramtype grouping: list[str]
970+
:keyword search: Search.
971+
:paramtype search: list[~_generated.models.SummaryParamsSearchItem]
972+
"""
973+
super().__init__(**kwargs)
974+
self.grouping = grouping
975+
self.search = search
976+
977+
978+
class SummaryParamsSearchItem(_serialization.Model):
979+
"""SummaryParamsSearchItem."""
980+
981+
982982
class SupportInfo(_serialization.Model):
983983
"""SupportInfo.
984984

0 commit comments

Comments
 (0)