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

@@ -0,0 +1,4 @@
1
+ # SPDX-FileCopyrightText: 2024 UL Research Institutes
2
+ # SPDX-License-Identifier: Apache-2.0
3
+
4
+ from .v0.r1.commands import *
dyff/schema/v0/r1/base.py CHANGED
@@ -577,6 +577,9 @@ class DyffBaseModel(pydantic.BaseModel):
577
577
  class Config:
578
578
  extra = pydantic.Extra.forbid
579
579
 
580
+ # TODO: (DYFF-223) I think that exclude_unset=True should be the default
581
+ # for all schema objects, but I'm unsure of the consequences of making
582
+ # this change and we'll defer it until v1.
580
583
  def dict(self, *, by_alias: bool = True, **kwargs) -> _ModelAsDict:
581
584
  return super().dict(by_alias=by_alias, **kwargs)
582
585
 
@@ -0,0 +1,201 @@
1
+ # SPDX-FileCopyrightText: 2024 UL Research Institutes
2
+ # SPDX-License-Identifier: Apache-2.0
3
+ """The command schemas describe the API for the command model.
4
+
5
+ These are used internally by the platform and users typically won't encounter them.
6
+ """
7
+
8
+ from __future__ import annotations
9
+
10
+ from typing import Any, Literal, Union
11
+
12
+ import pydantic
13
+
14
+ from .base import DyffSchemaBaseModel
15
+ from .platform import (
16
+ Documented,
17
+ DyffEntityType,
18
+ EntityKindLiteral,
19
+ FamilyMembers,
20
+ Labeled,
21
+ Status,
22
+ )
23
+
24
+ # ----------------------------------------------------------------------------
25
+
26
+
27
+ # mypy gets confused because 'dict' is the name of a method in DyffBaseModel
28
+ _ModelAsDict = dict[str, Any]
29
+
30
+
31
+ class EntityIdentifier(DyffSchemaBaseModel):
32
+ """Identifies a single entity."""
33
+
34
+ @staticmethod
35
+ def of(entity: DyffEntityType) -> EntityIdentifier:
36
+ """Create an identifier that identifies the given entity."""
37
+ return EntityIdentifier(kind=entity.kind, id=entity.id)
38
+
39
+ kind: EntityKindLiteral = pydantic.Field(description="The .kind of the entity.")
40
+ id: str = pydantic.Field(description="The .id of the entity.")
41
+
42
+
43
+ class FamilyIdentifier(EntityIdentifier):
44
+ """Identifies a single Family entity."""
45
+
46
+ kind: Literal["Family"] = "Family"
47
+
48
+
49
+ class Command(DyffSchemaBaseModel):
50
+ """Base class for Command messages.
51
+
52
+ Commands define the API of the "command model" in our CQRS architecture.
53
+ """
54
+
55
+ command: Literal[
56
+ "AppendRevisionToHistory",
57
+ "CreateEntity",
58
+ "EditEntityDocumentation",
59
+ "EditEntityLabels",
60
+ "EditFamilyMembers",
61
+ "ForgetEntity",
62
+ "UpdateEntityStatus",
63
+ ]
64
+
65
+ # TODO: (DYFF-223) I think that exclude_unset=True should be the default
66
+ # for all schema objects, but I'm unsure of the consequences of making
67
+ # this change and we'll defer it until v1.
68
+ def dict(
69
+ self, *, by_alias: bool = True, exclude_unset=True, **kwargs
70
+ ) -> _ModelAsDict:
71
+ return super().dict(by_alias=by_alias, exclude_unset=exclude_unset, **kwargs)
72
+
73
+ def json(self, *, by_alias: bool = True, exclude_unset=True, **kwargs) -> str:
74
+ return super().json(by_alias=by_alias, exclude_unset=exclude_unset, **kwargs)
75
+
76
+
77
+ # ----------------------------------------------------------------------------
78
+
79
+
80
+ class CreateEntity(Command):
81
+ """Create a new entity."""
82
+
83
+ command: Literal["CreateEntity"] = "CreateEntity"
84
+
85
+ data: DyffEntityType = pydantic.Field(
86
+ description="The full spec of the entity to create."
87
+ )
88
+
89
+
90
+ # ----------------------------------------------------------------------------
91
+
92
+
93
+ class EditEntityDocumentationData(Documented, EntityIdentifier):
94
+ """Payload data for the EditEntityDocumentation command."""
95
+
96
+
97
+ class EditEntityDocumentation(Command):
98
+ """Edit the documentation associated with an entity.
99
+
100
+ Setting a documentation field to null/None deletes the corresponding value. To
101
+ preserve the existing value, leave the field *unset*.
102
+ """
103
+
104
+ command: Literal["EditEntityDocumentation"] = "EditEntityDocumentation"
105
+
106
+ data: EditEntityDocumentationData = pydantic.Field(description="The edit data.")
107
+
108
+
109
+ # ----------------------------------------------------------------------------
110
+
111
+
112
+ class EditEntityLabelsData(Labeled, EntityIdentifier):
113
+ """Payload data for the EditEntityLabels command."""
114
+
115
+
116
+ class EditEntityLabels(Command):
117
+ """Edit the labels associated with an entity.
118
+
119
+ Setting a label field to null/None deletes the corresponding value. To preserve the
120
+ existing value, leave the field *unset*.
121
+ """
122
+
123
+ command: Literal["EditEntityLabels"] = "EditEntityLabels"
124
+
125
+ data: EditEntityLabelsData = pydantic.Field(description="The edit data.")
126
+
127
+
128
+ # ----------------------------------------------------------------------------
129
+
130
+
131
+ class EditFamilyMembersData(FamilyMembers, FamilyIdentifier):
132
+ """Payload data for the EditFamilyMembers command."""
133
+
134
+
135
+ class EditFamilyMembers(Command):
136
+ """Edit the labels associated with an entity.
137
+
138
+ Setting a tag value to null/None deletes the corresponding value. To preserve the
139
+ existing value, leave the field *unset*.
140
+ """
141
+
142
+ command: Literal["EditFamilyMembers"] = "EditFamilyMembers"
143
+
144
+ data: EditFamilyMembersData = pydantic.Field(description="The edit data.")
145
+
146
+
147
+ # ----------------------------------------------------------------------------
148
+
149
+
150
+ class ForgetEntity(Command):
151
+ """Forget (permanently delete) an entity."""
152
+
153
+ command: Literal["ForgetEntity"] = "ForgetEntity"
154
+
155
+ data: EntityIdentifier = pydantic.Field(description="The entity to forget.")
156
+
157
+
158
+ # ----------------------------------------------------------------------------
159
+
160
+
161
+ class UpdateEntityStatusData(Status, EntityIdentifier):
162
+ """Payload data for the UpdateEntityStatus command."""
163
+
164
+
165
+ class UpdateEntityStatus(Command):
166
+ """Update the status fields of an entity."""
167
+
168
+ command: Literal["UpdateEntityStatus"] = "UpdateEntityStatus"
169
+
170
+ data: UpdateEntityStatusData = pydantic.Field(description="The status update data.")
171
+
172
+
173
+ # ----------------------------------------------------------------------------
174
+
175
+
176
+ DyffCommandType = Union[
177
+ CreateEntity,
178
+ EditEntityDocumentation,
179
+ EditEntityLabels,
180
+ EditFamilyMembers,
181
+ ForgetEntity,
182
+ UpdateEntityStatus,
183
+ ]
184
+
185
+
186
+ __all__ = [
187
+ "Command",
188
+ "CreateEntity",
189
+ "DyffCommandType",
190
+ "EditEntityDocumentation",
191
+ "EditEntityDocumentationData",
192
+ "EditEntityLabels",
193
+ "EditEntityLabelsData",
194
+ "EditFamilyMembers",
195
+ "EditFamilyMembersData",
196
+ "EntityIdentifier",
197
+ "FamilyIdentifier",
198
+ "ForgetEntity",
199
+ "UpdateEntityStatus",
200
+ "UpdateEntityStatusData",
201
+ ]
@@ -260,6 +260,29 @@ class Resources(str, enum.Enum):
260
260
  raise ValueError(f"No Resources for Entity kind: {kind}")
