dyff-schema 0.27.3__tar.gz → 0.28.0__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.27.3/dyff_schema.egg-info → dyff_schema-0.28.0}/PKG-INFO +3 -2
- dyff_schema-0.28.0/dyff/schema/__init__.py +66 -0
- {dyff_schema-0.27.3 → dyff_schema-0.28.0}/dyff/schema/v0/r1/commands.py +42 -1
- {dyff_schema-0.27.3 → dyff_schema-0.28.0}/dyff/schema/v0/r1/platform.py +1 -3
- {dyff_schema-0.27.3 → dyff_schema-0.28.0}/dyff/schema/v0/r1/requests.py +24 -0
- {dyff_schema-0.27.3 → dyff_schema-0.28.0/dyff_schema.egg-info}/PKG-INFO +3 -2
- dyff_schema-0.27.3/dyff/schema/__init__.py +0 -39
- {dyff_schema-0.27.3 → dyff_schema-0.28.0}/.gitignore +0 -0
- {dyff_schema-0.27.3 → dyff_schema-0.28.0}/.gitlab-ci.yml +0 -0
- {dyff_schema-0.27.3 → dyff_schema-0.28.0}/.licenserc.yaml +0 -0
- {dyff_schema-0.27.3 → dyff_schema-0.28.0}/.pre-commit-config.yaml +0 -0
- {dyff_schema-0.27.3 → dyff_schema-0.28.0}/.prettierignore +0 -0
- {dyff_schema-0.27.3 → dyff_schema-0.28.0}/.secrets.baseline +0 -0
- {dyff_schema-0.27.3 → dyff_schema-0.28.0}/CODE_OF_CONDUCT.md +0 -0
- {dyff_schema-0.27.3 → dyff_schema-0.28.0}/LICENSE +0 -0
- {dyff_schema-0.27.3 → dyff_schema-0.28.0}/NOTICE +0 -0
- {dyff_schema-0.27.3 → dyff_schema-0.28.0}/README.md +0 -0
- {dyff_schema-0.27.3 → dyff_schema-0.28.0}/dyff/schema/adapters.py +0 -0
- {dyff_schema-0.27.3 → dyff_schema-0.28.0}/dyff/schema/annotations.py +0 -0
- {dyff_schema-0.27.3 → dyff_schema-0.28.0}/dyff/schema/base.py +0 -0
- {dyff_schema-0.27.3 → dyff_schema-0.28.0}/dyff/schema/commands.py +0 -0
- {dyff_schema-0.27.3 → dyff_schema-0.28.0}/dyff/schema/copydoc.py +0 -0
- {dyff_schema-0.27.3 → dyff_schema-0.28.0}/dyff/schema/dataset/__init__.py +0 -0
- {dyff_schema-0.27.3 → dyff_schema-0.28.0}/dyff/schema/dataset/arrow.py +0 -0
- {dyff_schema-0.27.3 → dyff_schema-0.28.0}/dyff/schema/dataset/binary.py +0 -0
- {dyff_schema-0.27.3 → dyff_schema-0.28.0}/dyff/schema/dataset/classification.py +0 -0
- {dyff_schema-0.27.3 → dyff_schema-0.28.0}/dyff/schema/dataset/embedding.py +0 -0
- {dyff_schema-0.27.3 → dyff_schema-0.28.0}/dyff/schema/dataset/text.py +0 -0
- {dyff_schema-0.27.3 → dyff_schema-0.28.0}/dyff/schema/dataset/vision.py +0 -0
- {dyff_schema-0.27.3 → dyff_schema-0.28.0}/dyff/schema/errors.py +0 -0
- {dyff_schema-0.27.3 → dyff_schema-0.28.0}/dyff/schema/ids.py +0 -0
- {dyff_schema-0.27.3 → dyff_schema-0.28.0}/dyff/schema/io/__init__.py +0 -0
- {dyff_schema-0.27.3 → dyff_schema-0.28.0}/dyff/schema/io/vllm.py +0 -0
- {dyff_schema-0.27.3 → dyff_schema-0.28.0}/dyff/schema/platform.py +0 -0
- {dyff_schema-0.27.3 → dyff_schema-0.28.0}/dyff/schema/py.typed +0 -0
- {dyff_schema-0.27.3 → dyff_schema-0.28.0}/dyff/schema/quantity.py +0 -0
- {dyff_schema-0.27.3 → dyff_schema-0.28.0}/dyff/schema/requests.py +0 -0
- {dyff_schema-0.27.3 → dyff_schema-0.28.0}/dyff/schema/test.py +0 -0
- {dyff_schema-0.27.3 → dyff_schema-0.28.0}/dyff/schema/v0/__init__.py +0 -0
- {dyff_schema-0.27.3 → dyff_schema-0.28.0}/dyff/schema/v0/r1/__init__.py +0 -0
- {dyff_schema-0.27.3 → dyff_schema-0.28.0}/dyff/schema/v0/r1/adapters.py +0 -0
- {dyff_schema-0.27.3 → dyff_schema-0.28.0}/dyff/schema/v0/r1/base.py +0 -0
- {dyff_schema-0.27.3 → dyff_schema-0.28.0}/dyff/schema/v0/r1/dataset/__init__.py +0 -0
- {dyff_schema-0.27.3 → dyff_schema-0.28.0}/dyff/schema/v0/r1/dataset/arrow.py +0 -0
- {dyff_schema-0.27.3 → dyff_schema-0.28.0}/dyff/schema/v0/r1/dataset/binary.py +0 -0
- {dyff_schema-0.27.3 → dyff_schema-0.28.0}/dyff/schema/v0/r1/dataset/classification.py +0 -0
- {dyff_schema-0.27.3 → dyff_schema-0.28.0}/dyff/schema/v0/r1/dataset/embedding.py +0 -0
- {dyff_schema-0.27.3 → dyff_schema-0.28.0}/dyff/schema/v0/r1/dataset/text.py +0 -0
- {dyff_schema-0.27.3 → dyff_schema-0.28.0}/dyff/schema/v0/r1/dataset/vision.py +0 -0
- {dyff_schema-0.27.3 → dyff_schema-0.28.0}/dyff/schema/v0/r1/io/__init__.py +0 -0
- {dyff_schema-0.27.3 → dyff_schema-0.28.0}/dyff/schema/v0/r1/io/vllm.py +0 -0
- {dyff_schema-0.27.3 → dyff_schema-0.28.0}/dyff/schema/v0/r1/test.py +0 -0
- {dyff_schema-0.27.3 → dyff_schema-0.28.0}/dyff/schema/v0/r1/version.py +0 -0
- {dyff_schema-0.27.3 → dyff_schema-0.28.0}/dyff/schema/version.py +0 -0
- {dyff_schema-0.27.3 → dyff_schema-0.28.0}/dyff_schema.egg-info/SOURCES.txt +0 -0
- {dyff_schema-0.27.3 → dyff_schema-0.28.0}/dyff_schema.egg-info/dependency_links.txt +0 -0
- {dyff_schema-0.27.3 → dyff_schema-0.28.0}/dyff_schema.egg-info/requires.txt +0 -0
- {dyff_schema-0.27.3 → dyff_schema-0.28.0}/dyff_schema.egg-info/top_level.txt +0 -0
- {dyff_schema-0.27.3 → dyff_schema-0.28.0}/makefile +0 -0
- {dyff_schema-0.27.3 → dyff_schema-0.28.0}/pyproject.toml +0 -0
- {dyff_schema-0.27.3 → dyff_schema-0.28.0}/setup.cfg +0 -0
- {dyff_schema-0.27.3 → dyff_schema-0.28.0}/tests/test_adapters.py +0 -0
- {dyff_schema-0.27.3 → dyff_schema-0.28.0}/tests/test_import.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: dyff-schema
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.28.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
|
|
@@ -27,6 +27,7 @@ Requires-Dist: jsonpath-ng
|
|
|
27
27
|
Requires-Dist: numpy<2
|
|
28
28
|
Requires-Dist: pyarrow
|
|
29
29
|
Requires-Dist: pydantic<2
|
|
30
|
+
Dynamic: license-file
|
|
30
31
|
|
|
31
32
|
# dyff-schema
|
|
32
33
|
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
# SPDX-FileCopyrightText: 2024 UL Research Institutes
|
|
2
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import importlib
|
|
5
|
+
from typing import Any, Iterable, Type, TypeVar, Union
|
|
6
|
+
|
|
7
|
+
import pydantic
|
|
8
|
+
|
|
9
|
+
from .base import DyffBaseModel, DyffSchemaBaseModel
|
|
10
|
+
from .version import SomeSchemaVersion
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def _symbol(fully_qualified_name):
|
|
14
|
+
tokens = fully_qualified_name.split(".")
|
|
15
|
+
module_name = ".".join(tokens[:-1])
|
|
16
|
+
member = tokens[-1]
|
|
17
|
+
module = importlib.import_module(module_name)
|
|
18
|
+
return getattr(module, member)
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def product_schema(
|
|
22
|
+
schemas: Iterable[Type[DyffSchemaBaseModel]],
|
|
23
|
+
) -> Type[DyffSchemaBaseModel]:
|
|
24
|
+
return pydantic.create_model("Product", __base__=tuple(schemas))
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
# TODO: Should have a way of registering schema names rather than allowing
|
|
28
|
+
# arbitrary imports.
|
|
29
|
+
def named_data_schema(
|
|
30
|
+
name: str, schema_version: SomeSchemaVersion
|
|
31
|
+
) -> Type[DyffSchemaBaseModel]:
|
|
32
|
+
version, revision = schema_version.split(".")
|
|
33
|
+
return _symbol(f"dyff.schema.v{version}.r{revision}.dataset.{name}")
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
_UpcastTargetT = TypeVar("_UpcastTargetT", bound=DyffBaseModel)
|
|
37
|
+
_UpcastSourceT = TypeVar("_UpcastSourceT", bound=DyffBaseModel)
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def upcast(
|
|
41
|
+
t: type[_UpcastTargetT], obj: Union[_UpcastSourceT, dict[str, Any]]
|
|
42
|
+
) -> _UpcastTargetT:
|
|
43
|
+
"""Perform a "structural upcast" on a Pydantic model instance.
|
|
44
|
+
|
|
45
|
+
An upcast is possible when the top-level fields of the target type are a subset of
|
|
46
|
+
the top-level fields of the source type, and the data in each source field validates
|
|
47
|
+
against the corresponding target field. In particular, an upcast is possible when
|
|
48
|
+
the source type is a Python subclass of the target type.
|
|
49
|
+
|
|
50
|
+
The upcast is "shallow" in the sense that sub-objects must validate as-is. In
|
|
51
|
+
particular, most Dyff schema types do not allow additional properties, so validation
|
|
52
|
+
will fail if a sub-object of the source object has fields that are not present in
|
|
53
|
+
the corresponding sub-object of the target type.
|
|
54
|
+
"""
|
|
55
|
+
if not isinstance(obj, dict):
|
|
56
|
+
# Preserve the unset status
|
|
57
|
+
obj = obj.dict(exclude_unset=True)
|
|
58
|
+
fields = {k: v for k, v in obj.items() if k in t.__fields__}
|
|
59
|
+
return t.parse_obj(fields)
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
__all__ = [
|
|
63
|
+
"named_data_schema",
|
|
64
|
+
"product_schema",
|
|
65
|
+
"upcast",
|
|
66
|
+
]
|
|
@@ -15,7 +15,6 @@ from .base import DyffSchemaBaseModel, JsonMergePatchSemantics, Null
|
|
|
15
15
|
from .platform import (
|
|
16
16
|
DyffEntityType,
|
|
17
17
|
EntityIdentifier,
|
|
18
|
-
EntityKindLiteral,
|
|
19
18
|
FamilyMember,
|
|
20
19
|
FamilyMembers,
|
|
21
20
|
LabelKeyType,
|
|
@@ -60,6 +59,7 @@ class Command(SchemaVersion, DyffSchemaBaseModel):
|
|
|
60
59
|
"EditEntityLabels",
|
|
61
60
|
"EditFamilyMembers",
|
|
62
61
|
"ForgetEntity",
|
|
62
|
+
"RestoreEntity",
|
|
63
63
|
"UpdateEntityStatus",
|
|
64
64
|
]
|
|
65
65
|
|
|
@@ -219,6 +219,43 @@ class ForgetEntity(Command):
|
|
|
219
219
|
# ----------------------------------------------------------------------------
|
|
220
220
|
|
|
221
221
|
|
|
222
|
+
class RestoreEntityAttributes(DyffSchemaBaseModel):
|
|
223
|
+
entity: DyffEntityType = pydantic.Field(
|
|
224
|
+
description="The full spec of the entity to restore."
|
|
225
|
+
)
|
|
226
|
+
|
|
227
|
+
ifRevisionMatch: Optional[str] = pydantic.Field(
|
|
228
|
+
default=None,
|
|
229
|
+
description="Do not change the entity if its revision does not match"
|
|
230
|
+
" the given revision.",
|
|
231
|
+
)
|
|
232
|
+
|
|
233
|
+
ifRevisionUndefined: Optional[bool] = pydantic.Field(
|
|
234
|
+
default=None,
|
|
235
|
+
description="Allow changing entities that have no revision."
|
|
236
|
+
" By default, entities with no revision will be changed if and only if"
|
|
237
|
+
" no other matching criteria are specified."
|
|
238
|
+
" This should be the case only for legacy data.",
|
|
239
|
+
)
|
|
240
|
+
|
|
241
|
+
|
|
242
|
+
class RestoreEntityData(EntityIdentifier):
|
|
243
|
+
attributes: RestoreEntityAttributes = pydantic.Field(
|
|
244
|
+
description="The command attributes"
|
|
245
|
+
)
|
|
246
|
+
|
|
247
|
+
|
|
248
|
+
class RestoreEntity(Command):
|
|
249
|
+
"""Restore an entity to a given state."""
|
|
250
|
+
|
|
251
|
+
command: Literal["RestoreEntity"] = "RestoreEntity"
|
|
252
|
+
|
|
253
|
+
data: RestoreEntityData = pydantic.Field(description="The command data.")
|
|
254
|
+
|
|
255
|
+
|
|
256
|
+
# ----------------------------------------------------------------------------
|
|
257
|
+
|
|
258
|
+
|
|
222
259
|
class UpdateEntityStatusAttributes(JsonMergePatchSemantics):
|
|
223
260
|
"""Attributes for the UpdateEntityStatus command."""
|
|
224
261
|
|
|
@@ -256,6 +293,7 @@ DyffCommandType = Union[
|
|
|
256
293
|
EditEntityLabels,
|
|
257
294
|
EditFamilyMembers,
|
|
258
295
|
ForgetEntity,
|
|
296
|
+
RestoreEntity,
|
|
259
297
|
UpdateEntityStatus,
|
|
260
298
|
]
|
|
261
299
|
|
|
@@ -277,6 +315,9 @@ __all__ = [
|
|
|
277
315
|
"EntityIdentifier",
|
|
278
316
|
"FamilyIdentifier",
|
|
279
317
|
"ForgetEntity",
|
|
318
|
+
"RestoreEntity",
|
|
319
|
+
"RestoreEntityAttributes",
|
|
320
|
+
"RestoreEntityData",
|
|
280
321
|
"UpdateEntityStatus",
|
|
281
322
|
"UpdateEntityStatusAttributes",
|
|
282
323
|
"UpdateEntityStatusData",
|
|
@@ -301,9 +301,7 @@ class EntityIdentifier(DyffSchemaBaseModel):
|
|
|
301
301
|
|
|
302
302
|
id: str = pydantic.Field(description="The .id of the entity.")
|
|
303
303
|
kind: EntityKindLiteral = pydantic.Field(
|
|
304
|
-
description="The .kind of the entity.
|
|
305
|
-
" sometimes you need to send a command without knowing the kind,"
|
|
306
|
-
" but it should be set whenever possible.",
|
|
304
|
+
description="The .kind of the entity.",
|
|
307
305
|
)
|
|
308
306
|
|
|
309
307
|
|
|
@@ -20,6 +20,7 @@ from typing import Any, Literal, Optional, Union
|
|
|
20
20
|
|
|
21
21
|
import pydantic
|
|
22
22
|
|
|
23
|
+
from ... import upcast
|
|
23
24
|
from . import commands
|
|
24
25
|
from .base import DyffBaseModel, JsonMergePatchSemantics, Null
|
|
25
26
|
from .platform import (
|
|
@@ -29,6 +30,7 @@ from .platform import (
|
|
|
29
30
|
DatasetBase,
|
|
30
31
|
DataView,
|
|
31
32
|
DocumentationBase,
|
|
33
|
+
Evaluation,
|
|
32
34
|
EvaluationBase,
|
|
33
35
|
FamilyBase,
|
|
34
36
|
FamilyMemberBase,
|
|
@@ -197,6 +199,27 @@ class EvaluationCreateRequest(DyffEntityCreateRequest, EvaluationBase):
|
|
|
197
199
|
)
|
|
198
200
|
return values
|
|
199
201
|
|
|
202
|
+
@staticmethod
|
|
203
|
+
def repeat_of(evaluation: Evaluation) -> EvaluationCreateRequest:
|
|
204
|
+
"""Return a request that will run an existing Evaluation again with the same
|
|
205
|
+
configuration."""
|
|
206
|
+
base = upcast(EvaluationBase, evaluation)
|
|
207
|
+
if evaluation.inferenceSessionReference:
|
|
208
|
+
return EvaluationCreateRequest(
|
|
209
|
+
account=evaluation.account,
|
|
210
|
+
inferenceSessionReference=evaluation.inferenceSessionReference,
|
|
211
|
+
**base.dict(),
|
|
212
|
+
)
|
|
213
|
+
else:
|
|
214
|
+
return EvaluationCreateRequest(
|
|
215
|
+
account=evaluation.account,
|
|
216
|
+
inferenceSession=EvaluationInferenceSessionRequest(
|
|
217
|
+
inferenceService=evaluation.inferenceSession.inferenceService.id,
|
|
218
|
+
**upcast(InferenceSessionBase, evaluation.inferenceSession).dict(),
|
|
219
|
+
),
|
|
220
|
+
**base.dict(),
|
|
221
|
+
)
|
|
222
|
+
|
|
200
223
|
|
|
201
224
|
class FamilyCreateRequest(DyffEntityCreateRequest, FamilyBase):
|
|
202
225
|
pass
|
|
@@ -403,6 +426,7 @@ class ScoreQueryRequest(DyffRequestDefaultValidators):
|
|
|
403
426
|
|
|
404
427
|
id: Optional[str] = pydantic.Field(default=None)
|
|
405
428
|
name: Optional[str] = pydantic.Field(default=None)
|
|
429
|
+
analysis: Optional[str] = pydantic.Field(default=None)
|
|
406
430
|
method: Optional[str] = pydantic.Field(default=None)
|
|
407
431
|
methodName: Optional[str] = pydantic.Field(default=None)
|
|
408
432
|
dataset: Optional[str] = pydantic.Field(default=None)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: dyff-schema
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.28.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
|
|
@@ -27,6 +27,7 @@ Requires-Dist: jsonpath-ng
|
|
|
27
27
|
Requires-Dist: numpy<2
|
|
28
28
|
Requires-Dist: pyarrow
|
|
29
29
|
Requires-Dist: pydantic<2
|
|
30
|
+
Dynamic: license-file
|
|
30
31
|
|
|
31
32
|
# dyff-schema
|
|
32
33
|
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
# SPDX-FileCopyrightText: 2024 UL Research Institutes
|
|
2
|
-
# SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
|
|
4
|
-
import importlib
|
|
5
|
-
from typing import Iterable, Type
|
|
6
|
-
|
|
7
|
-
import pydantic
|
|
8
|
-
|
|
9
|
-
from .base import DyffSchemaBaseModel
|
|
10
|
-
from .version import SomeSchemaVersion
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
def _symbol(fully_qualified_name):
|
|
14
|
-
tokens = fully_qualified_name.split(".")
|
|
15
|
-
module_name = ".".join(tokens[:-1])
|
|
16
|
-
member = tokens[-1]
|
|
17
|
-
module = importlib.import_module(module_name)
|
|
18
|
-
return getattr(module, member)
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
def product_schema(
|
|
22
|
-
schemas: Iterable[Type[DyffSchemaBaseModel]],
|
|
23
|
-
) -> Type[DyffSchemaBaseModel]:
|
|
24
|
-
return pydantic.create_model("Product", __base__=tuple(schemas))
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
# TODO: Should have a way of registering schema names rather than allowing
|
|
28
|
-
# arbitrary imports.
|
|
29
|
-
def named_data_schema(
|
|
30
|
-
name: str, schema_version: SomeSchemaVersion
|
|
31
|
-
) -> Type[DyffSchemaBaseModel]:
|
|
32
|
-
version, revision = schema_version.split(".")
|
|
33
|
-
return _symbol(f"dyff.schema.v{version}.r{revision}.dataset.{name}")
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
__all__ = [
|
|
37
|
-
"named_data_schema",
|
|
38
|
-
"product_schema",
|
|
39
|
-
]
|
|
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
|