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

dyff/schema/_version.py CHANGED
@@ -1,2 +1,2 @@
1
- __version__ = version = "0.33.0"
2
- __version_tuple__ = version_tuple = (0, 33, 0)
1
+ __version__ = version = "0.34.0"
2
+ __version_tuple__ = version_tuple = (0, 34, 0)
dyff/schema/v0/r1/oci.py CHANGED
@@ -181,3 +181,15 @@ class ImageManifest(_OCISchemaBaseModel):
181
181
  " if .artifactType is unspecified"
182
182
  )
183
183
  return self
184
+
185
+
186
+ __all__ = [
187
+ "Descriptor",
188
+ "ExecutionParameters",
189
+ "HistoryEntry",
190
+ "ImageConfig",
191
+ "ImageDescriptor",
192
+ "ImageManifest",
193
+ "Platform",
194
+ "RootFS",
195
+ ]
@@ -24,6 +24,7 @@ import enum
24
24
  import urllib.parse
25
25
  from datetime import datetime
26
26
  from enum import Enum
27
+ from pathlib import Path
27
28
  from typing import Any, Literal, NamedTuple, Optional, Type, Union
28
29
 
29
30
  import pyarrow
@@ -194,7 +195,8 @@ class Entities(str, enum.Enum):
194
195
 
195
196
  Account = "Account"
196
197
  Analysis = "Analysis"
197
- Artifact = "Artifact"
198
+ # FIXME: (schema v1) Rename to Artifact
199
+ Artifact = "OCIArtifact"
198
200
  Audit = "Audit"
199
201
  AuditProcedure = "AuditProcedure"
200
202
  Concern = "Concern"
@@ -262,6 +264,9 @@ class Resources(str, enum.Enum):
262
264
  @staticmethod
263
265
  def for_kind(kind: Entities) -> "Resources":
264
266
  try:
267
+ # FIXME: (schema v1) Special case for legacy OCIArtifact name
268
+ if kind == Entities.Artifact:
269
+ return Resources.Artifact
265
270
  return Resources[kind.value]
266
271
  except KeyError:
267
272
  raise ValueError(f"No Resources for Entity kind: {kind}")
@@ -269,7 +274,6 @@ class Resources(str, enum.Enum):
269
274
 