261
261
 
262
262
 
263
+ EntityKindLiteral = Literal[
264
+ "Analysis",
265
+ "Audit",
266
+ "AuditProcedure",
267
+ "DataSource",
268
+ "Dataset",
269
+ "Evaluation",
270
+ "Family",
271
+ "Hazard",
272
+ "History",
273
+ "InferenceService",
274
+ "InferenceSession",
275
+ "Measurement",
276
+ "Method",
277
+ "Model",
278
+ "Module",
279
+ "Report",
280
+ "Revision",
281
+ "SafetyCase",
282
+ "UseCase",
283
+ ]
284
+
285
+
263
286
  EntityID: TypeAlias = pydantic.constr(regex=entity_id_regex()) # type: ignore
264
287
 
265
288
 
@@ -412,6 +435,13 @@ class Mutable(DyffSchemaBaseModel):
412
435
  lastModificationTime: datetime
413
436
 
414
437
 
438
+ class DyffEntityMetadata(DyffSchemaBaseModel):
439
+ revision: Optional[str] = pydantic.Field(
440
+ default=None,
441
+ description="Unique identifier of the current revision of the entity.",
442
+ )
443
+
444
+
415
445
  class DyffEntity(Status, Labeled, SchemaVersion, DyffModelWithID):
416
446
  kind: Literal[
417
447
  "Analysis",
@@ -435,6 +465,11 @@ class DyffEntity(Status, Labeled, SchemaVersion, DyffModelWithID):
435
465
  "UseCase",
436
466
  ]
