dyff-schema 0.27.0__py3-none-any.whl → 0.27.2__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.

Potentially problematic release.


This version of dyff-schema might be problematic. Click here for more details.

dyff/schema/v0/r1/base.py CHANGED
@@ -658,6 +658,29 @@ class DyffSchemaBaseModel(DyffBaseModel):
658
658
  return values
659
659
 
660
660
 
661
+ class JsonMergePatchSemantics(DyffSchemaBaseModel):
662
+ """Explicit None values will be output as json 'null', and fields that are not set
663
+ explicitly are not output.
664
+
665
+ In JSON Merge Patch terms, None means "delete this field", and not setting a value
666
+ means "leave this field unchanged".
667
+ """
668
+
669
+ def dict(
670
+ self, *, by_alias: bool = True, exclude_unset=True, exclude_none=False, **kwargs
671
+ ) -> _ModelAsDict:
672
+ return super().dict(
673
+ by_alias=by_alias, exclude_unset=True, exclude_none=False, **kwargs
674
+ )
675
+
676
+ def json(
677
+ self, *, by_alias: bool = True, exclude_unset=True, exclude_none=False, **kwargs
678
+ ) -> str:
679
+ return super().json(
680
+ by_alias=by_alias, exclude_unset=True, exclude_none=False, **kwargs
681
+ )
682
+
683
+
661
684
  __all__ = [
662
685
  "DTYPE",
663
686
  "DType",
@@ -671,6 +694,7 @@ __all__ = [
671
694
  "Int16",
672
695
  "Int32",
673
696
  "Int64",
697
+ "JsonMergePatchSemantics",
674
698
  "Null",
675
699
  "UInt8",
676
700
  "UInt16",
@@ -7,13 +7,14 @@ These are used internally by the platform and users typically won't encounter th
7
7
 
8
8
  from __future__ import annotations
9
9
 
10
- from typing import Any, Literal, Optional, Union
10
+ from typing import Literal, Optional, Union
11
11
 
12
12
  import pydantic
13
13
 
14
- from .base import DyffSchemaBaseModel, Null
14
+ from .base import DyffSchemaBaseModel, JsonMergePatchSemantics, Null
15
15
  from .platform import (
16
16
  DyffEntityType,
17
+ EntityIdentifier,
17
18
  EntityKindLiteral,
18
19
  FamilyMember,
19
20
  FamilyMembers,
@@ -29,29 +30,6 @@ from .platform import (
29
30
  # ----------------------------------------------------------------------------
30
31
 
31
32
 
32
- # mypy gets confused because 'dict' is the name of a method in DyffBaseModel
33
- _ModelAsDict = dict[str, Any]
34
-
35
-
36
- class _JsonMergePatchSemantics(DyffSchemaBaseModel):
37
- """Explicit None values will be output as json 'null', and fields that are not set
38
- explicitly are not output.
39
-
40
- In JSON Merge Patch terms, None means "delete this field", and not setting a value
41
- means "leave this field unchanged".
42
- """
43
-
44
- def dict(self, *, by_alias: bool = True, **kwargs) -> _ModelAsDict:
45
- return super().dict(
46
- by_alias=by_alias, exclude_unset=True, exclude_none=False, **kwargs
47
- )
48
-
49
- def json(self, *, by_alias: bool = True, **kwargs) -> str:
50
- return super().json(
51
- by_alias=by_alias, exclude_unset=True, exclude_none=False, **kwargs
52
- )
53
-
54
-
55
33
  # class _NoneMeansUndefined(DyffSchemaBaseModel):
56
34
  # """Fields with the value None will not be emitted in the JSON output."""
57
35
 
@@ -64,23 +42,6 @@ class _JsonMergePatchSemantics(DyffSchemaBaseModel):
64
42
  # return super().json(exclude_none=True, **kwargs)
65
43
 
66
44
 
67
- class EntityIdentifier(DyffSchemaBaseModel):
68
- """Identifies a single entity."""
69
-
70
- @staticmethod
71
- def of(entity: DyffEntityType) -> EntityIdentifier:
72
- """Create an identifier that identifies the given entity."""
73
- return EntityIdentifier(kind=entity.kind, id=entity.id)
74
-
75
- id: str = pydantic.Field(description="The .id of the entity.")
76
- kind: Optional[EntityKindLiteral] = pydantic.Field(
77
- default=None,
78
- description="The .kind of the entity. This is optional because"
79
- " sometimes you need to send a command without knowing the kind,"
80
- " but it should be set whenever possible.",
81
- )
82
-
83
-
84
45
  class FamilyIdentifier(EntityIdentifier):
85
46
  """Identifies a single Family entity."""
86
47
 
@@ -119,7 +80,7 @@ class CreateEntity(Command):
119
80
  # ----------------------------------------------------------------------------
120
81
 
121
82
 
122
- class EditEntityDocumentationPatch(_JsonMergePatchSemantics):
83
+ class EditEntityDocumentationPatch(JsonMergePatchSemantics):
123
84
  """Same properties as DocumentationBase, but assigning None to a field is
124
85
  interpreted as a command to delete that field.
125
86
 
@@ -182,7 +143,7 @@ class EditEntityDocumentation(Command):
182
143
  # ----------------------------------------------------------------------------
183
144
 
184
145
 
185
- class EditEntityLabelsAttributes(_JsonMergePatchSemantics):
146
+ class EditEntityLabelsAttributes(JsonMergePatchSemantics):
186
147
  """Attributes for the EditEntityLabels command."""
187
148
 
188
149
  labels: dict[LabelKeyType, Optional[Union[LabelValueType, Null]]] = pydantic.Field(
@@ -216,7 +177,7 @@ class EditEntityLabels(Command):
216
177
  # ----------------------------------------------------------------------------
217
178
 
218
179
 
219
- class EditFamilyMembersAttributes(_JsonMergePatchSemantics):
180
+ class EditFamilyMembersAttributes(JsonMergePatchSemantics):
220
181
  """Attributes for the EditFamilyMembers command."""
221
182
 
222
183
  members: dict[TagNameType, Optional[Union[FamilyMember, Null]]] = pydantic.Field(
@@ -258,7 +219,7 @@ class ForgetEntity(Command):
258
219
  # ----------------------------------------------------------------------------
259
220
 
260
221
 
261
- class UpdateEntityStatusAttributes(_JsonMergePatchSemantics):
222
+ class UpdateEntityStatusAttributes(JsonMergePatchSemantics):
262
223
  """Attributes for the UpdateEntityStatus command."""
263
224
 
264
225
  status: str = pydantic.Field(
@@ -291,6 +291,23 @@ class DyffModelWithID(DyffSchemaBaseModel):
291
291
  account: str = pydantic.Field(description="Account that owns the entity")
292
292
 
293
293
 
294
+ class EntityIdentifier(DyffSchemaBaseModel):
295
+ """Identifies a single entity."""
296
+
297
+ @staticmethod
298
+ def of(entity: "DyffEntityType") -> "EntityIdentifier":
299
+ """Create an identifier that identifies the given entity."""
300
+ return EntityIdentifier(kind=entity.kind, id=entity.id)
301
+
302
+ id: str = pydantic.Field(description="The .id of the entity.")
303
+ kind: Optional[EntityKindLiteral] = pydantic.Field(
304
+ default=None,
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.",
308
+ )
309
+
310
+
294
311
  def LabelKey() -> type[str]:
295
312
  return pydantic.constr(
296
313
  regex=_k8s_label_key_regex(), max_length=_k8s_label_key_maxlen()
@@ -682,24 +699,24 @@ class FamilyMemberKind(str, enum.Enum):
682
699
 
683
700
 
684
701
  class FamilyMemberBase(DyffSchemaBaseModel):
685
- name: TagNameType = pydantic.Field(
686
- description="An interpretable identifier for the member that is unique"
687
- " in the context of the corresponding Family.",
688
- )
689
-
690
- resource: str = pydantic.Field(
702
+ entity: EntityIdentifier = pydantic.Field(
691
703
  description="ID of the resource this member references.",
692
704
  )
693
705
 
694
- description: Optional[str] = pydantic.Field(
706
+ description: Optional[pydantic.constr(max_length=summary_maxlen())] = pydantic.Field( # type: ignore
695
707
  default=None,
696
- description="A short description of the member. Interpreted as Markdown."
697
- " This should include information about how this version of the resource"
708
+ description="A short description of the member."
709
+ " This should describe how this version of the resource"
698
710
  " is different from other versions.",
699
711
  )
700
712
 
701
713
 
702
714
  class FamilyMember(FamilyMemberBase):
715
+ name: TagNameType = pydantic.Field(
716
+ description="An interpretable identifier for the member that is unique"
717
+ " in the context of the corresponding Family.",
718
+ )
719
+
703
720
  family: str = pydantic.Field(
704
721
  description="Identifier of the Family containing this tag."
705
722
  )
@@ -725,6 +742,12 @@ class FamilyBase(DyffSchemaBaseModel):
725
742
  class Family(DyffEntity, FamilyBase, FamilyMembers):
726
743
  kind: Literal["Family"] = "Family"
727
744
 
745
+ def dependencies(self) -> list[str]:
746
+ return []
747
+
748
+ def resource_allocation(self) -> Optional[ResourceAllocation]:
749
+ return None
750
+
728
751
 
729
752
  class RevisionMetadata(DyffSchemaBaseModel):
730
753
  previousRevision: Optional[str] = pydantic.Field(
@@ -21,7 +21,7 @@ from typing import Any, Literal, Optional, Union
21
21
  import pydantic
22
22
 
23
23
  from . import commands
24
- from .base import DyffBaseModel
24
+ from .base import DyffBaseModel, JsonMergePatchSemantics, Null
25
25
  from .platform import (
26
26
  AnalysisBase,
27
27
  AnalysisScope,
@@ -31,12 +31,14 @@ from .platform import (
31
31
  DocumentationBase,
32
32
  EvaluationBase,
33
33
  FamilyBase,
34
+ FamilyMemberBase,
34
35
  InferenceServiceBase,
35
36
  InferenceSessionBase,
36
37
  MethodBase,
37
38
  ModelSpec,
38
39
  ModuleBase,
39
40
  ReportBase,
41
+ TagNameType,
40
42
  summary_maxlen,
41
43
  title_maxlen,
42
44
  )
@@ -242,8 +244,12 @@ class DocumentationEditRequest(
242
244
  pass
243
245
 
244
246
 
245
- class FamilyMembersEditRequest(DyffRequestBase, commands.EditFamilyMembersAttributes):
246
- pass
247
+ class FamilyMembersEditRequest(DyffRequestBase, JsonMergePatchSemantics):
248
+ members: dict[TagNameType, Optional[Union[FamilyMemberBase, Null]]] = (
249
+ pydantic.Field(
250
+ description="Mapping of names to IDs of member resources.",
251
+ )
252
+ )
247
253
 
248
254
 
249
255
  class LabelsEditRequest(DyffRequestBase, commands.EditEntityLabelsAttributes):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: dyff-schema
3
- Version: 0.27.0
3
+ Version: 0.27.2
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
@@ -24,10 +24,10 @@ dyff/schema/io/vllm.py,sha256=2q05M_-lTzq9oywKXHPPpCFCSDVCSsRQqtmERzWTtio,123
24
24
  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
- dyff/schema/v0/r1/base.py,sha256=fSWeuiArzt7MOdLGqQPPNW4IPye-6EBrHSikFllQXxQ,20273
28
- dyff/schema/v0/r1/commands.py,sha256=7kP8G4amtvt3pRd01PHusV3EYGrYX82pV2GFe4WcitE,9752
29
- dyff/schema/v0/r1/platform.py,sha256=-HbsM-cHmm7HiLiVx-1vPQ4S8SqZqHK3UXwuCBtJi-g,80753
30
- dyff/schema/v0/r1/requests.py,sha256=ZoaT_g7dPKIWtibWJFwlbuMJ2dXqIkS8h9mJ-7VnLr4,15789
27
+ dyff/schema/v0/r1/base.py,sha256=Rry7GKdQyCLNXskB1CxqVlhVsgM8pw6a4xy3BFk_lRc,21095
28
+ dyff/schema/v0/r1/commands.py,sha256=eBXoDxmRZ9s2Idj1srmIaLPCn6QVbWXwpbNDHaJZDco,8354
29
+ dyff/schema/v0/r1/platform.py,sha256=mXI32MyJNVAYjT3xQtwlaysU6u_K6p9bb7phErayCq0,81574
30
+ dyff/schema/v0/r1/requests.py,sha256=AIBzfOnDEMVh1sCOCM6oKMVwZTCW3v9f5BVKB2s3-X0,16025
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.0.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
43
- dyff_schema-0.27.0.dist-info/METADATA,sha256=sCwQZWjkkkWNhuiV0OJ9FuQa2ddUVHsVvZqXOjhRKKs,3482
44
- dyff_schema-0.27.0.dist-info/NOTICE,sha256=YONACu0s_Ui6jNi-wtEsVQbTU1JIkh8wvLH6d1-Ni_w,43
45
- dyff_schema-0.27.0.dist-info/WHEEL,sha256=52BFRY2Up02UkjOa29eZOS2VxUrpPORXg1pkohGGUS8,91
46
- dyff_schema-0.27.0.dist-info/top_level.txt,sha256=9e3VVdeX73t_sUJOPQPCcGtYO1JhoErhHIi3WoWGcFI,5
47
- dyff_schema-0.27.0.dist-info/RECORD,,
42
+ dyff_schema-0.27.2.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
43
+ dyff_schema-0.27.2.dist-info/METADATA,sha256=ajCQ1ZTd0A7GA8g9h6Y-sx0SFHLJHDBqlr9ihKD8Qeg,3482
44
+ dyff_schema-0.27.2.dist-info/NOTICE,sha256=YONACu0s_Ui6jNi-wtEsVQbTU1JIkh8wvLH6d1-Ni_w,43
45
+ dyff_schema-0.27.2.dist-info/WHEEL,sha256=52BFRY2Up02UkjOa29eZOS2VxUrpPORXg1pkohGGUS8,91
46
+ dyff_schema-0.27.2.dist-info/top_level.txt,sha256=9e3VVdeX73t_sUJOPQPCcGtYO1JhoErhHIi3WoWGcFI,5
47
+ dyff_schema-0.27.2.dist-info/RECORD,,