dyff-schema 0.36.10__py3-none-any.whl → 0.37.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/_version.py CHANGED
@@ -1,2 +1,2 @@
1
- __version__ = version = "0.36.10"
2
- __version_tuple__ = version_tuple = (0, 36, 10)
1
+ __version__ = version = "0.37.1"
2
+ __version_tuple__ = version_tuple = (0, 37, 1)
@@ -19,13 +19,24 @@ We use the following naming convention:
19
19
 
20
20
  # fmt: on
21
21
  # mypy: disable-error-code="import-untyped"
22
+ from __future__ import annotations
23
+
22
24
  import abc
23
25
  import enum
24
26
  import urllib.parse
25
27
  from datetime import datetime, timedelta, timezone
26
28
  from enum import Enum
27
29
  from pathlib import Path
28
- from typing import Any, Literal, NamedTuple, Optional, Type, TypeVar, Union
30
+ from typing import (
31
+ TYPE_CHECKING,
32
+ Any,
33
+ Literal,
34
+ NamedTuple,
35
+ Optional,
36
+ Type,
37
+ TypeVar,
38
+ Union,
39
+ )
29
40
 
30
41
  import i18naddress
31
42
  import pyarrow
@@ -40,6 +51,12 @@ from .base import DyffSchemaBaseModel
40
51
  from .dataset import arrow, make_item_type, make_response_type
41
52
  from .version import SCHEMA_VERSION, SchemaVersion
42
53
 
54
+ if TYPE_CHECKING:
55
+ from .requests import (
56
+ AnalysisCreateRequest,
57
+ EvaluationCreateRequest,
58
+ )
59
+
43
60
  SYSTEM_ATTRIBUTES = frozenset(["creationTime", "status", "reason"])
44
61
 
45
62
 
@@ -219,6 +236,8 @@ class Entities(str, enum.Enum):
219
236
  Method = "Method"
220
237
  Model = "Model"
221
238
  Module = "Module"
239
+ Pipeline = "Pipeline"
240
+ PipelineRun = "PipelineRun"
222
241
  Report = "Report"
223
242
  Revision = "Revision"
224
243
  SafetyCase = "SafetyCase"
@@ -258,6 +277,8 @@ class Resources(str, enum.Enum):
258
277
  Method = "methods"
259
278
  Model = "models"
260
279
  Module = "modules"
280
+ Pipeline = "pipelines"
281
+ PipelineRun = "pipelineruns"
261
282
  Report = "reports"
262
283
  Revision = "revisions"
263
284
  SafetyCase = "safetycases"
