diracx-client 0.0.1a48__py3-none-any.whl → 0.0.1a49__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- diracx/client/_generated/models/_models.py +9 -0
- diracx/client/patches/jobs/aio.py +20 -2
- diracx/client/patches/jobs/common.py +51 -2
- diracx/client/patches/jobs/sync.py +20 -2
- {diracx_client-0.0.1a48.dist-info → diracx_client-0.0.1a49.dist-info}/METADATA +1 -1
- {diracx_client-0.0.1a48.dist-info → diracx_client-0.0.1a49.dist-info}/RECORD +7 -7
- {diracx_client-0.0.1a48.dist-info → diracx_client-0.0.1a49.dist-info}/WHEEL +0 -0
@@ -413,6 +413,9 @@ class JobCommand(_serialization.Model):
|
|
413
413
|
class JobMetaData(_serialization.Model):
|
414
414
|
"""A model that combines both JobAttributes and JobParameters.
|
415
415
|
|
416
|
+
:ivar additional_properties: Unmatched properties from the message are deserialized to this
|
417
|
+
collection.
|
418
|
+
:vartype additional_properties: dict[str, any]
|
416
419
|
:ivar timestamp: Timestamp.
|
417
420
|
:vartype timestamp: ~datetime.datetime
|
418
421
|
:ivar cpu_normalization_factor: Cpunormalizationfactor.
|
@@ -486,6 +489,7 @@ class JobMetaData(_serialization.Model):
|
|
486
489
|
"""
|
487
490
|
|
488
491
|
_attribute_map = {
|
492
|
+
"additional_properties": {"key": "", "type": "{object}"},
|
489
493
|
"timestamp": {"key": "timestamp", "type": "iso-8601"},
|
490
494
|
"cpu_normalization_factor": {"key": "CPUNormalizationFactor", "type": "int"},
|
491
495
|
"norm_cpu_time_s": {"key": "NormCPUTime(s)", "type": "int"},
|
@@ -526,6 +530,7 @@ class JobMetaData(_serialization.Model):
|
|
526
530
|
def __init__( # pylint: disable=too-many-locals
|
527
531
|
self,
|
528
532
|
*,
|
533
|
+
additional_properties: Optional[Dict[str, Any]] = None,
|
529
534
|
timestamp: Optional[datetime.datetime] = None,
|
530
535
|
cpu_normalization_factor: Optional[int] = None,
|
531
536
|
norm_cpu_time_s: Optional[int] = None,
|
@@ -564,6 +569,9 @@ class JobMetaData(_serialization.Model):
|
|
564
569
|
**kwargs: Any
|
565
570
|
) -> None:
|
566
571
|
"""
|
572
|
+
:keyword additional_properties: Unmatched properties from the message are deserialized to this
|
573
|
+
collection.
|
574
|
+
:paramtype additional_properties: dict[str, any]
|
567
575
|
:keyword timestamp: Timestamp.
|
568
576
|
:paramtype timestamp: ~datetime.datetime
|
569
577
|
:keyword cpu_normalization_factor: Cpunormalizationfactor.
|
@@ -636,6 +644,7 @@ class JobMetaData(_serialization.Model):
|
|
636
644
|
:paramtype accounted_flag: ~_generated.models.JobMetaDataAccountedFlag
|
637
645
|
"""
|
638
646
|
super().__init__(**kwargs)
|
647
|
+
self.additional_properties = additional_properties
|
639
648
|
self.timestamp = timestamp
|
640
649
|
self.cpu_normalization_factor = cpu_normalization_factor
|
641
650
|
self.norm_cpu_time_s = norm_cpu_time_s
|
@@ -11,12 +11,13 @@ __all__ = [
|
|
11
11
|
"JobsOperations",
|
12
12
|
]
|
13
13
|
|
14
|
-
from typing import Any, Unpack
|
14
|
+
from typing import IO, Any, Dict, Union, Unpack, cast
|
15
15
|
|
16
16
|
from azure.core.tracing.decorator_async import distributed_trace_async
|
17
17
|
|
18
18
|
from ..._generated.aio.operations._operations import JobsOperations as _JobsOperations
|
19
|
-
from .
|
19
|
+
from diracx.client._generated.models._models import JobMetaData
|
20
|
+
from .common import make_search_body, make_summary_body, SearchKwargs, SummaryKwargs, prepare_body_for_patch
|
20
21
|
|
21
22
|
# We're intentionally ignoring overrides here because we want to change the interface.
|
22
23
|
# mypy: disable-error-code=override
|
@@ -32,3 +33,20 @@ class JobsOperations(_JobsOperations):
|
|
32
33
|
async def summary(self, **kwargs: Unpack[SummaryKwargs]) -> list[dict[str, Any]]:
|
33
34
|
"""TODO"""
|
34
35
|
return await super().summary(**make_summary_body(**kwargs))
|
36
|
+
|
37
|
+
@distributed_trace_async
|
38
|
+
async def patch_metadata( # type: ignore[override]
|
39
|
+
self,
|
40
|
+
body: Union[Dict[str | int, JobMetaData | Dict[str, Any]], IO[bytes], bytes],
|
41
|
+
**kwargs: Any,
|
42
|
+
) -> None:
|
43
|
+
"""Patch Metadata.
|
44
|
+
|
45
|
+
Accepts job ids as str|int and metadata as dicts with pythonic or wire keys.
|
46
|
+
Unknown keys are emitted via `additional_properties`.
|
47
|
+
TODO: Remove this method once we have structured and known job parameters.
|
48
|
+
"""
|
49
|
+
prepared = prepare_body_for_patch(body)
|
50
|
+
# Cast to Any to accommodate generated signature expecting Dict[str, JobMetaData]
|
51
|
+
# while still allowing bytes/IO at runtime.
|
52
|
+
await super().patch_metadata(cast(Any, prepared), **kwargs)
|
@@ -2,16 +2,19 @@
|
|
2
2
|
|
3
3
|
from __future__ import annotations
|
4
4
|
|
5
|
+
from diracx.client._generated.models._models import JobMetaData
|
6
|
+
|
5
7
|
__all__ = [
|
6
8
|
"make_search_body",
|
7
9
|
"SearchKwargs",
|
8
10
|
"make_summary_body",
|
9
11
|
"SummaryKwargs",
|
12
|
+
"prepare_body_for_patch",
|
10
13
|
]
|
11
14
|
|
12
15
|
import json
|
13
|
-
from io import BytesIO
|
14
|
-
from typing import Any, IO, TypedDict, Unpack, cast, Literal
|
16
|
+
from io import BytesIO, IOBase
|
17
|
+
from typing import Any, IO, Dict, TypedDict, Union, Unpack, cast, Literal
|
15
18
|
|
16
19
|
from diracx.core.models import SearchSpec
|
17
20
|
|
@@ -83,3 +86,49 @@ def make_summary_body(**kwargs: Unpack[SummaryKwargs]) -> UnderlyingSummaryArgs:
|
|
83
86
|
result: UnderlyingSummaryArgs = {"body": BytesIO(json.dumps(body).encode("utf-8"))}
|
84
87
|
result.update(cast(ResponseExtra, kwargs))
|
85
88
|
return result
|
89
|
+
|
90
|
+
|
91
|
+
def prepare_body_for_patch(
|
92
|
+
body: Union[Dict[str | int, JobMetaData | Dict[str, Any]], IO[bytes], bytes]
|
93
|
+
) -> Union[Dict[str, JobMetaData], IO[bytes], bytes]:
|
94
|
+
"""Return a body suitable for the generated serializer.
|
95
|
+
|
96
|
+
- If bytes/IO: pass through (caller handles serialization).
|
97
|
+
- If dict: coerce each value to JobMetaData and inject extras.
|
98
|
+
- Accepts pythonic keys (e.g., 'job_type') or wire keys (e.g., 'JobType').
|
99
|
+
"""
|
100
|
+
if isinstance(body, (IOBase, bytes)):
|
101
|
+
return body
|
102
|
+
if not isinstance(body, dict):
|
103
|
+
raise TypeError("body must be a dict[job_id -> JobMetaData|dict] or IO[bytes]")
|
104
|
+
|
105
|
+
attr_map = JobMetaData._attribute_map # type: ignore[attr-defined]
|
106
|
+
py_names = set(attr_map.keys())
|
107
|
+
wire_to_py = {spec["key"]: py for py, spec in attr_map.items()}
|
108
|
+
|
109
|
+
out: Dict[str, JobMetaData] = {}
|
110
|
+
for job_id, metadata in body.items():
|
111
|
+
if isinstance(metadata, JobMetaData):
|
112
|
+
obj = metadata
|
113
|
+
elif isinstance(metadata, dict):
|
114
|
+
init_kwargs: Dict[str, Any] = {}
|
115
|
+
extras: Dict[str, Any] = {}
|
116
|
+
for k, v in metadata.items():
|
117
|
+
# known with no alias
|
118
|
+
if k in py_names:
|
119
|
+
init_kwargs[k] = v
|
120
|
+
# known with alias
|
121
|
+
elif k in wire_to_py:
|
122
|
+
init_kwargs[wire_to_py[k]] = v
|
123
|
+
# unknown -> additional_properties
|
124
|
+
else:
|
125
|
+
extras[k] = v
|
126
|
+
obj = JobMetaData(**init_kwargs)
|
127
|
+
if extras:
|
128
|
+
obj.additional_properties = extras
|
129
|
+
else:
|
130
|
+
raise TypeError(f"metadata for job {job_id!r} must be dict or JobMetaData, not {type(metadata).__name__}")
|
131
|
+
|
132
|
+
out[str(job_id)] = obj
|
133
|
+
|
134
|
+
return out
|
@@ -11,12 +11,13 @@ __all__ = [
|
|
11
11
|
"JobsOperations",
|
12
12
|
]
|
13
13
|
|
14
|
-
from typing import Any, Unpack
|
14
|
+
from typing import IO, Any, Dict, Union, Unpack, cast
|
15
15
|
|
16
16
|
from azure.core.tracing.decorator import distributed_trace
|
17
17
|
|
18
18
|
from ..._generated.operations._operations import JobsOperations as _JobsOperations
|
19
|
-
from .
|
19
|
+
from diracx.client._generated.models._models import JobMetaData
|
20
|
+
from .common import make_search_body, make_summary_body, SearchKwargs, SummaryKwargs, prepare_body_for_patch
|
20
21
|
|
21
22
|
# We're intentionally ignoring overrides here because we want to change the interface.
|
22
23
|
# mypy: disable-error-code=override
|
@@ -32,3 +33,20 @@ class JobsOperations(_JobsOperations):
|
|
32
33
|
def summary(self, **kwargs: Unpack[SummaryKwargs]) -> list[dict[str, Any]]:
|
33
34
|
"""TODO"""
|
34
35
|
return super().summary(**make_summary_body(**kwargs))
|
36
|
+
|
37
|
+
@distributed_trace
|
38
|
+
def patch_metadata( # type: ignore[override]
|
39
|
+
self,
|
40
|
+
body: Union[Dict[str | int, JobMetaData | Dict[str, Any]], IO[bytes], bytes],
|
41
|
+
**kwargs: Any,
|
42
|
+
) -> None:
|
43
|
+
"""Patch Metadata.
|
44
|
+
|
45
|
+
Accepts job ids as str|int and metadata as dicts with pythonic or wire keys.
|
46
|
+
Unknown keys are emitted via `additional_properties`.
|
47
|
+
TODO: Remove this method once we have structured and known job parameters.
|
48
|
+
"""
|
49
|
+
prepared = prepare_body_for_patch(body)
|
50
|
+
# Cast to Any to accommodate generated signature expecting Dict[str, JobMetaData]
|
51
|
+
# while still allowing bytes/IO at runtime.
|
52
|
+
super().patch_metadata(cast(Any, prepared), **kwargs)
|
@@ -24,7 +24,7 @@ diracx/client/_generated/aio/operations/_operations.py,sha256=jp9l6BLGSVjCxzQ1if
|
|
24
24
|
diracx/client/_generated/aio/operations/_patch.py,sha256=jyk2R4wUaClz07zK9TiH6V_SxKakrHNZAUm35lqUC6k,816
|
25
25
|
diracx/client/_generated/models/__init__.py,sha256=fqroW7xud-0lcwH-faWFHBDvDxgKYPNG3qkvb7SDiOk,2928
|
26
26
|
diracx/client/_generated/models/_enums.py,sha256=7ANOVuRfxsJLHSGGh34Nl4PwCBjK7FAbCO9djayU2_0,1808
|
27
|
-
diracx/client/_generated/models/_models.py,sha256=
|
27
|
+
diracx/client/_generated/models/_models.py,sha256=KFOvKVO8jJcy4_Mh49SpjR6PrRnsVKPUQmTJs2c7Onw,57791
|
28
28
|
diracx/client/_generated/models/_patch.py,sha256=D8bxd8gAeLH7RWZNUuzTT7P_dyot9Cey91Rb-UwI2BI,1501
|
29
29
|
diracx/client/_generated/operations/__init__.py,sha256=gtvv0durn3Cr8FUdFImqDcCtCVp7RKULjprmO4jOoeI,1070
|
30
30
|
diracx/client/_generated/operations/_operations.py,sha256=9LrZ2_Qz0CQJwKh3teML-w4qtia4SuMtrvb6rMZrfZw,103882
|
@@ -36,10 +36,10 @@ diracx/client/patches/auth/sync.py,sha256=AUag3E3W9rajGkzXfBuaRp6-kBlS9Ooi7R8QxM
|
|
36
36
|
diracx/client/patches/client/aio.py,sha256=GYUVCgSvlEeJnjVoqdorBAEdP4H6JoC_4L8tlvtAZIE,5330
|
37
37
|
diracx/client/patches/client/common.py,sha256=sWQ4-2iMHl5kwQzfAhny89uOWo8paoYpgp15Ak0UP5c,6243
|
38
38
|
diracx/client/patches/client/sync.py,sha256=AVfGtr0O8KsfX2TrtikftfSNFrZRIaujz_MOuaHKk3U,4720
|
39
|
-
diracx/client/patches/jobs/aio.py,sha256=
|
40
|
-
diracx/client/patches/jobs/common.py,sha256=
|
41
|
-
diracx/client/patches/jobs/sync.py,sha256=
|
39
|
+
diracx/client/patches/jobs/aio.py,sha256=8zUlwKPyx0yUkoxEjUkdYZcErs9jSv1ZEnZTHQeihI4,2047
|
40
|
+
diracx/client/patches/jobs/common.py,sha256=fTlQKEg06RSGG4ccFn-Mk_zSlZofPbpAJCzNtAZrPJA,4263
|
41
|
+
diracx/client/patches/jobs/sync.py,sha256=3tJDAm4Hq0X8DztJtjWPv69UzvIEcv195BG1fruoUN4,1977
|
42
42
|
_diracx_client_importer.pth,sha256=wJwJieKpvzPdCVaM-1oKiKN8OL3wBaHgrl8qyexFoKY,31
|
43
|
-
diracx_client-0.0.
|
44
|
-
diracx_client-0.0.
|
45
|
-
diracx_client-0.0.
|
43
|
+
diracx_client-0.0.1a49.dist-info/METADATA,sha256=VOhKbIbxcGtf7gbrYIL0r1jb0Qg2y5r7SXiJkkpN-7o,606
|
44
|
+
diracx_client-0.0.1a49.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
45
|
+
diracx_client-0.0.1a49.dist-info/RECORD,,
|
File without changes
|