dyff-schema 0.9.0__py3-none-any.whl → 0.10.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.
dyff/schema/errors.py CHANGED
@@ -6,8 +6,8 @@ from typing import NamedTuple, Optional
6
6
 
7
7
 
8
8
  class HTTPResponseStatus(NamedTuple):
9
- status_code: int
10
- description: str
9
+ code: int
10
+ status: str
11
11
 
12
12
 
13
13
  HTTP_400_BAD_REQUEST = HTTPResponseStatus(400, "Bad Request")
@@ -28,7 +28,7 @@ class ClientError(DyffError):
28
28
  def __init__(
29
29
  self, message, *, http_status: HTTPResponseStatus = HTTP_400_BAD_REQUEST
30
30
  ):
31
- if not (400 <= http_status.status_code <= 499):
31
+ if not (400 <= http_status.code <= 499):
32
32
  raise AssertionError(
33
33
  f"ClientError should map to a 4xx HTTP status; got {http_status}"
34
34
  )
@@ -44,7 +44,7 @@ class PlatformError(DyffError):
44
44
  *,
45
45
  http_status: HTTPResponseStatus = HTTP_500_INTERNAL_SERVER_ERROR,
46
46
  ):
47
- if not (500 <= http_status.status_code <= 599):
47
+ if not (500 <= http_status.code <= 599):
48
48
  raise AssertionError(
49
49
  f"PlatformError should map to a 5xx HTTP status; got {http_status}"
50
50
  )
@@ -18,6 +18,7 @@ We use the following naming convention:
18
18
  # mypy: disable-error-code="import-untyped"
19
19
  import abc
20
20
  import enum
21
+ import urllib.parse
21
22
  from datetime import datetime
22
23
  from enum import Enum
23
24
  from typing import Any, Literal, NamedTuple, Optional, Type, Union
@@ -998,8 +999,74 @@ class InferenceServiceRunnerKind(str, Enum):
998
999
  VLLM = "vllm"
999
1000
 
1000
1001
 
1002
+ class ContainerImageSource(DyffSchemaBaseModel):
1003
+ host: str = pydantic.Field(description="The host of the container image registry.")
1004
+ name: str = pydantic.Field(
1005
+ description="The name of the image",
1006
+ # https://github.com/opencontainers/distribution-spec/blob/main/spec.md#pull
1007
+ regex=r"^[a-z0-9]+((\.|_|__|-+)[a-z0-9]+)*(\/[a-z0-9]+((\.|_|__|-+)[a-z0-9]+)*)*$",
1008
+ )
1009
+ digest: str = pydantic.Field(
1010
+ description="The digest of the image. The image is always pulled by"
1011
+ " digest, even if 'tag' is specified.",
1012
+ regex=r"^sha256:[0-9a-f]{64}$",
1013
+ )
1014
+ tag: Optional[str] = pydantic.Field(
1015
+ default=None,
1016
+ description="The tag of the image. Although the image is always pulled"
1017
+ " by digest, including the tag is strongly recommended as it is often"
1018
+ " the main source of versioning information.",
1019
+ # https://github.com/opencontainers/distribution-spec/blob/main/spec.md#pull
1020
+ regex=r"^[a-zA-Z0-9_][a-zA-Z0-9._-]{0,127}$",
1021
+ )
1022
+
1023
+ def url(self) -> str:
1024
+ return f"{self.host}/{self.name}@{self.digest}"
1025
+
1026
+ @pydantic.validator("host")
1027
+ def validate_host(cls, v: str):
1028
+ if "/" in v:
1029
+ raise ValueError(
1030
+ "host: slashes not allowed; do not specify a scheme or path"
1031
+ )
1032
+ if "_" in v:
1033
+ # https://docs.docker.com/reference/cli/docker/image/tag/#description
1034
+ raise ValueError(
1035
+ "host: image registry hostnames may not contain underscores"
1036
+ )
1037
+
1038
+ # This works because we know there are no slashes in the value
1039
+ # "Following the syntax specifications in RFC 1808, urlparse recognizes
1040
+ # a netloc only if it is properly introduced by ‘//’. Otherwise the
1041
+ # input is presumed to be a relative URL and thus to start with a path
1042
+ # component."
1043
+ # https://docs.python.org/3/library/urllib.parse.html#urllib.parse.urlparse
1044
+ parsed = urllib.parse.urlparse(f"//{v}")
1045
+ if (
1046
+ parsed.scheme
1047
+ or parsed.path
1048
+ or parsed.params
1049
+ or parsed.query
1050
+ or parsed.fragment
1051
+ ):
1052
+ raise ValueError(
1053
+ "host: must be 'hostname' or 'hostname:port', and nothing else"
1054
+ )
1055
+
1056
+ return v
1057
+
1058
+
1001
1059
  class InferenceServiceRunner(DyffSchemaBaseModel):
