dirigent-plugin 0.16.6__tar.gz → 0.16.7__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.
@@ -1,12 +1,12 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dirigent-plugin
3
- Version: 0.16.6
3
+ Version: 0.16.7
4
4
  Summary: The dirigent plugin contract: block specs, protocols, and markers.
5
5
  License-Expression: LicenseRef-Proprietary
6
6
  License-File: LICENSE
7
7
  Classifier: Programming Language :: Python :: 3
8
8
  Classifier: Programming Language :: Python :: 3.13
9
- Requires-Dist: dirigent-common==0.16.6
9
+ Requires-Dist: dirigent-common==0.16.7
10
10
  Requires-Dist: httpx2>=2.12.0
11
11
  Requires-Dist: pluginkit>=0.5.0
12
12
  Requires-Dist: pydantic>=2.13.5
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "dirigent-plugin"
3
- version = "0.16.6"
3
+ version = "0.16.7"
4
4
  description = "The dirigent plugin contract: block specs, protocols, and markers."
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.13"
@@ -11,7 +11,7 @@ classifiers = [
11
11
  "Programming Language :: Python :: 3.13",
12
12
  ]
13
13
  dependencies = [
14
- "dirigent-common==0.16.6",
14
+ "dirigent-common==0.16.7",
15
15
  "httpx2>=2.12.0",
16
16
  "pluginkit>=0.5.0",
17
17
  "pydantic>=2.13.5",
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "dirigent-plugin"
3
- version = "0.16.6"
3
+ version = "0.16.7"
4
4
  description = "The dirigent plugin contract: block specs, protocols, and markers."
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.13"
@@ -11,7 +11,7 @@ classifiers = [
11
11
  "Programming Language :: Python :: 3.13",
12
12
  ]
13
13
  dependencies = [
14
- "dirigent-common==0.16.6",
14
+ "dirigent-common==0.16.7",
15
15
  "httpx2>=2.12.0",
16
16
  "pluginkit>=0.5.0",
17
17
  "pydantic>=2.13.5",
@@ -22,12 +22,14 @@ from dirigent_plugin.blocks import (
22
22
  OperatorSpec,
23
23
  ProbeResult,
24
24
  ProbeStatus,
25
+ Reference,
25
26
  RemoteHandle,
26
27
  RunId,
27
28
  RunRefused,
28
29
  Runs,
29
30
  RunSnapshot,
30
31
  RunState,
32
+ SchemaRef,
31
33
  Sensor,
32
34
  SensorSpec,
33
35
  ShellString,
@@ -92,6 +94,7 @@ __all__ = [
92
94
  "ProbeResult",
93
95
  "ProbeStatus",
94
96
  "ProgramConfig",
97
+ "Reference",
95
98
  "RemoteHandle",
96
99
  "RunId",
97
100
  "RunRefused",
@@ -99,6 +102,7 @@ __all__ = [
99
102
  "RunState",
100
103
  "Runs",
101
104
  "SURFACE_ID_PATTERN",
105
+ "SchemaRef",
102
106
  "Sensor",
103
107
  "SensorSpec",
104
108
  "SHELL_VARIABLES_FIELD",
@@ -6,7 +6,7 @@ from contextlib import AbstractAsyncContextManager
6
6
  from datetime import datetime, timedelta
7
7
  from enum import StrEnum
8
8
  from pathlib import Path
9
- from typing import Annotated, Any, ClassVar, Final, Protocol, cast
9
+ from typing import Annotated, Any, ClassVar, Final, Literal, Protocol, cast
10
10
  from uuid import UUID
11
11
 
12
12
  import httpx2
@@ -19,9 +19,6 @@ from dirigent_common import API_VERSION, SHELL_MEDIA_TYPE, BlockModel, HealthRep
19
19
 
20
20
  type RunId = UUID
21
21
 
22
- #: A connection is referenced by name, never by id, so documents stay portable.
23
- type ConnectionRef = str
24
-
25
22
  #: A JSON Schema format checker: a predicate that returns True when a value satisfies the
26
23
  #: format, False when it does not, and may instead raise to signal the value is invalid --
27
24
  #: exactly what ``jsonschema.FormatChecker.checks`` registers.
@@ -132,6 +129,43 @@ class ShellString:
132
129
  return published
133
130
 
134
131
 
132
+ class Reference:
133
+ """Marks a config field whose value is the code of another thing this instance holds.
134
+
135
+ It publishes ``x-dirigent-ref`` carrying what the code names, and a form generated from the
136
+ schema draws that thing under the field. It is a bare class rather than a model: annotation
137
+ metadata pydantic recognises as a model would be read as the field's schema, and a marker
138
+ must stay invisible to validation.
139
+ """
140
+
141
+ __slots__ = ("kind",)
142
+
143
+ def __init__(self, kind: Literal["connection", "schema"]) -> None:
144
+ """Record what a value of the marked field names."""
145
+ self.kind = kind
146
+
147
+ def __repr__(self) -> str:
148
+ """Render the marker the way it is written."""
149
+ return f"Reference({self.kind!r})"
150
+
151
+ def __get_pydantic_json_schema__(
152
+ self,
153
+ schema: CoreSchema,
154
+ handler: GetJsonSchemaHandler,
155
+ ) -> JsonSchemaValue:
156
+ """Publish what the marked field's code names, leaving what it validates untouched."""
157
+ published = handler(schema)
158
+ published["x-dirigent-ref"] = self.kind
159
+ return published
160
+
161
+
162
+ #: A connection is referenced by code, never by id, so documents stay portable.
163
+ type ConnectionRef = Annotated[str, Reference("connection")]
164
+
165
+ #: A schema is referenced by code: one the instance holds, or one the document carries.
166
+ type SchemaRef = Annotated[str, Reference("schema")]
167
+
168
+
135
169
  #: What the engine names the variables it substitutes a shell string's references out into.
136
170
  SHELL_VARIABLE_PREFIX: Final = "DIRIGENT_V"
137
171