270
275
  EntityKindLiteral = Literal[
271
276
  "Analysis",
272
- "Artifact",
273
277
  "Audit",
274
278
  "AuditProcedure",
275
279
  "DataSource",
@@ -284,6 +288,8 @@ EntityKindLiteral = Literal[
284
288
  "Method",
285
289
  "Model",
286
290
  "Module",
291
+ # FIXME: (schema v1) Rename to Artifact
292
+ "OCIArtifact",
287
293
  "Report",
288
294
  "Revision",
289
295
  "SafetyCase",
@@ -312,6 +318,9 @@ class EntityIdentifier(DyffSchemaBaseModel):
312
318
  description="The .kind of the entity.",
313
319
  )
314
320
 
321
+ def resource_path(self) -> str:
322
+ return f"{Resources.for_kind(Entities(self.kind)).value}/{self.id}"
323
+
315
324
 
316
325
  def LabelKey() -> type[str]:
317
326
  return Annotated[
@@ -492,7 +501,6 @@ class DyffEntityMetadata(DyffSchemaBaseModel):
492
501
  class DyffEntity(Status, Labeled, SchemaVersion, DyffModelWithID):
493
502
  kind: Literal[
494
503
  "Analysis",
495
- "Artifact",
496
504
  "Audit",
497
505
  "AuditProcedure",
498
506
  "DataSource",
@@ -507,6 +515,8 @@ class DyffEntity(Status, Labeled, SchemaVersion, DyffModelWithID):
507
515
  "Method",
508
516
  "Model",
509
517
  "Module",
518
+ # FIXME: (schema v1) Rename to Artifact
519
+ "OCIArtifact",
510
520
  "Report",
511
521
  "Revision",
512
522
  "SafetyCase",
@@ -1076,6 +1086,32 @@ class Dataset(DyffEntity, DatasetBase):
1076
1086
  return None
1077
1087
 
1078
1088
 
1089
+ # ----------------------------------------------------------------------------
1090
+ # Model
1091
+
1092
+
1093
+ class File(DyffSchemaBaseModel):
1094
+ mediaType: Optional[str] = pydantic.Field(
1095
+ default=None, description="The media type (MIME type) of the file"
1096
+ )
1097
+ path: str = pydantic.Field(
1098
+ description="The relative path of the file within the containing volume"
1099
+ )
1100
+ digest: Digest = pydantic.Field(
1101
+ default_factory=Digest,
1102
+ description="One or more message digests (hashes) of the file data",
1103
+ )
1104
+
1105
+
1106
+ class FileStorageURL(DyffSchemaBaseModel):
1107
+ file: File
1108
+ signedURL: StorageSignedURL
1109
+
1110
+
1111
+ class Volume(DyffSchemaBaseModel):
1112
+ files: list[File] = pydantic.Field(description="A list of files in the volume")
1113
+
1114
+
1079
1115
  class ModelSourceKinds(str, enum.Enum):
1080
1116
  GitLFS = "GitLFS"
1081
1117
  HuggingFaceHub = "HuggingFaceHub"
@@ -1129,10 +1165,6 @@ class ModelSource(DyffSchemaBaseModel):
1129
1165
  )
1130
1166
 
1131
1167
 
1132
- class ContainerImage(DyffSchemaBaseModel):
1133
- pass
1134
-
1135
-
1136
1168
  class AcceleratorGPU(DyffSchemaBaseModel):
1137
1169
  hardwareTypes: list[str] = pydantic.Field(
1138
1170
  min_length=1,
@@ -1154,14 +1186,23 @@ class Accelerator(DyffSchemaBaseModel):
1154
1186
  )
1155
1187
 
1156
1188
 
1189
+ # FIXME: Remove .storage because it's replaced by ScratchVolume, and rename to
1190
+ # ResourceRequirements for consistency with k8s.
1157
1191
  class ModelResources(DyffSchemaBaseModel):
1158
- storage: Quantity = pydantic.Field(
1159
- description="Amount of storage required for packaged model, in k8s Quantity notation",
1192
+ storage: Optional[Quantity] = pydantic.Field(
1193
+ default=None,
1194
+ deprecated=True,
1195
+ description="Storage required for packaged model, in k8s Quantity notation",
1160
1196
  )
1161
1197
 
1162
1198
  memory: Optional[Quantity] = pydantic.Field(
1163
1199
  default=None,
1164
- description="Amount of memory required to run the model on CPU, in k8s Quantity notation",
1200
+ description="Memory, in k8s Quantity notation",
1201
+ )
1202
+
1203
+ cpu: Optional[Quantity] = pydantic.Field(
1204
+ default=None,
1205
+ description="Number of CPUs, in k8s Quantity notation",
1165
1206
  )
1166
1207
 
1167
1208
 
@@ -1175,6 +1216,7 @@ class ModelStorageMedium(str, enum.Enum):
1175
1216
  class ModelArtifactKind(str, enum.Enum):
1176
1217
  HuggingFaceCache = "HuggingFaceCache"
1177
1218
  Mock = "Mock"
1219
+ Volume = "Volume"
1178
1220
 
1179
1221
 
1180
1222
  class ModelArtifactHuggingFaceCache(DyffSchemaBaseModel):
@@ -1194,6 +1236,9 @@ class ModelArtifact(DyffSchemaBaseModel):
1194
1236
  huggingFaceCache: Optional[ModelArtifactHuggingFaceCache] = pydantic.Field(
1195
1237
  default=None, description="Model stored in a HuggingFace cache"
1196
1238
  )
1239
+ volume: Optional[Volume] = pydantic.Field(
1240
+ default=None, description="Model stored as a generic volume"
1241
+ )
1197
1242
 
1198
1243
 
1199
1244
  class ModelStorage(DyffSchemaBaseModel):
@@ -1245,6 +1290,7 @@ class InferenceServiceBuilder(DyffSchemaBaseModel):
1245
1290
 
1246
1291
  class InferenceServiceRunnerKind(str, Enum):
1247
1292
  BENTOML_SERVICE_OPENLLM = "bentoml_service_openllm"
1293
+ CONTAINER = "container"
1248
1294
  HUGGINGFACE = "huggingface"
1249
1295
  MOCK = "mock"
1250
1296
  STANDALONE = "standalone"
@@ -1306,29 +1352,116 @@ class ContainerImageSource(DyffSchemaBaseModel):
1306
1352
  return v
1307
1353
 
1308
1354
 
1309
- class InferenceServiceRunner(DyffSchemaBaseModel):
1310
- kind: InferenceServiceRunnerKind
1355
+ class EnvVar(DyffSchemaBaseModel):
1356
+ name: str
1357
+ value: str
1358
+
1359
+
1360
+ # TODO: ModelResources is deprecated
1361
+ ResourceRequirements = ModelResources
1362
+
1363
+
1364
+ class VolumeMountKind(str, enum.Enum):
1365
+ data = "Data"
1366
+ scratch = "Scratch"
1367
+
1368
+
1369
+ class VolumeMountData(DyffSchemaBaseModel):
1370
+ source: EntityIdentifier = pydantic.Field(
1371
+ description="The Dyff platform resource to mount."
1372
+ " Must be a volume-like entity such as a Model or Dataset."
1373
+ )
1374
+
1311
1375
 
1376
+ class VolumeMountScratch(DyffSchemaBaseModel):
1377
+ capacity: Quantity = pydantic.Field(
1378
+ description="Minimum storage capacity of the Scratch volume."
1379
+ )
1380
+
1381
+
1382
+ class VolumeMount(DyffSchemaBaseModel):
1383
+ kind: VolumeMountKind = pydantic.Field(description="The kind of volume mount.")
1384
+ name: str = pydantic.Field(description="A descriptive name for the mount.")
1385
+ mountPath: Path = pydantic.Field(
1386
+ description="Where to mount the volume in the running container."
1387
+ " Must be an absolute path."
1388
+ )
1389
+ data: Optional[VolumeMountData] = pydantic.Field(
1390
+ default=None, description="Configuration for Data volume mounts."
1391
+ )
1392
+ scratch: Optional[VolumeMountScratch] = pydantic.Field(
1393
+ default=None, description="Configuration for Scratch volume mounts."
1394
+ )
1395
+
1396
+
1397
+ class Container(DyffSchemaBaseModel):
1398
+ """Configuration of a runnable container backed by either an image hosted in an
1399
+ external registyr, or an image artifact hosted in the Dyff system.
1400
+
1401
+ This is mostly a subset of the Kubernetes Container schema.
1402
+ """
1403
+
1404
+ args: Optional[list[str]] = pydantic.Field(
1405
+ default=None,
1406
+ description="Arguments to the entrypoint."
1407
+ " The container image's CMD is used if this is not provided.",
1408
+ )
1409
+ command: Optional[list[str]] = pydantic.Field(
1410
+ default=None,
1411
+ description="Entrypoint array. Not executed within a shell."
1412
+ " The container image's ENTRYPOINT is used if this is not provided.",
1413
+ )
1414
+ env: Optional[list[EnvVar]] = pydantic.Field(
1415
+ default=None,
1416
+ description="List of environment variables to set in the container.",
1417
+ )
1312
1418
  # TODO: (DYFF-421) Make .image required
1313
1419
  image: Optional[ContainerImageSource] = pydantic.Field(
1314
1420
  default=None,
1315
- description="The container image that implements the runner. This field is"
1316
- " optional for schema backwards-compatibility, but creating new"
1317
- " services with image=None will result in an error.",
1421
+ description="The container image that implements the runner."
1422
+ " Exactly one of .image and .imageRef must be set.",
1318
1423
  )
1319
-
1320
- args: Optional[list[str]] = pydantic.Field(
1321
- default=None, description="Command line arguments to forward to the runner"
1424
+ imageRef: Optional[EntityIdentifier] = pydantic.Field(
1425
+ default=None,
1426
+ description="Container image reference. Must be an image artifact"
1427
+ " that has been uploaded to this Dyff instance and is in Ready status."
1428
+ " Exactly one of .image and .imageRef must be set.",
1429
+ )
1430
+ resources: ResourceRequirements = pydantic.Field(
1431
+ description="Compute Resources required by this container."
1432
+ )
1433
+ volumeMounts: Optional[list[VolumeMount]] = pydantic.Field(
1434
+ default=None, description="Volumes to mount into the container's filesystem."
1435
+ )
1436
+ workingDir: Optional[Path] = pydantic.Field(
1437
+ default=None,
1438
+ description="Container's working directory. If not specified,"
1439
+ " the container runtime's default will be used,"
1440
+ " which might be configured in the container image.",
1322
1441
  )
1323
1442
 
1443
+ @pydantic.model_validator(mode="after")
1444
+ def check_image_exactly_one(cls, values):
1445
+ image = values.image is not None
1446
+ imageRef = values.imageRef is not None
1447
+ if sum([image, imageRef]) != 1:
1448
+ raise ValueError("must specify exactly one of {image, imageRef}")
1449
+ return values
1450
+
1451
+
1452
+ class InferenceServiceRunner(Container):
1453
+ """Configuration of a managed runner to use to run an inference service.
1454
+
1455
+ Using a managed runner simplifies the configuration of inference services backed by
1456
+ models in common formats, such as HuggingFace models.
1457
+ """
1458
+
1459
+ kind: InferenceServiceRunnerKind
1460
+
1324
1461
  accelerator: Optional[Accelerator] = pydantic.Field(
1325
1462
  default=None, description="Optional accelerator hardware to use, per node."
1326
1463
  )
1327
1464
 
1328
- resources: ModelResources = pydantic.Field(
1329
- description="Resource requirements to run the service, per node."
1330
- )
1331
-
1332
1465
  nodes: int = pydantic.Field(
1333
1466
  default=1,
1334
1467
  ge=1,
@@ -1366,7 +1499,9 @@ class InferenceServiceBase(DyffSchemaBaseModel):
1366
1499
 
1367
1500
  # FIXME: (DYFF-261) .runner should be required
1368
1501
  runner: Optional[InferenceServiceRunner] = pydantic.Field(
1369
- default=None, description="Configuration of the Runner used to run the service."
1502
+ default=None,
1503
+ description="Configuration of the managed runner used to run the service."
1504
+ " Only one of .container or .runner may be specified.",
1370
1505
  )
1371
1506
 
1372
1507
  interface: InferenceInterface = pydantic.Field(
@@ -2146,8 +2281,8 @@ class Score(ScoreData):
2146
2281
 
2147
2282
 
2148
2283
  # TODO: (schema-v1) Rename this to Artifact
2149
- class OCIArtifact(Documented, DyffEntity):
2150
- kind: Literal["Artifact"] = Entities.Artifact.value
2284
+ class OCIArtifact(DyffEntity):
2285
+ kind: Literal["OCIArtifact"] = Entities.Artifact.value
2151
2286
 
2152
2287
  manifest: oci.ImageManifest = pydantic.Field(
2153
2288
  description="The OCI image manifest of the artifact"
@@ -2519,6 +2654,7 @@ __all__ = [
2519
2654
  "AuditRequirement",
2520
2655
  "Concern",
2521
2656
  "ConcernBase",
2657
+ "Container",
2522
2658
  "ContainerImageSource",
2523
2659
  "DataSchema",
2524
2660
  "Dataset",
@@ -2552,6 +2688,8 @@ __all__ = [
2552
2688
  "FamilyMemberBase",
2553
2689
  "FamilyMemberKind",
2554
2690
  "FamilyMembers",
2691
+ "File",
2692
+ "FileStorageURL",
2555
2693
  "ForeignInferenceService",
2556
2694
  "ForeignMethod",
2557
2695
  "ForeignModel",
@@ -2616,6 +2754,7 @@ __all__ = [
2616
2754
  "Report",
2617
2755
  "ReportBase",
2618
2756
  "Resources",
2757
+ "ResourceRequirements",
2619
2758
  "Revision",
2620
2759
  "RevisionData",
2621
2760
  "RevisionMetadata",
@@ -2634,6 +2773,11 @@ __all__ = [
2634
2773
  "TagNameType",
2635
2774
  "TaskSchema",
2636
2775
  "UseCase",
2776
+ "Volume",
2777
+ "VolumeMount",
2778
+ "VolumeMountData",
2779
+ "VolumeMountKind",
2780
+ "VolumeMountScratch",
2637
2781
  "entity_class",
2638
2782
  "JobStatus",
2639
2783
  "EntityStatus",
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dyff-schema
3
- Version: 0.33.0
3
+ Version: 0.34.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
@@ -1,5 +1,5 @@
1
1
  dyff/schema/__init__.py,sha256=w7OWDFuyGKd6xt_yllNtKzHahPgywrfU4Ue02psYaMA,2244
2
- dyff/schema/_version.py,sha256=uTbdsxpcOU7mMXqX3G50NVmPGutL-k0_3StqoCGV-b0,80
2
+ dyff/schema/_version.py,sha256=XljasSz55aHZWbsQEfTEKzQqXO-_Fxt1XG4pyMx3dDc,80
3
3
  dyff/schema/adapters.py,sha256=YMTHv_2VlLGFp-Kqwa6H51hjffHmk8gXjZilHysIF5Q,123
4
4
  dyff/schema/annotations.py,sha256=nE6Jk1PLqlShj8uqjE_EzZC9zYnTDW5AVtQcjysiK8M,10018
5
5
  dyff/schema/base.py,sha256=jvaNtsSZyFfsdUZTcY_U-yfLY5_GyrMxSXhON2R9XR0,119
@@ -28,8 +28,8 @@ dyff/schema/v0/r1/__init__.py,sha256=L5y8UhRnojerPYHumsxQJRcHCNz8Hj9NM8b47mewMNs
28
28
  dyff/schema/v0/r1/adapters.py,sha256=hpwCSW8lkMkUKCLe0zaMUDu-VS_caSxJvPsECEi_XRA,33069
29
29
  dyff/schema/v0/r1/base.py,sha256=fdhAa4hpbSn7m3U0qha4rG7gJiYUvPR8SaM-mwszoy0,20289
30
30
  dyff/schema/v0/r1/commands.py,sha256=VoThKeIVz4ZQAqBXhb6TVOG6aG4m_Oa0_6Sc4oxyFhs,9801
31
- dyff/schema/v0/r1/oci.py,sha256=mvh1BaiRahZbjIbMh7RqZxZjOKZT9GsS1yBpSdPw01Y,6587
32
- dyff/schema/v0/r1/platform.py,sha256=s1O_mAVfi9owekqYxcjwPI10s3F7RNo8B8WvMunMi4U,83577
31
+ dyff/schema/v0/r1/oci.py,sha256=Jnnu2EBeYQKC-EbKLG60a5z3WwpOuZMogeJ7vQA74bM,6761
32
+ dyff/schema/v0/r1/platform.py,sha256=A6PEGqrGmSX2x1HtfxO8-_zYjPgxovGCBk4VoEiBviI,88542
33
33
  dyff/schema/v0/r1/requests.py,sha256=3XcFcKChubBrxoHCUHkV5GrNl6Ijdbxn4D4UZAAo09g,17965
34
34
  dyff/schema/v0/r1/responses.py,sha256=nxy7FPtfw2B_bljz5UGGuSE79HTkDQxKH56AJVmd4Qo,1287
35
35
  dyff/schema/v0/r1/test.py,sha256=X6dUyVd5svcPCI-PBMOAqEfK9jv3bRDvkQTJzwS96c0,10720
@@ -43,9 +43,9 @@ dyff/schema/v0/r1/dataset/text.py,sha256=MYG5seGODDryRSCy-g0Unh5dD0HCytmZ3FeElC-
43
43
  dyff/schema/v0/r1/dataset/vision.py,sha256=aIe0fbfM_g3DsrDTdg2K803YKLjZBpurM_VJcJFuZLc,369
44
44
  dyff/schema/v0/r1/io/__init__.py,sha256=L5y8UhRnojerPYHumsxQJRcHCNz8Hj9NM8b47mewMNs,92
45
45
  dyff/schema/v0/r1/io/vllm.py,sha256=vWyLg-susbg0JDfv6VExBpgFdU2GHP2a14ChOdbckvs,5321
46
- dyff_schema-0.33.0.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
47
- dyff_schema-0.33.0.dist-info/licenses/NOTICE,sha256=YONACu0s_Ui6jNi-wtEsVQbTU1JIkh8wvLH6d1-Ni_w,43
48
- dyff_schema-0.33.0.dist-info/METADATA,sha256=XUEtF3Dgk_LSI4YKUPZp5RJzKvzx7nv7_Jxp30ic3W0,3668
49
- dyff_schema-0.33.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
50
- dyff_schema-0.33.0.dist-info/top_level.txt,sha256=9e3VVdeX73t_sUJOPQPCcGtYO1JhoErhHIi3WoWGcFI,5
51
- dyff_schema-0.33.0.dist-info/RECORD,,
46
+ dyff_schema-0.34.0.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
47
+ dyff_schema-0.34.0.dist-info/licenses/NOTICE,sha256=YONACu0s_Ui6jNi-wtEsVQbTU1JIkh8wvLH6d1-Ni_w,43
48
+ dyff_schema-0.34.0.dist-info/METADATA,sha256=F3KZ0tCvKFS0i7dojafzjictFf_5tAMAita4ag9k_Xo,3668
49
+ dyff_schema-0.34.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
50
+ dyff_schema-0.34.0.dist-info/top_level.txt,sha256=9e3VVdeX73t_sUJOPQPCcGtYO1JhoErhHIi3WoWGcFI,5
51
+ dyff_schema-0.34.0.dist-info/RECORD,,