dyff-schema 0.32.0__tar.gz → 0.33.1__tar.gz
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-0.32.0 → dyff_schema-0.33.1}/.gitlab-ci.yml +2 -2
- {dyff_schema-0.32.0/dyff_schema.egg-info → dyff_schema-0.33.1}/PKG-INFO +2 -1
- dyff_schema-0.33.1/dyff/schema/_version.py +2 -0
- dyff_schema-0.33.1/dyff/schema/v0/r1/oci.py +183 -0
- {dyff_schema-0.32.0 → dyff_schema-0.33.1}/dyff/schema/v0/r1/platform.py +40 -1
- {dyff_schema-0.32.0 → dyff_schema-0.33.1}/dyff/schema/v0/r1/requests.py +25 -1
- {dyff_schema-0.32.0 → dyff_schema-0.33.1/dyff_schema.egg-info}/PKG-INFO +2 -1
- {dyff_schema-0.32.0 → dyff_schema-0.33.1}/dyff_schema.egg-info/SOURCES.txt +1 -0
- {dyff_schema-0.32.0 → dyff_schema-0.33.1}/dyff_schema.egg-info/requires.txt +1 -0
- {dyff_schema-0.32.0 → dyff_schema-0.33.1}/pyproject.toml +1 -0
- dyff_schema-0.32.0/dyff/schema/_version.py +0 -2
- {dyff_schema-0.32.0 → dyff_schema-0.33.1}/.gitignore +0 -0
- {dyff_schema-0.32.0 → dyff_schema-0.33.1}/.idea/dyff-schema.iml +0 -0
- {dyff_schema-0.32.0 → dyff_schema-0.33.1}/.licenserc.yaml +0 -0
- {dyff_schema-0.32.0 → dyff_schema-0.33.1}/.pre-commit-config.yaml +0 -0
- {dyff_schema-0.32.0 → dyff_schema-0.33.1}/.prettierignore +0 -0
- {dyff_schema-0.32.0 → dyff_schema-0.33.1}/.secrets.baseline +0 -0
- {dyff_schema-0.32.0 → dyff_schema-0.33.1}/CODE_OF_CONDUCT.md +0 -0
- {dyff_schema-0.32.0 → dyff_schema-0.33.1}/LICENSE +0 -0
- {dyff_schema-0.32.0 → dyff_schema-0.33.1}/NOTICE +0 -0
- {dyff_schema-0.32.0 → dyff_schema-0.33.1}/README.md +0 -0
- {dyff_schema-0.32.0 → dyff_schema-0.33.1}/dyff/schema/__init__.py +0 -0
- {dyff_schema-0.32.0 → dyff_schema-0.33.1}/dyff/schema/adapters.py +0 -0
- {dyff_schema-0.32.0 → dyff_schema-0.33.1}/dyff/schema/annotations.py +0 -0
- {dyff_schema-0.32.0 → dyff_schema-0.33.1}/dyff/schema/base.py +0 -0
- {dyff_schema-0.32.0 → dyff_schema-0.33.1}/dyff/schema/commands.py +0 -0
- {dyff_schema-0.32.0 → dyff_schema-0.33.1}/dyff/schema/copydoc.py +0 -0
- {dyff_schema-0.32.0 → dyff_schema-0.33.1}/dyff/schema/dataset/__init__.py +0 -0
- {dyff_schema-0.32.0 → dyff_schema-0.33.1}/dyff/schema/dataset/arrow.py +0 -0
- {dyff_schema-0.32.0 → dyff_schema-0.33.1}/dyff/schema/dataset/binary.py +0 -0
- {dyff_schema-0.32.0 → dyff_schema-0.33.1}/dyff/schema/dataset/classification.py +0 -0
- {dyff_schema-0.32.0 → dyff_schema-0.33.1}/dyff/schema/dataset/embedding.py +0 -0
- {dyff_schema-0.32.0 → dyff_schema-0.33.1}/dyff/schema/dataset/text.py +0 -0
- {dyff_schema-0.32.0 → dyff_schema-0.33.1}/dyff/schema/dataset/vision.py +0 -0
- {dyff_schema-0.32.0 → dyff_schema-0.33.1}/dyff/schema/errors.py +0 -0
- {dyff_schema-0.32.0 → dyff_schema-0.33.1}/dyff/schema/ids.py +0 -0
- {dyff_schema-0.32.0 → dyff_schema-0.33.1}/dyff/schema/io/__init__.py +0 -0
- {dyff_schema-0.32.0 → dyff_schema-0.33.1}/dyff/schema/io/vllm.py +0 -0
- {dyff_schema-0.32.0 → dyff_schema-0.33.1}/dyff/schema/platform.py +0 -0
- {dyff_schema-0.32.0 → dyff_schema-0.33.1}/dyff/schema/py.typed +0 -0
- {dyff_schema-0.32.0 → dyff_schema-0.33.1}/dyff/schema/quantity.py +0 -0
- {dyff_schema-0.32.0 → dyff_schema-0.33.1}/dyff/schema/requests.py +0 -0
- {dyff_schema-0.32.0 → dyff_schema-0.33.1}/dyff/schema/responses.py +0 -0
- {dyff_schema-0.32.0 → dyff_schema-0.33.1}/dyff/schema/test.py +0 -0
- {dyff_schema-0.32.0 → dyff_schema-0.33.1}/dyff/schema/v0/__init__.py +0 -0
- {dyff_schema-0.32.0 → dyff_schema-0.33.1}/dyff/schema/v0/r1/__init__.py +0 -0
- {dyff_schema-0.32.0 → dyff_schema-0.33.1}/dyff/schema/v0/r1/adapters.py +0 -0
- {dyff_schema-0.32.0 → dyff_schema-0.33.1}/dyff/schema/v0/r1/base.py +0 -0
- {dyff_schema-0.32.0 → dyff_schema-0.33.1}/dyff/schema/v0/r1/commands.py +0 -0
- {dyff_schema-0.32.0 → dyff_schema-0.33.1}/dyff/schema/v0/r1/dataset/__init__.py +0 -0
- {dyff_schema-0.32.0 → dyff_schema-0.33.1}/dyff/schema/v0/r1/dataset/arrow.py +0 -0
- {dyff_schema-0.32.0 → dyff_schema-0.33.1}/dyff/schema/v0/r1/dataset/binary.py +0 -0
- {dyff_schema-0.32.0 → dyff_schema-0.33.1}/dyff/schema/v0/r1/dataset/classification.py +0 -0
- {dyff_schema-0.32.0 → dyff_schema-0.33.1}/dyff/schema/v0/r1/dataset/embedding.py +0 -0
- {dyff_schema-0.32.0 → dyff_schema-0.33.1}/dyff/schema/v0/r1/dataset/text.py +0 -0
- {dyff_schema-0.32.0 → dyff_schema-0.33.1}/dyff/schema/v0/r1/dataset/vision.py +0 -0
- {dyff_schema-0.32.0 → dyff_schema-0.33.1}/dyff/schema/v0/r1/io/__init__.py +0 -0
- {dyff_schema-0.32.0 → dyff_schema-0.33.1}/dyff/schema/v0/r1/io/vllm.py +0 -0
- {dyff_schema-0.32.0 → dyff_schema-0.33.1}/dyff/schema/v0/r1/responses.py +0 -0
- {dyff_schema-0.32.0 → dyff_schema-0.33.1}/dyff/schema/v0/r1/test.py +0 -0
- {dyff_schema-0.32.0 → dyff_schema-0.33.1}/dyff/schema/v0/r1/version.py +0 -0
- {dyff_schema-0.32.0 → dyff_schema-0.33.1}/dyff/schema/version.py +0 -0
- {dyff_schema-0.32.0 → dyff_schema-0.33.1}/dyff_schema.egg-info/dependency_links.txt +0 -0
- {dyff_schema-0.32.0 → dyff_schema-0.33.1}/dyff_schema.egg-info/top_level.txt +0 -0
- {dyff_schema-0.32.0 → dyff_schema-0.33.1}/makefile +0 -0
- {dyff_schema-0.32.0 → dyff_schema-0.33.1}/setup.cfg +0 -0
- {dyff_schema-0.32.0 → dyff_schema-0.33.1}/tests/test_adapters.py +0 -0
- {dyff_schema-0.32.0 → dyff_schema-0.33.1}/tests/test_import.py +0 -0
|
@@ -8,7 +8,7 @@ stages:
|
|
|
8
8
|
|
|
9
9
|
include:
|
|
10
10
|
- project: saferatday0/library/gitlab
|
|
11
|
-
ref: 0.
|
|
11
|
+
ref: 0.18.3
|
|
12
12
|
file:
|
|
13
13
|
- gitlab-release.yml
|
|
14
14
|
- project: saferatday0/library/detect-secrets
|
|
@@ -20,7 +20,7 @@ include:
|
|
|
20
20
|
file:
|
|
21
21
|
- prettier.yml
|
|
22
22
|
- project: saferatday0/library/python
|
|
23
|
-
ref: 0.
|
|
23
|
+
ref: 0.22.0
|
|
24
24
|
file:
|
|
25
25
|
- python-autoflake.yml
|
|
26
26
|
- python-black.yml
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: dyff-schema
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.33.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
|
|
@@ -20,6 +20,7 @@ Requires-Python: >=3.10
|
|
|
20
20
|
Description-Content-Type: text/markdown
|
|
21
21
|
License-File: LICENSE
|
|
22
22
|
License-File: NOTICE
|
|
23
|
+
Requires-Dist: canonicaljson==2.0.0
|
|
23
24
|
Requires-Dist: hypothesis
|
|
24
25
|
Requires-Dist: hypothesis-jsonschema
|
|
25
26
|
Requires-Dist: jsonpath-ng
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
# SPDX-FileCopyrightText: 2024 UL Research Institutes
|
|
2
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
from __future__ import annotations
|
|
5
|
+
|
|
6
|
+
import enum
|
|
7
|
+
import hashlib
|
|
8
|
+
from datetime import datetime, timezone
|
|
9
|
+
from typing import Any, Literal, Optional
|
|
10
|
+
|
|
11
|
+
import canonicaljson
|
|
12
|
+
import pydantic
|
|
13
|
+
|
|
14
|
+
from .base import int64
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class KnownMediaTypes(str, enum.Enum):
|
|
18
|
+
oci_image_manifest = "application/vnd.oci.image.manifest.v1+json"
|
|
19
|
+
oci_image_config = "application/vnd.oci.image.config.v1+json"
|
|
20
|
+
oci_image_layer_tar = "application/vnd.oci.image.layer.v1.tar"
|
|
21
|
+
oci_image_layer_tar_gzip = "application/vnd.oci.image.layer.v1.tar+gzip"
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
# mypy gets confused because 'dict' is the name of a method in DyffBaseModel
|
|
25
|
+
_ModelAsDict = dict[str, Any]
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
class _OCISchemaBaseModel(pydantic.BaseModel):
|
|
29
|
+
def model_dump( # type: ignore [override]
|
|
30
|
+
self, *, by_alias: bool = True, exclude_none: bool = True, **kwargs
|
|
31
|
+
) -> _ModelAsDict:
|
|
32
|
+
return super().model_dump(
|
|
33
|
+
by_alias=by_alias, exclude_none=exclude_none, **kwargs
|
|
34
|
+
)
|
|
35
|
+
|
|
36
|
+
def model_dump_json( # type: ignore [override]
|
|
37
|
+
self, *, by_alias: bool = True, exclude_none: bool = True, **kwargs
|
|
38
|
+
) -> str:
|
|
39
|
+
return super().model_dump_json(
|
|
40
|
+
by_alias=by_alias, exclude_none=exclude_none, **kwargs
|
|
41
|
+
)
|
|
42
|
+
|
|
43
|
+
def dict(
|
|
44
|
+
self, *, by_alias: bool = True, exclude_none: bool = True, **kwargs
|
|
45
|
+
) -> _ModelAsDict:
|
|
46
|
+
return self.model_dump(by_alias=by_alias, exclude_none=exclude_none, **kwargs)
|
|
47
|
+
|
|
48
|
+
def json(
|
|
49
|
+
self, *, by_alias: bool = True, exclude_none: bool = True, **kwargs
|
|
50
|
+
) -> str:
|
|
51
|
+
return self.model_dump_json(
|
|
52
|
+
by_alias=by_alias, exclude_none=exclude_none, **kwargs
|
|
53
|
+
)
|
|
54
|
+
|
|
55
|
+
@pydantic.model_validator(mode="after")
|
|
56
|
+
def _ensure_datetime_timezone_utc(cls, values):
|
|
57
|
+
for field_name, field_value in values.__dict__.items():
|
|
58
|
+
if isinstance(field_value, datetime):
|
|
59
|
+
if field_value.tzinfo is None:
|
|
60
|
+
# Set UTC timezone for naive datetime
|
|
61
|
+
setattr(
|
|
62
|
+
values, field_name, field_value.replace(tzinfo=timezone.utc)
|
|
63
|
+
)
|
|
64
|
+
elif field_value.tzinfo != timezone.utc:
|
|
65
|
+
# Convert to UTC timezone
|
|
66
|
+
setattr(values, field_name, field_value.astimezone(timezone.utc))
|
|
67
|
+
return values
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
class _DigestMixin(pydantic.BaseModel):
|
|
71
|
+
def digest(self) -> str:
|
|
72
|
+
obj = self.model_dump(mode="json")
|
|
73
|
+
h = hashlib.sha256(usedforsecurity=False)
|
|
74
|
+
for chunk in canonicaljson.iterencode_canonical_json(obj):
|
|
75
|
+
h.update(chunk)
|
|
76
|
+
return "sha256:{}".format(h.hexdigest())
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
class Platform(_OCISchemaBaseModel):
|
|
80
|
+
architecture: str
|
|
81
|
+
os: str
|
|
82
|
+
os_version: Optional[str] = pydantic.Field(alias="os.version", default=None)
|
|
83
|
+
os_features: Optional[list[str]] = pydantic.Field(alias="os.features", default=None)
|
|
84
|
+
variant: Optional[str] = pydantic.Field(default=None)
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
class Descriptor(_OCISchemaBaseModel):
|
|
88
|
+
"""
|
|
89
|
+
https://github.com/opencontainers/image-spec/blob/v1.1.1/descriptor.md
|
|
90
|
+
"""
|
|
91
|
+
|
|
92
|
+
mediaType: str = pydantic.Field()
|
|
93
|
+
digest: str = pydantic.Field()
|
|
94
|
+
size: int64() = pydantic.Field( # type: ignore
|
|
95
|
+
description="This REQUIRED property specifies the size, in bytes,"
|
|
96
|
+
" of the raw content. This property exists so that a client"
|
|
97
|
+
" will have an expected size for the content before processing."
|
|
98
|
+
" If the length of the retrieved content does not match"
|
|
99
|
+
" the specified length, the content SHOULD NOT be trusted."
|
|
100
|
+
)
|
|
101
|
+
urls: Optional[list[str]] = pydantic.Field(default=None)
|
|
102
|
+
annotations: Optional[dict[str, str]] = pydantic.Field(default=None)
|
|
103
|
+
data: Optional[str] = pydantic.Field(default=None)
|
|
104
|
+
artifactType: Optional[str] = pydantic.Field(default=None)
|
|
105
|
+
|
|
106
|
+
@staticmethod
|
|
107
|
+
def empty() -> Descriptor:
|
|
108
|
+
"""
|
|
109
|
+
https://github.com/opencontainers/image-spec/blob/v1.1.1/manifest.md#guidance-for-an-empty-descriptor
|
|
110
|
+
"""
|
|
111
|
+
return Descriptor.model_validate(
|
|
112
|
+
{
|
|
113
|
+
"mediaType": "application/vnd.oci.empty.v1+json",
|
|
114
|
+
"digest": "sha256:44136fa355b3678a1146ad16f7e8649e94fb4fc21fe77e8310c060f61caaff8a",
|
|
115
|
+
"size": 2,
|
|
116
|
+
"data": "e30=",
|
|
117
|
+
}
|
|
118
|
+
)
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
class ImageDescriptor(Descriptor):
|
|
122
|
+
platform: Platform
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
class ExecutionParameters(_OCISchemaBaseModel):
|
|
126
|
+
# TODO
|
|
127
|
+
pass
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
class RootFS(_OCISchemaBaseModel):
|
|
131
|
+
type_: Literal["layers"] = pydantic.Field(alias="type", default="layers")
|
|
132
|
+
diff_ids: list[str] = pydantic.Field()
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
class HistoryEntry(_OCISchemaBaseModel):
|
|
136
|
+
created: Optional[str] = pydantic.Field(default=None)
|
|
137
|
+
author: Optional[str] = pydantic.Field(default=None)
|
|
138
|
+
created_by: Optional[str] = pydantic.Field(default=None)
|
|
139
|
+
comment: Optional[str] = pydantic.Field(default=None)
|
|
140
|
+
empty_layer: Optional[bool] = pydantic.Field(default=None)
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
class ImageConfig(Platform, _DigestMixin):
|
|
144
|
+
"""
|
|
145
|
+
https://github.com/opencontainers/image-spec/blob/v1.1.1/config.md
|
|
146
|
+
"""
|
|
147
|
+
|
|
148
|
+
created: Optional[str] = pydantic.Field(default=None)
|
|
149
|
+
author: Optional[str] = pydantic.Field(default=None)
|
|
150
|
+
config: Optional[ExecutionParameters] = pydantic.Field(default=None)
|
|
151
|
+
rootfs: RootFS
|
|
152
|
+
history: Optional[list[HistoryEntry]] = pydantic.Field(default=None)
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
class ImageManifest(_OCISchemaBaseModel):
|
|
156
|
+
schemaVersion: Literal["2"] = "2"
|
|
157
|
+
mediaType: Literal["application/vnd.oci.image.manifest.v1+json"] = (
|
|
158
|
+
"application/vnd.oci.image.manifest.v1+json"
|
|
159
|
+
)
|
|
160
|
+
artifactType: Optional[str] = pydantic.Field(default=None)
|
|
161
|
+
config: Descriptor = pydantic.Field(default_factory=Descriptor.empty)
|
|
162
|
+
layers: list[Descriptor] = pydantic.Field(
|
|
163
|
+
default_factory=lambda: [Descriptor.empty()]
|
|
164
|
+
)
|
|
165
|
+
subject: Optional[Descriptor] = pydantic.Field(default=None)
|
|
166
|
+
annotations: Optional[dict[str, str]] = pydantic.Field(default=None)
|
|
167
|
+
|
|
168
|
+
def is_image_manifest(self) -> bool:
|
|
169
|
+
return self.artifactType is None
|
|
170
|
+
|
|
171
|
+
def is_artifact_manifest(self) -> bool:
|
|
172
|
+
return self.artifactType is not None
|
|
173
|
+
|
|
174
|
+
@pydantic.model_validator(mode="after")
|
|
175
|
+
def validate_types(self):
|
|
176
|
+
if self.artifactType is None:
|
|
177
|
+
if self.config.mediaType != KnownMediaTypes.oci_image_config.value:
|
|
178
|
+
raise ValueError(
|
|
179
|
+
".config.mediaType must be"
|
|
180
|
+
f"{KnownMediaTypes.oci_image_config.value}"
|
|
181
|
+
" if .artifactType is unspecified"
|
|
182
|
+
)
|
|
183
|
+
return self
|
|
@@ -33,6 +33,7 @@ from typing_extensions import Annotated, TypeAlias
|
|
|
33
33
|
|
|
34
34
|
from ... import named_data_schema, product_schema
|
|
35
35
|
from ...version import SomeSchemaVersion
|
|
36
|
+
from . import oci
|
|
36
37
|
from .base import DyffSchemaBaseModel
|
|
37
38
|
from .dataset import arrow, make_item_type, make_response_type
|
|
38
39
|
from .version import SCHEMA_VERSION, SchemaVersion
|
|
@@ -193,6 +194,8 @@ class Entities(str, enum.Enum):
|
|
|
193
194
|
|
|
194
195
|
Account = "Account"
|
|
195
196
|
Analysis = "Analysis"
|
|
197
|
+
# FIXME: (schema v1) Rename to Artifact
|
|
198
|
+
Artifact = "OCIArtifact"
|
|
196
199
|
Audit = "Audit"
|
|
197
200
|
AuditProcedure = "AuditProcedure"
|
|
198
201
|
Concern = "Concern"
|
|
@@ -220,6 +223,7 @@ class Resources(str, enum.Enum):
|
|
|
220
223
|
"""The resource names corresponding to entities that have API endpoints."""
|
|
221
224
|
|
|
222
225
|
Analysis = "analyses"
|
|
226
|
+
Artifact = "artifacts"
|
|
223
227
|
Audit = "audits"
|
|
224
228
|
AuditProcedure = "auditprocedures"
|
|
225
229
|
Concern = "concerns"
|
|
@@ -259,6 +263,9 @@ class Resources(str, enum.Enum):
|
|
|
259
263
|
@staticmethod
|
|
260
264
|
def for_kind(kind: Entities) -> "Resources":
|
|
261
265
|
try:
|
|
266
|
+
# FIXME: (schema v1) Special case for legacy OCIArtifact name
|
|
267
|
+
if kind == Entities.Artifact:
|
|
268
|
+
return Resources.Artifact
|
|
262
269
|
return Resources[kind.value]
|
|
263
270
|
except KeyError:
|
|
264
271
|
raise ValueError(f"No Resources for Entity kind: {kind}")
|
|
@@ -280,6 +287,8 @@ EntityKindLiteral = Literal[
|
|
|
280
287
|
"Method",
|
|
281
288
|
"Model",
|
|
282
289
|
"Module",
|
|
290
|
+
# FIXME: (schema v1) Rename to Artifact
|
|
291
|
+
"OCIArtifact",
|
|
283
292
|
"Report",
|
|
284
293
|
"Revision",
|
|
285
294
|
"SafetyCase",
|
|
@@ -502,6 +511,8 @@ class DyffEntity(Status, Labeled, SchemaVersion, DyffModelWithID):
|
|
|
502
511
|
"Method",
|
|
503
512
|
"Model",
|
|
504
513
|
"Module",
|
|
514
|
+
# FIXME: (schema v1) Rename to Artifact
|
|
515
|
+
"OCIArtifact",
|
|
505
516
|
"Report",
|
|
506
517
|
"Revision",
|
|
507
518
|
"SafetyCase",
|
|
@@ -829,8 +840,10 @@ class Digest(DyffSchemaBaseModel):
|
|
|
829
840
|
)
|
|
830
841
|
|
|
831
842
|
|
|
843
|
+
# TODO: (schema-v1) Rename this to "File" or something -- reserve Artifact
|
|
844
|
+
# for OCI artifacts.
|
|
832
845
|
class Artifact(DyffSchemaBaseModel):
|
|
833
|
-
# TODO:
|
|
846
|
+
# TODO: (schema-v1) Rename this to 'contentType' or something and commit to making it the MIME type
|
|
834
847
|
kind: Optional[str] = pydantic.Field(
|
|
835
848
|
default=None, description="The kind of artifact"
|
|
836
849
|
)
|
|
@@ -1122,6 +1135,10 @@ class ModelSource(DyffSchemaBaseModel):
|
|
|
1122
1135
|
)
|
|
1123
1136
|
|
|
1124
1137
|
|
|
1138
|
+
class ContainerImage(DyffSchemaBaseModel):
|
|
1139
|
+
pass
|
|
1140
|
+
|
|
1141
|
+
|
|
1125
1142
|
class AcceleratorGPU(DyffSchemaBaseModel):
|
|
1126
1143
|
hardwareTypes: list[str] = pydantic.Field(
|
|
1127
1144
|
min_length=1,
|
|
@@ -2130,6 +2147,25 @@ class Score(ScoreData):
|
|
|
2130
2147
|
id: str = pydantic.Field(description="Unique identifier of the entity")
|
|
2131
2148
|
|
|
2132
2149
|
|
|
2150
|
+
# ---------------------------------------------------------------------------
|
|
2151
|
+
# OCI artifacts
|
|
2152
|
+
|
|
2153
|
+
|
|
2154
|
+
# TODO: (schema-v1) Rename this to Artifact
|
|
2155
|
+
class OCIArtifact(DyffEntity):
|
|
2156
|
+
kind: Literal["OCIArtifact"] = Entities.Artifact.value
|
|
2157
|
+
|
|
2158
|
+
manifest: oci.ImageManifest = pydantic.Field(
|
|
2159
|
+
description="The OCI image manifest of the artifact"
|
|
2160
|
+
)
|
|
2161
|
+
|
|
2162
|
+
def dependencies(self) -> list[str]:
|
|
2163
|
+
return []
|
|
2164
|
+
|
|
2165
|
+
def resource_allocation(self) -> Optional[ResourceAllocation]:
|
|
2166
|
+
return None
|
|
2167
|
+
|
|
2168
|
+
|
|
2133
2169
|
# ---------------------------------------------------------------------------
|
|
2134
2170
|
# Status enumerations
|
|
2135
2171
|
|
|
@@ -2372,6 +2408,7 @@ def is_status_success(status: str) -> bool:
|
|
|
2372
2408
|
|
|
2373
2409
|
_ENTITY_CLASS = {
|
|
2374
2410
|
Entities.Analysis: Analysis,
|
|
2411
|
+
Entities.Artifact: OCIArtifact,
|
|
2375
2412
|
Entities.Audit: Audit,
|
|
2376
2413
|
Entities.AuditProcedure: AuditProcedure,
|
|
2377
2414
|
Entities.Dataset: Dataset,
|
|
@@ -2406,6 +2443,7 @@ _DyffEntityTypeRevisable = Union[
|
|
|
2406
2443
|
Method,
|
|
2407
2444
|
Model,
|
|
2408
2445
|
Module,
|
|
2446
|
+
OCIArtifact,
|
|
2409
2447
|
Report,
|
|
2410
2448
|
SafetyCase,
|
|
2411
2449
|
UseCase,
|
|
@@ -2579,6 +2617,7 @@ __all__ = [
|
|
|
2579
2617
|
"ModelStorage",
|
|
2580
2618
|
"Module",
|
|
2581
2619
|
"ModuleBase",
|
|
2620
|
+
"OCIArtifact",
|
|
2582
2621
|
"QueryableDyffEntity",
|
|
2583
2622
|
"Report",
|
|
2584
2623
|
"ReportBase",
|
|
@@ -21,7 +21,7 @@ from typing import Any, Literal, Optional, Union
|
|
|
21
21
|
import pydantic
|
|
22
22
|
|
|
23
23
|
from ... import upcast
|
|
24
|
-
from . import commands
|
|
24
|
+
from . import commands, oci
|
|
25
25
|
from .base import DyffBaseModel, JsonMergePatchSemantics
|
|
26
26
|
from .platform import (
|
|
27
27
|
AnalysisBase,
|
|
@@ -72,6 +72,20 @@ class DyffRequestBase(SchemaVersion, DyffRequestDefaultValidators):
|
|
|
72
72
|
# TODO: (DYFF-223) I think that exclude_unset=True should be the default
|
|
73
73
|
# for all schema objects, but I'm unsure of the consequences of making
|
|
74
74
|
# this change and we'll defer it until v1.
|
|
75
|
+
def model_dump( # type: ignore [override]
|
|
76
|
+
self, *, by_alias: bool = True, exclude_unset=True, **kwargs
|
|
77
|
+
) -> _ModelAsDict:
|
|
78
|
+
return super().model_dump(
|
|
79
|
+
by_alias=by_alias, exclude_unset=exclude_unset, **kwargs
|
|
80
|
+
)
|
|
81
|
+
|
|
82
|
+
def model_dump_json( # type: ignore [override]
|
|
83
|
+
self, *, by_alias: bool = True, exclude_unset=True, **kwargs
|
|
84
|
+
) -> str:
|
|
85
|
+
return super().model_dump_json(
|
|
86
|
+
by_alias=by_alias, exclude_unset=exclude_unset, **kwargs
|
|
87
|
+
)
|
|
88
|
+
|
|
75
89
|
def dict(
|
|
76
90
|
self, *, by_alias: bool = True, exclude_unset=True, **kwargs
|
|
77
91
|
) -> _ModelAsDict:
|
|
@@ -118,6 +132,10 @@ class AnalysisCreateRequest(DyffEntityCreateRequest, AnalysisBase):
|
|
|
118
132
|
return scope
|
|
119
133
|
|
|
120
134
|
|
|
135
|
+
class ArtifactCreateRequest(DyffEntityCreateRequest):
|
|
136
|
+
manifest: oci.ImageManifest
|
|
137
|
+
|
|
138
|
+
|
|
121
139
|
class ConcernCreateRequest(DyffEntityCreateRequest, ConcernBase):
|
|
122
140
|
@pydantic.field_validator("documentation", check_fields=False)
|
|
123
141
|
def _validate_documentation(
|
|
@@ -357,6 +375,10 @@ class _AnalysisProductQueryRequest(DyffEntityQueryRequest):
|
|
|
357
375
|
inputs: Optional[str] = pydantic.Field(default=None)
|
|
358
376
|
|
|
359
377
|
|
|
378
|
+
class ArtifactQueryRequest(DyffEntityQueryRequest):
|
|
379
|
+
name: Optional[str] = pydantic.Field(default=None)
|
|
380
|
+
|
|
381
|
+
|
|
360
382
|
class AuditQueryRequest(DyffEntityQueryRequest):
|
|
361
383
|
name: Optional[str] = pydantic.Field(default=None)
|
|
362
384
|
|
|
@@ -446,6 +468,8 @@ class UseCaseQueryRequest(DyffEntityQueryRequest):
|
|
|
446
468
|
|
|
447
469
|
__all__ = [
|
|
448
470
|
"AnalysisCreateRequest",
|
|
471
|
+
"ArtifactCreateRequest",
|
|
472
|
+
"ArtifactQueryRequest",
|
|
449
473
|
"AuditQueryRequest",
|
|
450
474
|
"ConcernCreateRequest",
|
|
451
475
|
"DyffEntityCreateRequest",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: dyff-schema
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.33.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
|
|
@@ -20,6 +20,7 @@ Requires-Python: >=3.10
|
|
|
20
20
|
Description-Content-Type: text/markdown
|
|
21
21
|
License-File: LICENSE
|
|
22
22
|
License-File: NOTICE
|
|
23
|
+
Requires-Dist: canonicaljson==2.0.0
|
|
23
24
|
Requires-Dist: hypothesis
|
|
24
25
|
Requires-Dist: hypothesis-jsonschema
|
|
25
26
|
Requires-Dist: jsonpath-ng
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|