dyff-schema 0.27.2__py3-none-any.whl → 0.27.4__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.
- dyff/schema/__init__.py +29 -2
- dyff/schema/v0/r1/commands.py +0 -1
- dyff/schema/v0/r1/platform.py +3 -5
- dyff/schema/v0/r1/requests.py +24 -0
- {dyff_schema-0.27.2.dist-info → dyff_schema-0.27.4.dist-info}/METADATA +3 -2
- {dyff_schema-0.27.2.dist-info → dyff_schema-0.27.4.dist-info}/RECORD +10 -10
- {dyff_schema-0.27.2.dist-info → dyff_schema-0.27.4.dist-info}/WHEEL +1 -1
- {dyff_schema-0.27.2.dist-info → dyff_schema-0.27.4.dist-info/licenses}/LICENSE +0 -0
- {dyff_schema-0.27.2.dist-info → dyff_schema-0.27.4.dist-info/licenses}/NOTICE +0 -0
- {dyff_schema-0.27.2.dist-info → dyff_schema-0.27.4.dist-info}/top_level.txt +0 -0
dyff/schema/__init__.py
CHANGED
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
# SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
4
|
import importlib
|
|
5
|
-
from typing import Iterable, Type
|
|
5
|
+
from typing import Any, Iterable, Type, TypeVar, Union
|
|
6
6
|
|
|
7
7
|
import pydantic
|
|
8
8
|
|
|
9
|
-
from .base import DyffSchemaBaseModel
|
|
9
|
+
from .base import DyffBaseModel, DyffSchemaBaseModel
|
|
10
10
|
from .version import SomeSchemaVersion
|
|
11
11
|
|
|
12
12
|
|
|
@@ -33,7 +33,34 @@ def named_data_schema(
|
|
|
33
33
|
return _symbol(f"dyff.schema.v{version}.r{revision}.dataset.{name}")
|
|
34
34
|
|
|
35
35
|
|
|
36
|
+
_UpcastTargetT = TypeVar("_UpcastTargetT", bound=DyffBaseModel)
|
|
37
|
+
_UpcastSourceT = TypeVar("_UpcastSourceT", bound=DyffBaseModel)
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def upcast(
|
|
41
|
+
t: type[_UpcastTargetT], obj: Union[_UpcastSourceT, dict[str, Any]]
|
|
42
|
+
) -> _UpcastTargetT:
|
|
43
|
+
"""Perform a "structural upcast" on a Pydantic model instance.
|
|
44
|
+
|
|
45
|
+
An upcast is possible when the top-level fields of the target type are a subset of
|
|
46
|
+
the top-level fields of the source type, and the data in each source field validates
|
|
47
|
+
against the corresponding target field. In particular, an upcast is possible when
|
|
48
|
+
the source type is a Python subclass of the target type.
|
|
49
|
+
|
|
50
|
+
The upcast is "shallow" in the sense that sub-objects must validate as-is. In
|
|
51
|
+
particular, most Dyff schema types do not allow additional properties, so validation
|
|
52
|
+
will fail if a sub-object of the source object has fields that are not present in
|
|
53
|
+
the corresponding sub-object of the target type.
|
|
54
|
+
"""
|
|
55
|
+
if not isinstance(obj, dict):
|
|
56
|
+
# Preserve the unset status
|
|
57
|
+
obj = obj.dict(exclude_unset=True)
|
|
58
|
+
fields = {k: v for k, v in obj.items() if k in t.__fields__}
|
|
59
|
+
return t.parse_obj(fields)
|
|
60
|
+
|
|
61
|
+
|
|
36
62
|
__all__ = [
|
|
37
63
|
"named_data_schema",
|
|
38
64
|
"product_schema",
|
|
65
|
+
"upcast",
|
|
39
66
|
]
|
dyff/schema/v0/r1/commands.py
CHANGED
dyff/schema/v0/r1/platform.py
CHANGED
|
@@ -300,11 +300,8 @@ class EntityIdentifier(DyffSchemaBaseModel):
|
|
|
300
300
|
return EntityIdentifier(kind=entity.kind, id=entity.id)
|
|
301
301
|
|
|
302
302
|
id: str = pydantic.Field(description="The .id of the entity.")
|
|
303
|
-
kind:
|
|
304
|
-
|
|
305
|
-
description="The .kind of the entity. This is optional because"
|
|
306
|
-
" sometimes you need to send a command without knowing the kind,"
|
|
307
|
-
" but it should be set whenever possible.",
|
|
303
|
+
kind: EntityKindLiteral = pydantic.Field(
|
|
304
|
+
description="The .kind of the entity.",
|
|
308
305
|
)
|
|
309
306
|
|
|
310
307
|
|
|
@@ -2477,6 +2474,7 @@ __all__ = [
|
|
|
2477
2474
|
"DyffSchemaBaseModel",
|
|
2478
2475
|
"Entities",
|
|
2479
2476
|
"EntityID",
|
|
2477
|
+
"EntityIdentifier",
|
|
2480
2478
|
"EntityKindLiteral",
|
|
2481
2479
|
"Evaluation",
|
|
2482
2480
|
"EvaluationBase",
|
dyff/schema/v0/r1/requests.py
CHANGED
|
@@ -20,6 +20,7 @@ from typing import Any, Literal, Optional, Union
|
|
|
20
20
|
|
|
21
21
|
import pydantic
|
|
22
22
|
|
|
23
|
+
from ... import upcast
|
|
23
24
|
from . import commands
|
|
24
25
|
from .base import DyffBaseModel, JsonMergePatchSemantics, Null
|
|
25
26
|
from .platform import (
|
|
@@ -29,6 +30,7 @@ from .platform import (
|
|
|
29
30
|
DatasetBase,
|
|
30
31
|
DataView,
|
|
31
32
|
DocumentationBase,
|
|
33
|
+
Evaluation,
|
|
32
34
|
EvaluationBase,
|
|
33
35
|
FamilyBase,
|
|
34
36
|
FamilyMemberBase,
|
|
@@ -197,6 +199,27 @@ class EvaluationCreateRequest(DyffEntityCreateRequest, EvaluationBase):
|
|
|
197
199
|
)
|
|
198
200
|
return values
|
|
199
201
|
|
|
202
|
+
@staticmethod
|
|
203
|
+
def repeat_of(evaluation: Evaluation) -> EvaluationCreateRequest:
|
|
204
|
+
"""Return a request that will run an existing Evaluation again with the same
|
|
205
|
+
configuration."""
|
|
206
|
+
base = upcast(EvaluationBase, evaluation)
|
|
207
|
+
if evaluation.inferenceSessionReference:
|
|
208
|
+
return EvaluationCreateRequest(
|
|
209
|
+
account=evaluation.account,
|
|
210
|
+
inferenceSessionReference=evaluation.inferenceSessionReference,
|
|
211
|
+
**base.dict(),
|
|
212
|
+
)
|
|
213
|
+
else:
|
|
214
|
+
return EvaluationCreateRequest(
|
|
215
|
+
account=evaluation.account,
|
|
216
|
+
inferenceSession=EvaluationInferenceSessionRequest(
|
|
217
|
+
inferenceService=evaluation.inferenceSession.inferenceService.id,
|
|
218
|
+
**upcast(InferenceSessionBase, evaluation.inferenceSession).dict(),
|
|
219
|
+
),
|
|
220
|
+
**base.dict(),
|
|
221
|
+
)
|
|
222
|
+
|
|
200
223
|
|
|
201
224
|
class FamilyCreateRequest(DyffEntityCreateRequest, FamilyBase):
|
|
202
225
|
pass
|
|
@@ -403,6 +426,7 @@ class ScoreQueryRequest(DyffRequestDefaultValidators):
|
|
|
403
426
|
|
|
404
427
|
id: Optional[str] = pydantic.Field(default=None)
|
|
405
428
|
name: Optional[str] = pydantic.Field(default=None)
|
|
429
|
+
analysis: Optional[str] = pydantic.Field(default=None)
|
|
406
430
|
method: Optional[str] = pydantic.Field(default=None)
|
|
407
431
|
methodName: Optional[str] = pydantic.Field(default=None)
|
|
408
432
|
dataset: Optional[str] = pydantic.Field(default=None)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: dyff-schema
|
|
3
|
-
Version: 0.27.
|
|
3
|
+
Version: 0.27.4
|
|
4
4
|
Summary: Data models for the Dyff AI auditing platform.
|
|
5
5
|
Author-email: Digital Safety Research Institute <contact@dsri.org>
|
|
6
6
|
License: Apache-2.0
|
|
@@ -27,6 +27,7 @@ Requires-Dist: jsonpath-ng
|
|
|
27
27
|
Requires-Dist: numpy<2
|
|
28
28
|
Requires-Dist: pyarrow
|
|
29
29
|
Requires-Dist: pydantic<2
|
|
30
|
+
Dynamic: license-file
|
|
30
31
|
|
|
31
32
|
# dyff-schema
|
|
32
33
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
dyff/schema/__init__.py,sha256=
|
|
1
|
+
dyff/schema/__init__.py,sha256=Nua_5EC8HHIxBp6u0SmnApz1WmlYSJ8tDsayD4zEl_Y,2237
|
|
2
2
|
dyff/schema/adapters.py,sha256=YMTHv_2VlLGFp-Kqwa6H51hjffHmk8gXjZilHysIF5Q,123
|
|
3
3
|
dyff/schema/annotations.py,sha256=nE6Jk1PLqlShj8uqjE_EzZC9zYnTDW5AVtQcjysiK8M,10018
|
|
4
4
|
dyff/schema/base.py,sha256=jvaNtsSZyFfsdUZTcY_U-yfLY5_GyrMxSXhON2R9XR0,119
|
|
@@ -25,9 +25,9 @@ dyff/schema/v0/__init__.py,sha256=L5y8UhRnojerPYHumsxQJRcHCNz8Hj9NM8b47mewMNs,92
|
|
|
25
25
|
dyff/schema/v0/r1/__init__.py,sha256=L5y8UhRnojerPYHumsxQJRcHCNz8Hj9NM8b47mewMNs,92
|
|
26
26
|
dyff/schema/v0/r1/adapters.py,sha256=dmQS2ecgDX4ZvTMOW-6NzV_Oq_UpaiyFd7QnSNoOnK8,33057
|
|
27
27
|
dyff/schema/v0/r1/base.py,sha256=Rry7GKdQyCLNXskB1CxqVlhVsgM8pw6a4xy3BFk_lRc,21095
|
|
28
|
-
dyff/schema/v0/r1/commands.py,sha256=
|
|
29
|
-
dyff/schema/v0/r1/platform.py,sha256=
|
|
30
|
-
dyff/schema/v0/r1/requests.py,sha256=
|
|
28
|
+
dyff/schema/v0/r1/commands.py,sha256=HTIgCIwec3nmKOyJ0PstHskfoGeOzB9QVoywUdfl0wU,8331
|
|
29
|
+
dyff/schema/v0/r1/platform.py,sha256=BNKQt-2udkPt7_Qg5s-I0U8m3Sb7eKbQYqvg87rkNfg,81416
|
|
30
|
+
dyff/schema/v0/r1/requests.py,sha256=56R_yOdbDOEcY0og2GoY5bXeG6ifn7z3ypNdBOF_igk,17043
|
|
31
31
|
dyff/schema/v0/r1/test.py,sha256=X6dUyVd5svcPCI-PBMOAqEfK9jv3bRDvkQTJzwS96c0,10720
|
|
32
32
|
dyff/schema/v0/r1/version.py,sha256=isKAGuGxsdru8vDaYmI4YiZdJOu_wNxXK7u6QzD6FE4,392
|
|
33
33
|
dyff/schema/v0/r1/dataset/__init__.py,sha256=LbVlkO2asyGYBKk2z49xjJYTM-pu9y9e4eQDXgTDLnM,2553
|
|
@@ -39,9 +39,9 @@ dyff/schema/v0/r1/dataset/text.py,sha256=nLIn91Zlt0tNdXUklSgjJ-kEDxoPX32ISLkiv2D
|
|
|
39
39
|
dyff/schema/v0/r1/dataset/vision.py,sha256=aIe0fbfM_g3DsrDTdg2K803YKLjZBpurM_VJcJFuZLc,369
|
|
40
40
|
dyff/schema/v0/r1/io/__init__.py,sha256=L5y8UhRnojerPYHumsxQJRcHCNz8Hj9NM8b47mewMNs,92
|
|
41
41
|
dyff/schema/v0/r1/io/vllm.py,sha256=CUE9y8KthtUI7sD49S875rDmPvKotSXVIRaBS79aBZs,5320
|
|
42
|
-
dyff_schema-0.27.
|
|
43
|
-
dyff_schema-0.27.
|
|
44
|
-
dyff_schema-0.27.
|
|
45
|
-
dyff_schema-0.27.
|
|
46
|
-
dyff_schema-0.27.
|
|
47
|
-
dyff_schema-0.27.
|
|
42
|
+
dyff_schema-0.27.4.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
|
43
|
+
dyff_schema-0.27.4.dist-info/licenses/NOTICE,sha256=YONACu0s_Ui6jNi-wtEsVQbTU1JIkh8wvLH6d1-Ni_w,43
|
|
44
|
+
dyff_schema-0.27.4.dist-info/METADATA,sha256=l6FN4G2M1ZLvHNvBGxQ-82U5NL-rBefWVOY_EZzt9zU,3504
|
|
45
|
+
dyff_schema-0.27.4.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
|
|
46
|
+
dyff_schema-0.27.4.dist-info/top_level.txt,sha256=9e3VVdeX73t_sUJOPQPCcGtYO1JhoErhHIi3WoWGcFI,5
|
|
47
|
+
dyff_schema-0.27.4.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|