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

@@ -16,11 +16,11 @@ from __future__ import annotations
16
16
 
17
17
  import re
18
18
  from datetime import datetime
19
- from typing import Optional, Union
19
+ from typing import Literal, Optional, Union
20
20
 
21
21
  import pydantic
22
22
 
23
- from .base import DyffBaseModel
23
+ from .base import DyffBaseModel, DyffSchemaBaseModel
24
24
  from .platform import (
25
25
  AnalysisBase,
26
26
  AnalysisScope,
@@ -38,6 +38,8 @@ from .platform import (
38
38
  ModelSpec,
39
39
  ModuleBase,
40
40
  ReportBase,
41
+ summary_maxlen,
42
+ title_maxlen,
41
43
  )
42
44
  from .version import SchemaVersion
43
45
 
@@ -94,7 +96,28 @@ class AnalysisCreateRequest(DyffEntityCreateRequest, AnalysisBase):
94
96
 
95
97
 
96
98
  class ConcernCreateRequest(DyffEntityCreateRequest, ConcernBase):
97
- pass
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
98
121
 
99
122
 
100
123
  class DatasetCreateRequest(DyffEntityCreateRequest, DatasetBase):
@@ -102,7 +125,23 @@ class DatasetCreateRequest(DyffEntityCreateRequest, DatasetBase):
102
125
 
103
126
 
104
127
  class DocumentationEditRequest(DyffRequestBase, DocumentationBase):
105
- 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
106
145
 
107
146
 
108
147
  class InferenceServiceCreateRequest(DyffEntityCreateRequest, InferenceServiceBase):
@@ -213,7 +252,7 @@ class LabelUpdateRequest(DyffRequestBase, Labeled):
213
252
  # specify. I think it's not that important, because all of the query parameters
214
253
  # will always be optional. There could be a problem if the semantics of a
215
254
  # name change, but let's just not do that!
216
- class DyffEntityQueryRequest(DyffRequestDefaultValidators):
255
+ class QueryRequest(DyffRequestDefaultValidators):
217
256
  query: Optional[str] = pydantic.Field(
218
257
  default=None,
219
258
  description="A JSON structure describing a query, encoded as a string."
@@ -223,6 +262,30 @@ class DyffEntityQueryRequest(DyffRequestDefaultValidators):
223
262
  )
224
263
 
225
264
  id: Optional[str] = pydantic.Field(default=None)
265
+
266
+ order: Optional[Literal["ascending", "descending"]] = pydantic.Field(
267
+ default=None,
268
+ description="Sort the results in this order. Default: unsorted."
269
+ " Ignored unless 'orderBy' is also set."
270
+ " The order of operations is query -> order -> limit.",
271
+ )
272
+
273
+ orderBy: Optional[str] = pydantic.Field(
274
+ default=None,
275
+ description="Sort the results by the value of the specified field."
276
+ " The 'order' field must be set also."
277
+ " The order of operations is query -> order -> limit.",
278
+ )
279
+
280
+ limit: Optional[int] = pydantic.Field(
281
+ default=None,
282
+ ge=1,
283
+ description="Return at most this many results."
284
+ " The order of operations is query -> order -> limit.",
285
+ )
286
+
287
+
288
+ class DyffEntityQueryRequest(QueryRequest):
226
289
  account: Optional[str] = pydantic.Field(default=None)
227
290
  status: Optional[str] = pydantic.Field(default=None)
228
291
  reason: Optional[str] = pydantic.Field(default=None)
@@ -231,16 +294,8 @@ class DyffEntityQueryRequest(DyffRequestDefaultValidators):
231
294
  )
232
295
 
233
296
 
234
- class DocumentationQueryRequest(DyffRequestDefaultValidators):
235
- query: Optional[str] = pydantic.Field(
236
- default=None,
237
- description="A JSON structure describing a query, encoded as a string."
238
- " Valid keys are the same as the valid query keys for the corresponding"
239
- " endpoint. Values can be scalars or lists. Lists are treated as"
240
- " disjunctive queries (i.e., 'value $in list').",
241
- )
242
-
243
- id: Optional[str] = pydantic.Field(default=None)
297
+ class DocumentationQueryRequest(QueryRequest):
298
+ pass
244
299
 
245
300
 
246
301
  class _AnalysisProductQueryRequest(DyffEntityQueryRequest):
@@ -370,6 +425,7 @@ __all__ = [
370
425
  "ModelQueryRequest",
371
426
  "ModuleCreateRequest",
372
427
  "ModuleQueryRequest",
428
+ "QueryRequest",
373
429
  "ReportCreateRequest",
374
430
  "ReportQueryRequest",
375
431
  "SafetyCaseQueryRequest",
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: dyff-schema
3
- Version: 0.20.0
3
+ Version: 0.21.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
@@ -25,7 +25,7 @@ dyff/schema/v0/r1/__init__.py,sha256=L5y8UhRnojerPYHumsxQJRcHCNz8Hj9NM8b47mewMNs
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
27
  dyff/schema/v0/r1/platform.py,sha256=bvROO9WEOV257C_QSWuWeDLCFegaYl116YvMP-AClUE,75609
28
- dyff/schema/v0/r1/requests.py,sha256=s31J0fegRm_7My_5Ut-qNQnXtMMVwlhOSWKf51h5u4g,13269
28
+ dyff/schema/v0/r1/requests.py,sha256=4TM1IKG9IP4MyprIy9E9XA_JqvkuwKAuY1ao1BbVLI0,15676
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.20.0.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
41
- dyff_schema-0.20.0.dist-info/METADATA,sha256=WkVYqNNDqfAfcdwnC5kkmYa2q86AYDVjhZcMD5Sn14k,3482
42
- dyff_schema-0.20.0.dist-info/NOTICE,sha256=YONACu0s_Ui6jNi-wtEsVQbTU1JIkh8wvLH6d1-Ni_w,43
43
- dyff_schema-0.20.0.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
44
- dyff_schema-0.20.0.dist-info/top_level.txt,sha256=9e3VVdeX73t_sUJOPQPCcGtYO1JhoErhHIi3WoWGcFI,5
45
- dyff_schema-0.20.0.dist-info/RECORD,,
40
+ dyff_schema-0.21.0.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
41
+ dyff_schema-0.21.0.dist-info/METADATA,sha256=9GEkk75CrXQJyJVMlEDJJLI0c3XD49ZHnrcjTa8Bsls,3482
42
+ dyff_schema-0.21.0.dist-info/NOTICE,sha256=YONACu0s_Ui6jNi-wtEsVQbTU1JIkh8wvLH6d1-Ni_w,43
43
+ dyff_schema-0.21.0.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
44
+ dyff_schema-0.21.0.dist-info/top_level.txt,sha256=9e3VVdeX73t_sUJOPQPCcGtYO1JhoErhHIi3WoWGcFI,5
45
+ dyff_schema-0.21.0.dist-info/RECORD,,