437
467
 
468
+ metadata: DyffEntityMetadata = pydantic.Field(
469
+ default_factory=DyffEntityMetadata,
470
+ description="Entity metadata",
471
+ )
472
+
438
473
  annotations: list[Annotation] = pydantic.Field(
439
474
  default_factory=list,
440
475
  description="A set of key-value annotations for the resource. Used to"
@@ -684,7 +719,17 @@ class Family(DyffEntity, FamilyBase, FamilyMembers):
684
719
 
685
720
 
686
721
  class RevisionMetadata(DyffSchemaBaseModel):
687
- creationTime: datetime = pydantic.Field("The time when the Revision was created")
722
+ previousRevision: Optional[str] = pydantic.Field(
723
+ description="The ID of the revision from which this revision was derived."
724
+ "If None, then this is the first revision of the entity."
725
+ )
726
+ creationTime: datetime = pydantic.Field(
727
+ description="The time when the Revision was created"
728
+ )
729
+
730
+
731
+ class ForeignRevision(RevisionMetadata):
732
+ id: str = pydantic.Field(description="Unique identifier of the entity")
688
733
 
689
734
 
690
735
  # Note: The 'Revision' class itself is defined all the way at the end of this
@@ -695,9 +740,13 @@ class RevisionMetadata(DyffSchemaBaseModel):
695
740
  class History(DyffEntity):
696
741
  kind: Literal["History"] = "History"
697
742
 
698
- latest: str = pydantic.Field(description="The ID of the latest Revision")
699
- revisions: dict[str, RevisionMetadata] = pydantic.Field(
700
- description="The set of known Revisions"
743
+ historyOf: str = pydantic.Field(
744
+ description="The ID of the entity described by this History."
745
+ )
746
+
747
+ latest: ForeignRevision = pydantic.Field(description="The latest Revision")
748
+ revisions: list[ForeignRevision] = pydantic.Field(
749
+ description="The list of known Revisions, in chronological order (newest last)."
701
750
  )
702
751
 
703
752
 
@@ -1415,6 +1464,10 @@ class EvaluationClientConfiguration(DyffSchemaBaseModel):
1415
1464
  " Error (default): the evaluation fails. Ignore: no error.",
1416
1465
  )
1417
1466
 
1467
+ requestTimeoutSeconds: int = pydantic.Field(
1468
+ default=30, ge=0, description="The timeout delay for requests."
1469
+ )
1470
+
1418
1471
 
1419
1472
  class EvaluationBase(DyffSchemaBaseModel):
1420
1473
  dataset: str = pydantic.Field(description="The Dataset to evaluate on.")
@@ -2278,7 +2331,7 @@ def entity_class(kind: Entities):
2278
2331
  return _ENTITY_CLASS[kind]
2279
2332
 
2280
2333
 
2281
- DyffEntityTypeExceptRevision = Union[
2334
+ _DyffEntityTypeRevisable = Union[
2282
2335
  Audit,
2283
2336
  AuditProcedure,
2284
2337
  DataSource,
@@ -2286,7 +2339,6 @@ DyffEntityTypeExceptRevision = Union[
2286
2339
  Evaluation,
2287
2340
  Family,
2288
2341
  Hazard,
2289
- History,
2290
2342
  InferenceService,
2291
2343
  InferenceSession,
2292
2344
  Measurement,
@@ -2299,6 +2351,18 @@ DyffEntityTypeExceptRevision = Union[
2299
2351
  ]
2300
2352
 
2301
2353
 
2354
+ class RevisionBody(DyffSchemaBaseModel):
2355
+ format: Literal["Snapshot", "JsonMergePatch"]
2356
+ snapshot: Optional[_DyffEntityTypeRevisable] = pydantic.Field(
2357
+ default=None, description="A full snapshot of the entity."
2358
+ )
2359
+ jsonMergePatch: Optional[str] = pydantic.Field(
2360
+ default=None,
2361
+ description="A JsonMergePatch, serialized as a string, that will"
2362
+ " transform the *current* revision into the *previous* revision.",
2363
+ )
2364
+
2365
+
2302
2366
  # Note: This class is defined here because OpenAPI generation doesn't work
2303
2367
  # with the Python < 3.10 "ForwardDeclaration" syntax. You get an error like:
2304
2368
  #
@@ -2320,12 +2384,16 @@ DyffEntityTypeExceptRevision = Union[
2320
2384
  class Revision(DyffEntity, RevisionMetadata):
2321
2385
  kind: Literal["Revision"] = "Revision"
2322
2386
 
2323
- entity: DyffEntityTypeExceptRevision = pydantic.Field(
2324
- description="The associated entity data",
2387
+ revisionOf: str = pydantic.Field(
2388
+ description="The ID of the entity that this is a revision of"
2389
+ )
2390
+
2391
+ body: RevisionBody = pydantic.Field(
2392
+ description="The associated entity revision data",
2325
2393
  )
2326
2394
 
2327
2395
 
2328
- DyffEntityType = Union[DyffEntityTypeExceptRevision, Revision]
2396
+ DyffEntityType = Union[_DyffEntityTypeRevisable, History, Revision]
2329
2397
 
2330
2398
 
2331
2399
  __all__ = [
@@ -2371,8 +2439,10 @@ __all__ = [
2371
2439
  "DyffSchemaBaseModel",
2372
2440
  "Entities",
2373
2441
  "EntityID",
2442
+ "EntityKindLiteral",
2374
2443
  "Evaluation",
2375
2444
  "EvaluationBase",
2445
+ "EvaluationClientConfiguration",
2376
2446
  "ExtractorStep",
2377
2447
  "Family",
2378
2448
  "FamilyBase",
@@ -2383,6 +2453,7 @@ __all__ = [
2383
2453
  "ForeignInferenceService",
2384
2454
  "ForeignMethod",
2385
2455
  "ForeignModel",
2456
+ "ForeignRevision",
2386
2457
  "Frameworks",
2387
2458
  "Hazard",
2388
2459
  "History",
@@ -2441,6 +2512,7 @@ __all__ = [
2441
2512
  "ReportBase",
2442
2513
  "Resources",
2443
2514
  "Revision",
2515
+ "RevisionBody",
2444
2516
  "RevisionMetadata",
2445
2517
  "Role",
2446
2518
  "SafetyCase",
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: dyff-schema
3
- Version: 0.24.1
3
+ Version: 0.25.0
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
@@ -2,6 +2,7 @@ dyff/schema/__init__.py,sha256=JcpxaRHNYgLjJWLjVayLlqacb2GX49Pazpwb8m-BctM,1031
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
5
+ dyff/schema/commands.py,sha256=hlqMJ99ZF_ElnGF6vQO_T872WM7aClFoFKkAXA66boI,123
5
6
  dyff/schema/copydoc.py,sha256=B4ZRpQmbFxi-3l9LCHvaJiVKb9VxADgC5vey804Febc,1075
6
7
  dyff/schema/errors.py,sha256=ow3yiucU4wGkeLmapUURp3eyaebwGUwDaVTXpPcrA7M,1542
7
8
  dyff/schema/ids.py,sha256=M3kdGRYGPCMnFkRRo0nzHlntdJtBrRwGJ_9R7LlN0bI,2085
@@ -23,8 +24,9 @@ dyff/schema/io/vllm.py,sha256=2q05M_-lTzq9oywKXHPPpCFCSDVCSsRQqtmERzWTtio,123
23
24
  dyff/schema/v0/__init__.py,sha256=L5y8UhRnojerPYHumsxQJRcHCNz8Hj9NM8b47mewMNs,92
24
25
  dyff/schema/v0/r1/__init__.py,sha256=L5y8UhRnojerPYHumsxQJRcHCNz8Hj9NM8b47mewMNs,92
25
26
  dyff/schema/v0/r1/adapters.py,sha256=dmQS2ecgDX4ZvTMOW-6NzV_Oq_UpaiyFd7QnSNoOnK8,33057
26
- dyff/schema/v0/r1/base.py,sha256=IpvlYDr6JjYo6tn8XW4C1Fpgd_uqzZGZsG_cuEn_gQs,19441
27
- dyff/schema/v0/r1/platform.py,sha256=KpTGCS8x1FAkfrMEgbjfDpTGgwNTF28WSuohYnROvj8,78287
27
+ dyff/schema/v0/r1/base.py,sha256=9tzgWKeQrSlLq2HERViDzaNYW6X5m5V6Uf9t8uky_FI,19640
28
+ dyff/schema/v0/r1/commands.py,sha256=8Ixr-NpC1FHrkdyzZMCYLi7CoJNfFfadYPO1D9kfaq0,5653
29
+ dyff/schema/v0/r1/platform.py,sha256=V7ezBMWkbGoDoWAElm-RcvX_5XBQ-BHXN23N3Kab8Rk,80273
28
30
  dyff/schema/v0/r1/requests.py,sha256=4TM1IKG9IP4MyprIy9E9XA_JqvkuwKAuY1ao1BbVLI0,15676
29
31
  dyff/schema/v0/r1/test.py,sha256=X6dUyVd5svcPCI-PBMOAqEfK9jv3bRDvkQTJzwS96c0,10720
30
32
  dyff/schema/v0/r1/version.py,sha256=isKAGuGxsdru8vDaYmI4YiZdJOu_wNxXK7u6QzD6FE4,392
@@ -37,9 +39,9 @@ dyff/schema/v0/r1/dataset/text.py,sha256=nLIn91Zlt0tNdXUklSgjJ-kEDxoPX32ISLkiv2D
37
39
  dyff/schema/v0/r1/dataset/vision.py,sha256=aIe0fbfM_g3DsrDTdg2K803YKLjZBpurM_VJcJFuZLc,369
38
40
  dyff/schema/v0/r1/io/__init__.py,sha256=L5y8UhRnojerPYHumsxQJRcHCNz8Hj9NM8b47mewMNs,92
39
41
  dyff/schema/v0/r1/io/vllm.py,sha256=CUE9y8KthtUI7sD49S875rDmPvKotSXVIRaBS79aBZs,5320
40
- dyff_schema-0.24.1.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
41
- dyff_schema-0.24.1.dist-info/METADATA,sha256=joonUGA6du1G3HJKOTBQE7HuOivJW33vIMw3zNrl3bg,3482
42
- dyff_schema-0.24.1.dist-info/NOTICE,sha256=YONACu0s_Ui6jNi-wtEsVQbTU1JIkh8wvLH6d1-Ni_w,43
43
- dyff_schema-0.24.1.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
44
- dyff_schema-0.24.1.dist-info/top_level.txt,sha256=9e3VVdeX73t_sUJOPQPCcGtYO1JhoErhHIi3WoWGcFI,5
45
- dyff_schema-0.24.1.dist-info/RECORD,,
42
+ dyff_schema-0.25.0.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
43
+ dyff_schema-0.25.0.dist-info/METADATA,sha256=_d_BL3jZLaYU3uknTZDiRpBd1AMSGyY8ZrqPeMeqogs,3482
44
+ dyff_schema-0.25.0.dist-info/NOTICE,sha256=YONACu0s_Ui6jNi-wtEsVQbTU1JIkh8wvLH6d1-Ni_w,43
45
+ dyff_schema-0.25.0.dist-info/WHEEL,sha256=jB7zZ3N9hIM9adW7qlTAyycLYW9npaWKLRzaoVcLKcM,91
46
+ dyff_schema-0.25.0.dist-info/top_level.txt,sha256=9e3VVdeX73t_sUJOPQPCcGtYO1JhoErhHIi3WoWGcFI,5
47
+ dyff_schema-0.25.0.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (75.8.0)
2
+ Generator: setuptools (75.8.2)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5