dyff-schema 0.26.0__py3-none-any.whl → 0.26.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.

@@ -41,8 +41,13 @@ class EntityIdentifier(DyffSchemaBaseModel):
41
41
  """Create an identifier that identifies the given entity."""
42
42
  return EntityIdentifier(kind=entity.kind, id=entity.id)
43
43
 
44
- kind: EntityKindLiteral = pydantic.Field(description="The .kind of the entity.")
45
44
  id: str = pydantic.Field(description="The .id of the entity.")
45
+ kind: Optional[EntityKindLiteral] = pydantic.Field(
46
+ default=None,
47
+ description="The .kind of the entity. This is optional because"
48
+ " sometimes you need to send a command without knowing the kind,"
49
+ " but it should be set whenever possible.",
50
+ )
46
51
 
47
52
 
48
53
  class FamilyIdentifier(EntityIdentifier):
@@ -51,7 +56,7 @@ class FamilyIdentifier(EntityIdentifier):
51
56
  kind: Literal["Family"] = "Family"
52
57
 
53
58
 
54
- class Command(SchemaVersion):
59
+ class Command(SchemaVersion, DyffSchemaBaseModel):
55
60
  """Base class for Command messages.
56
61
 
57
62
  Commands define the API of the "command model" in our CQRS architecture.
@@ -95,17 +100,17 @@ class CreateEntity(Command):
95
100
 
96
101
 
97
102
  class EditEntityDocumentationPatch(DyffSchemaBaseModel):
98
- """Same properties as DocumentationBase, but generates a JSON Schema that allows
99
- fields to be set to JSON 'null'.
103
+ """Same properties as DocumentationBase, but assigning None to a field is
104
+ interpreted as a command to delete that field.
100
105
 
101
- This is needed to get JSON Merge Patch semantics, where explicit 'null' means
102
- "delete that field".
106
+ Fields that are assigned explicitly remain unchanged.
103
107
  """
104
108
 
105
109
  title: Optional[Union[pydantic.constr(max_length=title_maxlen()), Null]] = ( # type: ignore
106
110
  pydantic.Field(
107
111
  default=None,
108
- description='A short plain string suitable as a title or "headline".',
112
+ description='A short plain string suitable as a title or "headline".'
113
+ " Providing an explicit None value deletes the current value.",
109
114
  )
110
115
  )
111
116
 
@@ -113,19 +118,22 @@ class EditEntityDocumentationPatch(DyffSchemaBaseModel):
113
118
  pydantic.Field(
114
119
  default=None,
115
120
  description="A brief summary, suitable for display in"
116
- " small UI elements. Interpreted as Markdown. Excessively long"
117
- " summaries may be truncated in the UI, especially on small displays.",
121
+ " small UI elements. Providing an explicit None value deletes the"
122
+ " current value.",
118
123
  )
119
124
  )
120
125
 
121
126
  fullPage: Optional[Union[str, Null]] = pydantic.Field(
122
127
  default=None,
123
128
  description="Long-form documentation. Interpreted as"
124
- " Markdown. There are no length constraints, but be reasonable.",
129
+ " Markdown. There are no length constraints, but be reasonable."
130
+ " Providing an explicit None value deletes the current value.",
125
131
  )
126
132
 
127
133
 
128
134
  class EditEntityDocumentationAttributes(DyffSchemaBaseModel):
135
+ """Attributes for the EditEntityDocumentation command."""
136
+
129
137
  documentation: EditEntityDocumentationPatch = pydantic.Field(
130
138
  description="Edits to make to the documentation."
131
139
  )
@@ -155,18 +163,13 @@ class EditEntityDocumentation(Command):
155
163
 
156
164
 
157
165
  class EditEntityLabelsAttributes(DyffSchemaBaseModel):
166
+ """Attributes for the EditEntityLabels command."""
167
+
158
168
  labels: dict[LabelKeyType, Optional[Union[LabelValueType, Null]]] = pydantic.Field(
159
169
  default_factory=dict,
160
- description="A set of key-value labels for the resource. Used to"
161
- " specify identifying attributes of resources that are meaningful to"
162
- " users but do not imply semantics in the dyff system.\n\n"
163
- "The keys are DNS labels with an optional DNS domain prefix."
164
- " For example: 'my-key', 'your.com/key_0'. Keys prefixed with"
165
- " 'dyff.io/', 'subdomain.dyff.io/', etc. are reserved.\n\n"
166
- "The label values are alphanumeric characters separated by"
167
- " '.', '-', or '_'.\n\n"
168
- "We follow the kubernetes label conventions closely."
169
- " See: https://kubernetes.io/docs/concepts/overview/working-with-objects/labels",
170
+ description="A set of key-value labels for the resource."
171
+ " Existing label keys that are not provided in the edit remain unchanged."
172
+ " Providing an explicit None value deletes the corresponding key.",
170
173
  )
171
174
 
172
175
 
@@ -194,7 +197,7 @@ class EditEntityLabels(Command):
194
197
 
195
198
 
196
199
  class EditFamilyMembersAttributes(DyffSchemaBaseModel):
