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

@@ -194,11 +194,13 @@ class Entities(str, enum.Enum):
194
194
  Analysis = "Analysis"
195
195
  Audit = "Audit"
196
196
  AuditProcedure = "AuditProcedure"
197
+ Concern = "Concern"
197
198
  DataSource = "DataSource"
198
199
  Dataset = "Dataset"
199
200
  Documentation = "Documentation"
200
201
  Evaluation = "Evaluation"
201
202
  Family = "Family"
203
+ Hazard = "Hazard"
202
204
  History = "History"
203
205
  InferenceService = "InferenceService"
204
206
  InferenceSession = "InferenceSession"
@@ -210,6 +212,7 @@ class Entities(str, enum.Enum):
210
212
  Revision = "Revision"
211
213
  SafetyCase = "SafetyCase"
212
214
  Score = "Score"
215
+ UseCase = "UseCase"
213
216
 
214
217
 
215
218
  class Resources(str, enum.Enum):
@@ -218,11 +221,14 @@ class Resources(str, enum.Enum):
218
221
  Analysis = "analyses"
219
222
  Audit = "audits"
220
223
  AuditProcedure = "auditprocedures"
224
+ Concern = "concerns"
221
225
  Dataset = "datasets"
222
226
  DataSource = "datasources"
227
+ Descriptor = "descriptors"
223
228
  Documentation = "documentation"
224
229
  Evaluation = "evaluations"
225
230
  Family = "families"
231
+ Hazard = "hazards"
226
232
  History = "histories"
227
233
  InferenceService = "inferenceservices"
228
234
  InferenceSession = "inferencesessions"
@@ -234,6 +240,7 @@ class Resources(str, enum.Enum):
234
240
  Revision = "revisions"
235
241
  SafetyCase = "safetycases"
236
242
  Score = "scores"
243
+ UseCase = "usecases"
237
244
 
238
245
  Task = "tasks"