@@ -309,6 +330,8 @@ EntityKindLiteral = Literal[
309
330
  "Module",
310
331
  # FIXME: (schema v1) Rename to Artifact
311
332
  "OCIArtifact",
333
+ "Pipeline",
334
+ "PipelineRun",
312
335
  "Report",
313
336
  "Revision",
314
337
  "SafetyCase",
@@ -539,6 +562,8 @@ class DyffEntity(Status, Labeled, SchemaVersion, DyffModelWithID):
539
562
  "Module",
540
563
  # FIXME: (schema v1) Rename to Artifact
541
564
  "OCIArtifact",
565
+ "Pipeline",
566
+ "PipelineRun",
542
567
  "Report",
543
568
  "Revision",
544
569
  "SafetyCase",
@@ -2706,6 +2731,98 @@ class ChallengeSubmission(DyffEntity):
2706
2731
  return None
2707
2732
 
2708
2733
 
2734
+ # ---------------------------------------------------------------------------
2735
+ # Pipelines
2736
+
2737
+ PipelineNodeRequest: TypeAlias = Union[
2738
+ "AnalysisCreateRequest",
2739
+ "EvaluationCreateRequest",
2740
+ ]
2741
+
2742
+
2743
+ class PipelineNode(DyffSchemaBaseModel):
2744
+ name: str = pydantic.Field(
2745
+ description="The name of the node. Must be unique in the context of the pipeline."
2746
+ )
2747
+
2748
+ request: PipelineNodeRequest = pydantic.Field( # type: ignore[valid-type]
2749
+ discriminator="kind",
2750
+ description="The request template that will be executed when this node"
2751
+ ' executes. You can use the syntax ``"$(node_name)"`` in request fields'
2752
+ " that reference another entity to indicate that the request depends"
2753
+ " on another node in the pipeline. The placeholder will be substituted"
2754
+ " with the ID of the created entity once it is known. Dyff infers the"
2755
+ " dependency graph structure from these placeholders.",
2756
+ )
2757
+
2758
+
2759
+ class PipelineParameter(DyffSchemaBaseModel):
2760
+ """Declares a parameter that can be passed to the pipeline to customize its
2761
+ behavior."""
2762
+
2763
+ keyword: str = pydantic.Field(description="The keyword of the argument.")
2764
+ destination: str = pydantic.Field(
2765
+ description="The field in a pipeline node to substitute with the"
2766
+ " parameter value. Should be a string like 'node_name.field1.field2'."
2767
+ )
2768
+ description: Optional[str] = pydantic.Field(
2769
+ default=None, description="A description of the argument."
2770
+ )
2771
+
2772
+
2773
+ class PipelineBase(DyffSchemaBaseModel):
2774
+ name: str = pydantic.Field(description="The name of the Pipeline.")
2775
+ nodes: dict[str, PipelineNode] = pydantic.Field(
2776
+ description="The nodes in the pipeline graph.",
2777
+ min_length=1,
2778
+ )
2779
+
2780
+ @pydantic.field_validator("nodes", mode="after")
2781
+ def validate_node_names_match(cls, nodes: dict[str, PipelineNode]):
2782
+ for k, v in nodes.items():
2783
+ if k != v.name:
2784
+ raise ValueError(f"nodes[{k}]: dict key must match value.name")
2785
+
2786
+
2787
+ class Pipeline(DyffEntity, PipelineBase):
2788
+ """A set of Dyff workflows that can be executed as a group.
2789
+
2790
+ The pipeline
2791
+ is a directed acyclic graph representing data dependencies between
2792
+ workflows. For example, a simple pipeline might run an Evaluation and
2793
+ then create a SafetyCase from the evaluation output. This pipeline would
2794
+ have a graph structure like ``evaluation -> safetycase``.
2795
+ """
2796
+
2797
+ kind: Literal["Pipeline"] = Entities.Pipeline.value
2798
+
2799
+ def dependencies(self) -> list[str]:
2800
+ return []
2801
+
2802
+ def resource_allocation(self) -> Optional[ResourceAllocation]:
2803
+ return None
2804
+
2805
+
2806
+ class PipelineRunBase(DyffSchemaBaseModel):
2807
+ """A pipeline run is an execution of a pipeline."""
2808
+
2809
+ pipeline: str = pydantic.Field(description="The ID of the pipeline that was run.")
2810
+ arguments: dict[str, pydantic.JsonValue] = pydantic.Field(
2811
+ default_factory=dict,
2812
+ description="The arguments to pass to the pipeline.",
2813
+ )
2814
+
2815
+
2816
+ class PipelineRun(DyffEntity, PipelineRunBase):
2817
+ kind: Literal["PipelineRun"] = Entities.PipelineRun.value
2818
+
2819
+ def dependencies(self) -> list[str]:
2820
+ return [self.pipeline]
2821
+
2822
+ def resource_allocation(self) -> Optional[ResourceAllocation]:
2823
+ return None
2824
+
2825
+
2709
2826
  # ---------------------------------------------------------------------------
2710
2827
  # Status enumerations
2711
2828
 
@@ -2963,6 +3080,8 @@ _ENTITY_CLASS = {
2963
3080
  Entities.Method: Method,
2964
3081
  Entities.Model: Model,
2965
3082
  Entities.Module: Module,
3083
+ Entities.Pipeline: Pipeline,
3084
+ Entities.PipelineRun: PipelineRun,
2966
3085
  Entities.Report: Report,
2967
3086
  Entities.SafetyCase: SafetyCase,
2968
3087
  Entities.Team: Team,
@@ -2992,6 +3111,8 @@ _DyffEntityTypeRevisable = Union[
2992
3111
  Model,
2993
3112
  Module,
2994
3113
  OCIArtifact,
3114
+ Pipeline,
3115
+ PipelineRun,
2995
3116
  Report,
2996
3117
  SafetyCase,
2997
3118
  Team,
@@ -3210,6 +3331,12 @@ __all__ = [
3210
3331
  "Module",
3211
3332
  "ModuleBase",
3212
3333
  "OCIArtifact",
3334
+ "Pipeline",
3335
+ "PipelineBase",
3336
+ "PipelineNode",
3337
+ "PipelineNodeRequest",
3338
+ "PipelineRun",
3339
+ "PipelineRunBase",
3213
3340
  "QueryableDyffEntity",
3214
3341
  "Report",
3215
3342
  "ReportBase",
@@ -42,6 +42,7 @@ from .platform import (
42
42
  MethodBase,
43
43
  ModelSpec,
44
44
  ModuleBase,
45
+ PipelineBase,
45
46
  ReportBase,
46
47
  TagNameType,
47
48
  TeamBase,
@@ -282,6 +283,19 @@ class ModuleCreateRequest(DyffEntityCreateRequest, ModuleBase):
282
283
  pass
283
284
 
284
285
 
286
+ class PipelineCreateRequest(DyffEntityCreateRequest, PipelineBase):
287
+ pass
288
+
289
+
290
+ class PipelineRunRequest(DyffRequestBase):
291
+ """A request to run a pipeline."""
292
+
293
+ arguments: dict[str, pydantic.JsonValue] = pydantic.Field(
294
+ default_factory=dict,
295
+ description="Arguments to pass to the pipeline run.",
296
+ )
297
+
298
+
285
299
  class ReportCreateRequest(DyffEntityCreateRequest, ReportBase):
286
300
  """A Report transforms raw model outputs into some useful statistics.
287
301
 
@@ -541,6 +555,8 @@ __all__ = [
541
555
  "ModelQueryRequest",
542
556
  "ModuleCreateRequest",
543
557
  "ModuleQueryRequest",
558
+ "PipelineCreateRequest",
559
+ "PipelineRunRequest",
544
560
  "QueryRequest",
545
561
  "ReportCreateRequest",
546
562
  "ReportQueryRequest",
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dyff-schema
3
- Version: 0.36.10
3
+ Version: 0.37.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
@@ -1,5 +1,5 @@
1
1
  dyff/schema/__init__.py,sha256=w7OWDFuyGKd6xt_yllNtKzHahPgywrfU4Ue02psYaMA,2244
2
- dyff/schema/_version.py,sha256=D_gwlkLPf6qLvdN0hk8VV2OKAzSW4v5rqK3XtT_BWiU,82
2
+ dyff/schema/_version.py,sha256=6lGXMg4NDOdrq_CTwNbiYVyEaS7boKhXY0k9w1JNUNA,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
@@ -29,8 +29,8 @@ dyff/schema/v0/r1/adapters.py,sha256=hpwCSW8lkMkUKCLe0zaMUDu-VS_caSxJvPsECEi_XRA
29
29
  dyff/schema/v0/r1/base.py,sha256=1VJXVLKldOq3aH2HdVgxXXk4DJTZEIiaTa4GzMKzziU,20228
30
30
  dyff/schema/v0/r1/commands.py,sha256=jqbEvDRLpcVGWXqlbniuSKg3UIjlrpKt6_0hiwUpPfQ,20153
31
31
  dyff/schema/v0/r1/oci.py,sha256=YjHDVBJ2IIxqijll70OK6pM-qT6pq8tvU7D3YB9vGM0,6700
32
- dyff/schema/v0/r1/platform.py,sha256=_ZpRyTAUtBDoG2neD6o5nwFT0AUvKAc3WH5L-V9vOFI,104027
33
- dyff/schema/v0/r1/requests.py,sha256=H_psyQUyThRI8XGG1PAH4yTngRCdIpOAbtxtirW0tw4,19085
32
+ dyff/schema/v0/r1/platform.py,sha256=02q4QK_Peu3W-JwCZhn-a_UcMWUOBUydu8H229-HXg8,107913
33
+ dyff/schema/v0/r1/requests.py,sha256=-KaM1VjwaqZEI0zgexeyetQccrRX78x4WxHNIxQqJog,19483
34
34
  dyff/schema/v0/r1/responses.py,sha256=nxy7FPtfw2B_bljz5UGGuSE79HTkDQxKH56AJVmd4Qo,1287
35
35
  dyff/schema/v0/r1/test.py,sha256=X6dUyVd5svcPCI-PBMOAqEfK9jv3bRDvkQTJzwS96c0,10720
36
36
  dyff/schema/v0/r1/version.py,sha256=NONebgcv5Thsw_ymud6PacZdGjV6ndBrmLnap-obcpo,428
@@ -43,9 +43,9 @@ dyff/schema/v0/r1/dataset/text.py,sha256=MYG5seGODDryRSCy-g0Unh5dD0HCytmZ3FeElC-
43
43
  dyff/schema/v0/r1/dataset/vision.py,sha256=tJFF4dkhHX0UXTj1sPW-G22xTSI40gbYO465FuvmvAU,443
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.36.10.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
47
- dyff_schema-0.36.10.dist-info/licenses/NOTICE,sha256=YONACu0s_Ui6jNi-wtEsVQbTU1JIkh8wvLH6d1-Ni_w,43
48
- dyff_schema-0.36.10.dist-info/METADATA,sha256=Kpp8nCb9bQuU1rbKWvuHosX-MOyfMfucMyb45-jkGgc,3735
49
- dyff_schema-0.36.10.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
50
- dyff_schema-0.36.10.dist-info/top_level.txt,sha256=9e3VVdeX73t_sUJOPQPCcGtYO1JhoErhHIi3WoWGcFI,5
51
- dyff_schema-0.36.10.dist-info/RECORD,,
46
+ dyff_schema-0.37.1.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
47
+ dyff_schema-0.37.1.dist-info/licenses/NOTICE,sha256=YONACu0s_Ui6jNi-wtEsVQbTU1JIkh8wvLH6d1-Ni_w,43
48
+ dyff_schema-0.37.1.dist-info/METADATA,sha256=a1KHWa5OO7141im2ezzjYe0UGtOt_mA4pEq-gaQQmi4,3734
49
+ dyff_schema-0.37.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
50
+ dyff_schema-0.37.1.dist-info/top_level.txt,sha256=9e3VVdeX73t_sUJOPQPCcGtYO1JhoErhHIi3WoWGcFI,5
51
+ dyff_schema-0.37.1.dist-info/RECORD,,