197
- """Payload data for the EditFamilyMembers command."""
200
+ """Attributes for the EditFamilyMembers command."""
198
201
 
199
202
  members: dict[TagNameType, Optional[Union[FamilyMember, Null]]] = pydantic.Field(
200
203
  description="Mapping of names to IDs of member resources.",
@@ -236,11 +239,13 @@ class ForgetEntity(Command):
236
239
 
237
240
 
238
241
  class UpdateEntityStatusAttributes(DyffSchemaBaseModel):
242
+ """Attributes for the UpdateEntityStatus command."""
243
+
239
244
  status: str = pydantic.Field(
240
245
  description=Status.__fields__["status"].field_info.description
241
246
  )
242
247
 
243
- reason: Union[str, Null] = pydantic.Field(
248
+ reason: Optional[Union[str, Null]] = pydantic.Field(
244
249
  description=Status.__fields__["reason"].field_info.description
245
250
  )
246
251
 
@@ -305,7 +305,7 @@ def LabelValue() -> type[str]:
305
305
 
306
306
  def TagName() -> type[str]:
307
307
  return pydantic.constr( # type: ignore
308
- regex=_oci_image_tag_regex(), max_length=_k8s_label_key_maxlen()
308
+ regex=_oci_image_tag_regex(), max_length=_oci_image_tag_maxlen()
309
309
  )
310
310
 
311
311
 
@@ -16,11 +16,12 @@ from __future__ import annotations
16
16
 
17
17
  import re
18
18
  from datetime import datetime
19
- from typing import Literal, Optional, Union
19
+ from typing import Any, Literal, Optional, Union
20
20
 
21
21
  import pydantic
22
22
 
23
- from .base import DyffBaseModel, DyffSchemaBaseModel
23
+ from . import commands
24
+ from .base import DyffBaseModel
24
25
  from .platform import (
25
26
  AnalysisBase,
26
27
  AnalysisScope,
@@ -30,10 +31,8 @@ from .platform import (
30
31
  DocumentationBase,
31
32
  EvaluationBase,
32
33
  FamilyBase,
33
- FamilyMembers,
34
34
  InferenceServiceBase,
35
35
  InferenceSessionBase,
36
- Labeled,
37
36
  MethodBase,
38
37
  ModelSpec,
39
38
  ModuleBase,
@@ -43,6 +42,9 @@ from .platform import (
43
42
  )
44
43
  from .version import SchemaVersion
45
44
 
45
+ # mypy gets confused because 'dict' is the name of a method in DyffBaseModel
46
+ _ModelAsDict = dict[str, Any]
47
+
46
48
 
47
49
  class DyffRequestDefaultValidators(DyffBaseModel):
48
50
  """This must be the base class for *all* request models in the Dyff schema.
@@ -62,7 +64,19 @@ class DyffRequestDefaultValidators(DyffBaseModel):
62
64
 
63
65
 
64
66
  class DyffRequestBase(SchemaVersion, DyffRequestDefaultValidators):
65
- pass
67
+ # TODO: (DYFF-223) I think that exclude_unset=True should be the default
68
+ # for all schema objects, but I'm unsure of the consequences of making
69
+ # this change and we'll defer it until v1.
70
+ def dict(
71
+ self, *, by_alias: bool = True, exclude_unset=True, **kwargs
72
+ ) -> _ModelAsDict:
73
+ return super().dict(by_alias=by_alias, exclude_unset=exclude_unset, **kwargs)
74
+
75
+ def json(self, *, by_alias: bool = True, exclude_unset=True, **kwargs) -> str:
76
+ return super().json(by_alias=by_alias, exclude_unset=exclude_unset, **kwargs)
77
+
78
+
79
+ # ----------------------------------------------------------------------------
66
80
 
67
81
 
68
82
  class DyffEntityCreateRequest(DyffRequestBase):
@@ -124,26 +138,6 @@ class DatasetCreateRequest(DyffEntityCreateRequest, DatasetBase):
124
138
  pass
125
139
 
126
140
 
127
- class DocumentationEditRequest(DyffRequestBase, DocumentationBase):
128
- @pydantic.validator("title", check_fields=False)
129
- def _validate_title(cls, title: Optional[str]) -> Optional[str]:
130
- # TODO: This has to be a validator function because we can't apply the
131
- # contraint to DocumentationBase, since there are already entities
132
- # that violate the constraints in the data store. Fix in Schema v1.
133
- if title is not None and len(title) > title_maxlen():
134
- raise ValueError(f".title must have length < {title_maxlen()}")
135
- return title
136
-
137
- @pydantic.validator("summary", check_fields=False)
138
- def _validate_summary(cls, summary: Optional[str]) -> Optional[str]:
139
- # TODO: This has to be a validator function because we can't apply the
140
- # contraint to DocumentationBase, since there are already entities
141
- # that violate the constraints in the data store. Fix in Schema v1.
142
- if summary is not None and len(summary) > summary_maxlen():
143
- raise ValueError(f".summary must have length < {summary_maxlen()}")
144
- return summary
145
-
146
-
147
141
  class InferenceServiceCreateRequest(DyffEntityCreateRequest, InferenceServiceBase):
148
142
  model: Optional[str] = pydantic.Field(
149
143
  default=None, description="ID of Model backing the service, if applicable"
@@ -239,14 +233,35 @@ class ReportCreateRequest(DyffEntityCreateRequest, ReportBase):
239
233
  )
240
234
 
241
235
 
242
- class FamilyMembersEditRequest(DyffRequestBase, FamilyMembers):
236
+ # ----------------------------------------------------------------------------
237
+
238
+
239
+ class DocumentationEditRequest(
240
+ DyffRequestBase, commands.EditEntityDocumentationAttributes
241
+ ):
243
242
  pass
244
243
 
245
244
 
246
- class LabelUpdateRequest(DyffRequestBase, Labeled):
245
+ class FamilyMembersEditRequest(DyffRequestBase, commands.EditFamilyMembersAttributes):
247
246
  pass
248
247
 
249
248
 
249
+ class LabelsEditRequest(DyffRequestBase, commands.EditEntityLabelsAttributes):
250
+ pass
251
+
252
+
253
+ class LabelUpdateRequest(LabelsEditRequest):
254
+ """Deprecated alias for LabelsEditRequest.
255
+
256
+ .. deprecated:: 0.26.0
257
+
258
+ Use LabelsEditRequest
259
+ """
260
+
261
+
262
+ # ----------------------------------------------------------------------------
263
+
264
+
250
265
  # Note: Query requests, as they currently exist, don't work with Versioned
251
266
  # because fastapi will assign None to every field that the client doesn't
252
267
  # specify. I think it's not that important, because all of the query parameters
@@ -418,6 +433,7 @@ __all__ = [
418
433
  "InferenceSessionQueryRequest",
419
434
  "InferenceSessionTokenCreateRequest",
420
435
  "LabelUpdateRequest",
436
+ "LabelsEditRequest",
421
437
  "MeasurementQueryRequest",
422
438
  "MethodCreateRequest",
423
439
  "MethodQueryRequest",
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: dyff-schema
3
- Version: 0.26.0
3
+ Version: 0.26.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
@@ -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=OW05Wn2ZHBpeutj2sx93jcD1cz4kLzRvRZ_y2dS53lo,20206
28
- dyff/schema/v0/r1/commands.py,sha256=GUeD5wx-ZkfqLpQa6iI4joq_AVTxR1gFvmluA9AZ1G4,9136
29
- dyff/schema/v0/r1/platform.py,sha256=ndOu5kOfkQOjfFQ0bX8sp0IvMO1xcVMmpWU0LMQeS88,80754
30
- dyff/schema/v0/r1/requests.py,sha256=4TM1IKG9IP4MyprIy9E9XA_JqvkuwKAuY1ao1BbVLI0,15676
28
+ dyff/schema/v0/r1/commands.py,sha256=8PN_oBKLOJ7vweMVA01BtrURyN2LjC2C9WMO8Ki-NJI,9136
29
+ dyff/schema/v0/r1/platform.py,sha256=iXlDpL45W8m9RMhEWgFkuDW7rOEwiK18gnu8dgYzRaA,80754
30
+ dyff/schema/v0/r1/requests.py,sha256=ZoaT_g7dPKIWtibWJFwlbuMJ2dXqIkS8h9mJ-7VnLr4,15789
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.26.0.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
43
- dyff_schema-0.26.0.dist-info/METADATA,sha256=FNMFyld3y1bRhDrQF8H9WILabZKxeo5zkazsLkCrnkU,3482
44
- dyff_schema-0.26.0.dist-info/NOTICE,sha256=YONACu0s_Ui6jNi-wtEsVQbTU1JIkh8wvLH6d1-Ni_w,43
45
- dyff_schema-0.26.0.dist-info/WHEEL,sha256=52BFRY2Up02UkjOa29eZOS2VxUrpPORXg1pkohGGUS8,91
46
- dyff_schema-0.26.0.dist-info/top_level.txt,sha256=9e3VVdeX73t_sUJOPQPCcGtYO1JhoErhHIi3WoWGcFI,5
47
- dyff_schema-0.26.0.dist-info/RECORD,,
42
+ dyff_schema-0.26.2.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
43
+ dyff_schema-0.26.2.dist-info/METADATA,sha256=7Fnl0skcl3BUYwrW3R6OO6-v7rMuRkItvbSa68k40nI,3482
44
+ dyff_schema-0.26.2.dist-info/NOTICE,sha256=YONACu0s_Ui6jNi-wtEsVQbTU1JIkh8wvLH6d1-Ni_w,43
45
+ dyff_schema-0.26.2.dist-info/WHEEL,sha256=52BFRY2Up02UkjOa29eZOS2VxUrpPORXg1pkohGGUS8,91
46
+ dyff_schema-0.26.2.dist-info/top_level.txt,sha256=9e3VVdeX73t_sUJOPQPCcGtYO1JhoErhHIi3WoWGcFI,5
47
+ dyff_schema-0.26.2.dist-info/RECORD,,