239
246
  """
@@ -396,6 +403,15 @@ class Documented(DyffSchemaBaseModel):
396
403
  )
397
404
 
398
405
 
406
+ class Metadata(DyffSchemaBaseModel):
407
+ pass
408
+
409
+
410
+ class Mutable(DyffSchemaBaseModel):
411
+ etag: str
412
+ lastModificationTime: datetime
413
+
414
+
399
415
  class DyffEntity(Status, Labeled, SchemaVersion, DyffModelWithID):
400
416
  kind: Literal[
401
417
  "Analysis",
@@ -405,6 +421,7 @@ class DyffEntity(Status, Labeled, SchemaVersion, DyffModelWithID):
405
421
  "Dataset",
406
422
  "Evaluation",
407
423
  "Family",
424
+ "Hazard",
408
425
  "History",
409
426
  "InferenceService",
410
427
  "InferenceSession",
@@ -415,6 +432,7 @@ class DyffEntity(Status, Labeled, SchemaVersion, DyffModelWithID):
415
432
  "Report",
416
433
  "Revision",
417
434
  "SafetyCase",
435
+ "UseCase",
418
436
  ]
419
437
 
420
438
  annotations: list[Annotation] = pydantic.Field(
@@ -683,6 +701,32 @@ class History(DyffEntity):
683
701
  )
684
702
 
685
703
 
704
+ class ConcernBase(Documented):
705
+ pass
706
+
707
+
708
+ class Concern(ConcernBase, DyffEntity):
709
+ def label_key(self) -> str:
710
+ return f"{Resources[self.kind].value}.dyff.io/{self.id}"
711
+
712
+ def label_value(self) -> str:
713
+ return "1"
714
+
715
+ def dependencies(self) -> list[str]:
716
+ return []
717
+
718
+ def resource_allocation(self) -> Optional[ResourceAllocation]:
719
+ return None
720
+
721
+
722
+ class Hazard(Concern):
723
+ kind: Literal["Hazard"] = Entities.Hazard.value
724
+
725
+
726
+ class UseCase(Concern):
727
+ kind: Literal["UseCase"] = Entities.UseCase.value
728
+
729
+
686
730
  # ----------------------------------------------------------------------------
687
731
 
688
732
 
@@ -1727,6 +1771,16 @@ class MethodBase(DyffSchemaBaseModel):
1727
1771
  return scores
1728
1772
 
1729
1773
 
1774
+ class MethodMetadata(Metadata):
1775
+ concerns: list[Concern] = pydantic.Field(
1776
+ default_factory=list, description="The Concerns applicable to this Method."
1777
+ )
1778
+
1779
+
1780
+ class ModelMetadata(Metadata):
1781
+ pass
1782
+
1783
+
1730
1784
  class Method(DyffEntity, MethodBase):
1731
1785
  kind: Literal["Method"] = Entities.Method.value
1732
1786
 
@@ -2169,6 +2223,7 @@ DyffEntityTypeExceptRevision = Union[
2169
2223
  Dataset,
2170
2224
  Evaluation,
2171
2225
  Family,
2226
+ Hazard,
2172
2227
  History,
2173
2228
  InferenceService,
2174
2229
  InferenceSession,
@@ -2178,6 +2233,7 @@ DyffEntityTypeExceptRevision = Union[
2178
2233
  Module,
2179
2234
  Report,
2180
2235
  SafetyCase,
2236
+ UseCase,
2181
2237
  ]
2182
2238
 
2183
2239
 
@@ -2232,6 +2288,8 @@ __all__ = [
2232
2288
  "Audit",
2233
2289
  "AuditProcedure",
2234
2290
  "AuditRequirement",
2291
+ "Concern",
2292
+ "ConcernBase",
2235
2293
  "ContainerImageSource",
2236
2294
  "DataSchema",
2237
2295
  "Dataset",
@@ -2243,6 +2301,7 @@ __all__ = [
2243
2301
  "Digest",
2244
2302
  "Documentation",
2245
2303
  "DocumentationBase",
2304
+ "Documented",
2246
2305
  "DyffDataSchema",
2247
2306
  "DyffEntity",
2248
2307
  "DyffEntityType",
@@ -2263,6 +2322,7 @@ __all__ = [
2263
2322
  "ForeignMethod",
2264
2323
  "ForeignModel",
2265
2324
  "Frameworks",
2325
+ "Hazard",
2266
2326
  "History",
2267
2327
  "Identity",
2268
2328
  "InferenceInterface",
@@ -2333,6 +2393,7 @@ __all__ = [
2333
2393
  "StorageSignedURL",
2334
2394
  "TagName",
2335
2395
  "TaskSchema",
2396
+ "UseCase",
2336
2397
  "entity_class",
2337
2398
  "JobStatus",
2338
2399
  "EntityStatus",
@@ -24,6 +24,7 @@ from .base import DyffBaseModel
24
24
  from .platform import (
25
25
  AnalysisBase,
26
26
  AnalysisScope,
27
+ ConcernBase,
27
28
  DatasetBase,
28
29
  DataView,
29
30
  DocumentationBase,
@@ -37,6 +38,8 @@ from .platform import (
37
38
  ModelSpec,
38
39
  ModuleBase,
39
40
  ReportBase,
41
+ summary_maxlen,
42
+ title_maxlen,
40
43
  )
41
44
  from .version import SchemaVersion
42
45
 
@@ -92,12 +95,53 @@ class AnalysisCreateRequest(DyffEntityCreateRequest, AnalysisBase):
92
95
  return scope
93
96
 
94
97
 
98
+ class ConcernCreateRequest(DyffEntityCreateRequest, ConcernBase):
99
+ @pydantic.validator("documentation", check_fields=False)
100
+ def _validate_documentation(
101
+ cls, documentation: DocumentationBase
102
+ ) -> DocumentationBase:
103
+ # TODO: This has to be a validator function because we can't apply the
104
+ # contraint to DocumentationBase, since there are already entities
105
+ # that violate the constraints in the data store. Fix in Schema v1.
106
+ if (
107
+ documentation.title is not None
108
+ and len(documentation.title) > title_maxlen()
109
+ ):
110
+ raise ValueError(
111
+ f".documentation.title must have length < {title_maxlen()}"
112
+ )
113
+ if (
114
+ documentation.summary is not None
115
+ and len(documentation.summary) > summary_maxlen()
116
+ ):
117
+ raise ValueError(
118
+ f".documentation.summary must have length < {summary_maxlen()}"
119
+ )
120
+ return documentation
121
+
122
+
95
123
  class DatasetCreateRequest(DyffEntityCreateRequest, DatasetBase):
96
124
  pass
97
125
 
98
126
 
99
127
  class DocumentationEditRequest(DyffRequestBase, DocumentationBase):
100
- pass
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
101
145
 
102
146
 
103
147
  class InferenceServiceCreateRequest(DyffEntityCreateRequest, InferenceServiceBase):
@@ -330,9 +374,14 @@ class ScoreQueryRequest(DyffRequestDefaultValidators):
330
374
  model: Optional[str] = pydantic.Field(default=None)
331
375
 
332
376
 
377
+ class UseCaseQueryRequest(DyffEntityQueryRequest):
378
+ pass
379
+
380
+
333
381
  __all__ = [
334
382
  "AnalysisCreateRequest",
335
383
  "AuditQueryRequest",
384
+ "ConcernCreateRequest",
336
385
  "DyffEntityCreateRequest",
337
386
  "DyffEntityQueryRequest",
338
387
  "DyffRequestBase",
@@ -364,4 +413,5 @@ __all__ = [
364
413
  "ReportQueryRequest",
365
414
  "SafetyCaseQueryRequest",
366
415
  "ScoreQueryRequest",
416
+ "UseCaseQueryRequest",
367
417
  ]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: dyff-schema
3
- Version: 0.19.0
3
+ Version: 0.20.1
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,8 +24,8 @@ dyff/schema/v0/__init__.py,sha256=L5y8UhRnojerPYHumsxQJRcHCNz8Hj9NM8b47mewMNs,92
24
24
  dyff/schema/v0/r1/__init__.py,sha256=L5y8UhRnojerPYHumsxQJRcHCNz8Hj9NM8b47mewMNs,92
25
25
  dyff/schema/v0/r1/adapters.py,sha256=2t2oxsnGfSEDKKDIEYw4qqLXMH7qlFIwPVuLyUmbsHs,23552
26
26
  dyff/schema/v0/r1/base.py,sha256=IpvlYDr6JjYo6tn8XW4C1Fpgd_uqzZGZsG_cuEn_gQs,19441
27
- dyff/schema/v0/r1/platform.py,sha256=c-XBKsACEmz_VptGDGCDsULGYtxDajVZ6H7mzjxXHGY,74405
28
- dyff/schema/v0/r1/requests.py,sha256=UC2jK_upahjemie2s_Acg9xd4NDlwlwUUAOGnpI2iS0,13058
27
+ dyff/schema/v0/r1/platform.py,sha256=bvROO9WEOV257C_QSWuWeDLCFegaYl116YvMP-AClUE,75609
28
+ dyff/schema/v0/r1/requests.py,sha256=3aLqBchrwoFg18ZrVGU938Zo3B4G2o-zzHA2r7noEDc,15259
29
29
  dyff/schema/v0/r1/test.py,sha256=X6dUyVd5svcPCI-PBMOAqEfK9jv3bRDvkQTJzwS96c0,10720
30
30
  dyff/schema/v0/r1/version.py,sha256=isKAGuGxsdru8vDaYmI4YiZdJOu_wNxXK7u6QzD6FE4,392
31
31
  dyff/schema/v0/r1/dataset/__init__.py,sha256=LbVlkO2asyGYBKk2z49xjJYTM-pu9y9e4eQDXgTDLnM,2553
@@ -37,9 +37,9 @@ dyff/schema/v0/r1/dataset/text.py,sha256=nLIn91Zlt0tNdXUklSgjJ-kEDxoPX32ISLkiv2D
37
37
  dyff/schema/v0/r1/dataset/vision.py,sha256=aIe0fbfM_g3DsrDTdg2K803YKLjZBpurM_VJcJFuZLc,369
38
38
  dyff/schema/v0/r1/io/__init__.py,sha256=L5y8UhRnojerPYHumsxQJRcHCNz8Hj9NM8b47mewMNs,92
39
39
  dyff/schema/v0/r1/io/vllm.py,sha256=CUE9y8KthtUI7sD49S875rDmPvKotSXVIRaBS79aBZs,5320
40
- dyff_schema-0.19.0.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
41
- dyff_schema-0.19.0.dist-info/METADATA,sha256=r7aFHs035B-teQqNrDhlCKYNSicfqzmwXU_8ADCAigo,3482
42
- dyff_schema-0.19.0.dist-info/NOTICE,sha256=YONACu0s_Ui6jNi-wtEsVQbTU1JIkh8wvLH6d1-Ni_w,43
43
- dyff_schema-0.19.0.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
44
- dyff_schema-0.19.0.dist-info/top_level.txt,sha256=9e3VVdeX73t_sUJOPQPCcGtYO1JhoErhHIi3WoWGcFI,5
45
- dyff_schema-0.19.0.dist-info/RECORD,,
40
+ dyff_schema-0.20.1.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
41
+ dyff_schema-0.20.1.dist-info/METADATA,sha256=RgL-FUplGCL93AiOnjWVkZ5m_QMygt6kRe2bBq4yp_g,3482
42
+ dyff_schema-0.20.1.dist-info/NOTICE,sha256=YONACu0s_Ui6jNi-wtEsVQbTU1JIkh8wvLH6d1-Ni_w,43
43
+ dyff_schema-0.20.1.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
44
+ dyff_schema-0.20.1.dist-info/top_level.txt,sha256=9e3VVdeX73t_sUJOPQPCcGtYO1JhoErhHIi3WoWGcFI,5
45
+ dyff_schema-0.20.1.dist-info/RECORD,,