1002
1060
  kind: InferenceServiceRunnerKind
1061
+
1062
+ # TODO: (DYFF-421) Make .image required
1063
+ image: Optional[ContainerImageSource] = pydantic.Field(
1064
+ default=None,
1065
+ description="The container image that implements the runner. This field is"
1066
+ " optional for schema backwards-compatibility, but creating new"
1067
+ " services with image=None will result in an error.",
1068
+ )
1069
+
1003
1070
  args: Optional[list[str]] = pydantic.Field(
1004
1071
  default=None, description="Command line arguments to forward to the runner"
1005
1072
  )
@@ -1878,6 +1945,7 @@ __all__ = [
1878
1945
  "Audit",
1879
1946
  "AuditProcedure",
1880
1947
  "AuditRequirement",
1948
+ "ContainerImageSource",
1881
1949
  "DataSchema",
1882
1950
  "Dataset",
1883
1951
  "DatasetBase",
@@ -83,6 +83,16 @@ class InferenceServiceCreateRequest(DyffEntityCreateRequest, InferenceServiceBas
83
83
  default=None, description="ID of Model backing the service, if applicable"
84
84
  )
85
85
 
86
+ # TODO: (DYFF-421) Make .image required and remove this validator
87
+ @pydantic.validator("image", check_fields=False)
88
+ def validate_image_not_none(cls, v):
89
+ if v is None:
90
+ raise ValueError(
91
+ ".image is required for new services; it is defined as Optional"
92
+ " for schema backwards-compatibility only"
93
+ )
94
+ return v
95
+
86
96
 
87
97
  class InferenceSessionCreateRequest(DyffEntityCreateRequest, InferenceSessionBase):
88
98
  inferenceService: str = pydantic.Field(description="InferenceService ID")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: dyff-schema
3
- Version: 0.9.0
3
+ Version: 0.10.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
@@ -2,7 +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/base.py,sha256=jvaNtsSZyFfsdUZTcY_U-yfLY5_GyrMxSXhON2R9XR0,119
4
4
  dyff/schema/copydoc.py,sha256=B4ZRpQmbFxi-3l9LCHvaJiVKb9VxADgC5vey804Febc,1075
5
- dyff/schema/errors.py,sha256=4FwatI-0RUYYqVR0hHoifXPgANk89QgSq9PTS9FzfwU,1568
5
+ dyff/schema/errors.py,sha256=ow3yiucU4wGkeLmapUURp3eyaebwGUwDaVTXpPcrA7M,1542
6
6
  dyff/schema/ids.py,sha256=Z3JQzlAJQC2Pam7ehxb4TXA4MIuFQN5SyzL5Ql0RukA,1422
7
7
  dyff/schema/platform.py,sha256=peHzGGSd5dQ-EFXrWDjBqMUtoOL3iCHxcV3XzW6Rjag,123
8
8
  dyff/schema/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -22,8 +22,8 @@ dyff/schema/v0/__init__.py,sha256=L5y8UhRnojerPYHumsxQJRcHCNz8Hj9NM8b47mewMNs,92
22
22
  dyff/schema/v0/r1/__init__.py,sha256=L5y8UhRnojerPYHumsxQJRcHCNz8Hj9NM8b47mewMNs,92
23
23
  dyff/schema/v0/r1/adapters.py,sha256=2t2oxsnGfSEDKKDIEYw4qqLXMH7qlFIwPVuLyUmbsHs,23552
24
24
  dyff/schema/v0/r1/base.py,sha256=QX1TfqX3jBafxpBnf2bUTcgP0sMyqZFFNJZQHhM48BI,19385
25
- dyff/schema/v0/r1/platform.py,sha256=t7XKNBXByrkleLhcRZn1Et0Dtb36CtmghWeezThz_UI,61416
26
- dyff/schema/v0/r1/requests.py,sha256=I2K3thOsga0X9-6oRsAO1Hqgkr8qV_8haw-7ALIf_yc,9857
25
+ dyff/schema/v0/r1/platform.py,sha256=XNrL-H1wuY9CaBpfbCVzDK7hqclS87OouyAnS9FlM4g,64134
26
+ dyff/schema/v0/r1/requests.py,sha256=2Xu1iA2m1bCNzITPcwrnNagqAOtB8Fahav9zzV8oGJ0,10245
27
27
  dyff/schema/v0/r1/test.py,sha256=X6dUyVd5svcPCI-PBMOAqEfK9jv3bRDvkQTJzwS96c0,10720
28
28
  dyff/schema/v0/r1/version.py,sha256=isKAGuGxsdru8vDaYmI4YiZdJOu_wNxXK7u6QzD6FE4,392
29
29
  dyff/schema/v0/r1/dataset/__init__.py,sha256=LbVlkO2asyGYBKk2z49xjJYTM-pu9y9e4eQDXgTDLnM,2553
@@ -34,9 +34,9 @@ dyff/schema/v0/r1/dataset/text.py,sha256=nLIn91Zlt0tNdXUklSgjJ-kEDxoPX32ISLkiv2D
34
34
  dyff/schema/v0/r1/dataset/vision.py,sha256=aIe0fbfM_g3DsrDTdg2K803YKLjZBpurM_VJcJFuZLc,369
35
35
  dyff/schema/v0/r1/io/__init__.py,sha256=L5y8UhRnojerPYHumsxQJRcHCNz8Hj9NM8b47mewMNs,92
36
36
  dyff/schema/v0/r1/io/vllm.py,sha256=CUE9y8KthtUI7sD49S875rDmPvKotSXVIRaBS79aBZs,5320
37
- dyff_schema-0.9.0.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
38
- dyff_schema-0.9.0.dist-info/METADATA,sha256=y8iwfPwD_j6hEaMZXg7wTYwt319cWdKjB2eDNRiyc14,3459
39
- dyff_schema-0.9.0.dist-info/NOTICE,sha256=YONACu0s_Ui6jNi-wtEsVQbTU1JIkh8wvLH6d1-Ni_w,43
40
- dyff_schema-0.9.0.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
41
- dyff_schema-0.9.0.dist-info/top_level.txt,sha256=9e3VVdeX73t_sUJOPQPCcGtYO1JhoErhHIi3WoWGcFI,5
42
- dyff_schema-0.9.0.dist-info/RECORD,,
37
+ dyff_schema-0.10.1.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
38
+ dyff_schema-0.10.1.dist-info/METADATA,sha256=1yQ9XLIRO4uugg3K5OBROsnHoBCA4ekh1PRWImfFSU0,3460
39
+ dyff_schema-0.10.1.dist-info/NOTICE,sha256=YONACu0s_Ui6jNi-wtEsVQbTU1JIkh8wvLH6d1-Ni_w,43
40
+ dyff_schema-0.10.1.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
41
+ dyff_schema-0.10.1.dist-info/top_level.txt,sha256=9e3VVdeX73t_sUJOPQPCcGtYO1JhoErhHIi3WoWGcFI,5
42
+ dyff_schema-0.10.1.dist-info/RECORD,,