prefactor-core 0.3.0__tar.gz → 0.4.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.
- {prefactor_core-0.3.0 → prefactor_core-0.4.0}/PKG-INFO +2 -2
- {prefactor_core-0.3.0 → prefactor_core-0.4.0}/pyproject.toml +1 -1
- {prefactor_core-0.3.0 → prefactor_core-0.4.0}/src/prefactor_core/_version.py +1 -1
- {prefactor_core-0.3.0 → prefactor_core-0.4.0}/src/prefactor_core/managers/agent_instance.py +45 -8
- {prefactor_core-0.3.0 → prefactor_core-0.4.0}/.gitignore +0 -0
- {prefactor_core-0.3.0 → prefactor_core-0.4.0}/README.md +0 -0
- {prefactor_core-0.3.0 → prefactor_core-0.4.0}/examples/agent_e2e.py +0 -0
- {prefactor_core-0.3.0 → prefactor_core-0.4.0}/src/prefactor_core/__init__.py +0 -0
- {prefactor_core-0.3.0 → prefactor_core-0.4.0}/src/prefactor_core/client.py +0 -0
- {prefactor_core-0.3.0 → prefactor_core-0.4.0}/src/prefactor_core/config.py +0 -0
- {prefactor_core-0.3.0 → prefactor_core-0.4.0}/src/prefactor_core/context_stack.py +0 -0
- {prefactor_core-0.3.0 → prefactor_core-0.4.0}/src/prefactor_core/exceptions.py +0 -0
- {prefactor_core-0.3.0 → prefactor_core-0.4.0}/src/prefactor_core/managers/__init__.py +0 -0
- {prefactor_core-0.3.0 → prefactor_core-0.4.0}/src/prefactor_core/managers/span.py +0 -0
- {prefactor_core-0.3.0 → prefactor_core-0.4.0}/src/prefactor_core/models.py +0 -0
- {prefactor_core-0.3.0 → prefactor_core-0.4.0}/src/prefactor_core/monitoring/__init__.py +0 -0
- {prefactor_core-0.3.0 → prefactor_core-0.4.0}/src/prefactor_core/monitoring/termination_monitor.py +0 -0
- {prefactor_core-0.3.0 → prefactor_core-0.4.0}/src/prefactor_core/operations.py +0 -0
- {prefactor_core-0.3.0 → prefactor_core-0.4.0}/src/prefactor_core/queue/__init__.py +0 -0
- {prefactor_core-0.3.0 → prefactor_core-0.4.0}/src/prefactor_core/queue/base.py +0 -0
- {prefactor_core-0.3.0 → prefactor_core-0.4.0}/src/prefactor_core/queue/executor.py +0 -0
- {prefactor_core-0.3.0 → prefactor_core-0.4.0}/src/prefactor_core/queue/memory.py +0 -0
- {prefactor_core-0.3.0 → prefactor_core-0.4.0}/src/prefactor_core/schema_registry.py +0 -0
- {prefactor_core-0.3.0 → prefactor_core-0.4.0}/src/prefactor_core/span_context.py +0 -0
- {prefactor_core-0.3.0 → prefactor_core-0.4.0}/src/prefactor_core/utils.py +0 -0
- {prefactor_core-0.3.0 → prefactor_core-0.4.0}/tests/monitoring/__init__.py +0 -0
- {prefactor_core-0.3.0 → prefactor_core-0.4.0}/tests/monitoring/test_termination_monitor.py +0 -0
- {prefactor_core-0.3.0 → prefactor_core-0.4.0}/tests/test_agent_instance_finish_status.py +0 -0
- {prefactor_core-0.3.0 → prefactor_core-0.4.0}/tests/test_agent_instance_register.py +0 -0
- {prefactor_core-0.3.0 → prefactor_core-0.4.0}/tests/test_client.py +0 -0
- {prefactor_core-0.3.0 → prefactor_core-0.4.0}/tests/test_failure_handling.py +0 -0
- {prefactor_core-0.3.0 → prefactor_core-0.4.0}/tests/test_imports.py +0 -0
- {prefactor_core-0.3.0 → prefactor_core-0.4.0}/tests/test_queue.py +0 -0
- {prefactor_core-0.3.0 → prefactor_core-0.4.0}/tests/test_sdk_header.py +0 -0
- {prefactor_core-0.3.0 → prefactor_core-0.4.0}/tests/test_span_context.py +0 -0
- {prefactor_core-0.3.0 → prefactor_core-0.4.0}/tests/test_span_manager.py +0 -0
- {prefactor_core-0.3.0 → prefactor_core-0.4.0}/tests/test_utils.py +0 -0
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: prefactor-core
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.4.0
|
|
4
4
|
Summary: Core Prefactor SDK with async queue-based operations
|
|
5
5
|
Author-email: Prefactor Pty Ltd <josh@prefactor.tech>
|
|
6
6
|
License: MIT
|
|
7
7
|
Requires-Python: <4.0.0,>=3.11.0
|
|
8
|
-
Requires-Dist: prefactor-http>=0.
|
|
8
|
+
Requires-Dist: prefactor-http>=0.3.0
|
|
9
9
|
Requires-Dist: pydantic>=2.0.0
|
|
10
10
|
Description-Content-Type: text/markdown
|
|
11
11
|
|
|
@@ -97,29 +97,45 @@ class AgentInstanceManager:
|
|
|
97
97
|
)
|
|
98
98
|
return result.id
|
|
99
99
|
|
|
100
|
-
async def start(
|
|
100
|
+
async def start(
|
|
101
|
+
self,
|
|
102
|
+
instance_id: str,
|
|
103
|
+
timestamp: datetime | None = None,
|
|
104
|
+
) -> None:
|
|
101
105
|
"""Mark an instance as started.
|
|
102
106
|
|
|
103
107
|
Queues a start operation for the instance.
|
|
104
108
|
|
|
105
109
|
Args:
|
|
106
110
|
instance_id: The ID of the instance to start.
|
|
111
|
+
timestamp: Optional ISO 8601 start time (defaults to current time).
|
|
107
112
|
"""
|
|
108
|
-
await self.start_with_idempotency_key(
|
|
113
|
+
await self.start_with_idempotency_key(
|
|
114
|
+
instance_id,
|
|
115
|
+
generate_idempotency_key(),
|
|
116
|
+
timestamp=timestamp,
|
|
117
|
+
)
|
|
109
118
|
|
|
110
119
|
async def start_with_idempotency_key(
|
|
111
120
|
self,
|
|
112
121
|
instance_id: str,
|
|
113
122
|
idempotency_key: str,
|
|
123
|
+
timestamp: datetime | None = None,
|
|
114
124
|
) -> None:
|
|
115
|
-
"""Queue a start operation using a stable idempotency key.
|
|
125
|
+
"""Queue a start operation using a stable idempotency key.
|
|
126
|
+
|
|
127
|
+
Args:
|
|
128
|
+
instance_id: The ID of the instance to start.
|
|
129
|
+
idempotency_key: Stable key for idempotent retries.
|
|
130
|
+
timestamp: Optional ISO 8601 start time (defaults to current time).
|
|
131
|
+
"""
|
|
116
132
|
operation = Operation(
|
|
117
133
|
type=OperationType.START_AGENT_INSTANCE,
|
|
118
134
|
payload={
|
|
119
135
|
"instance_id": instance_id,
|
|
120
136
|
"idempotency_key": idempotency_key,
|
|
121
137
|
},
|
|
122
|
-
timestamp=datetime.now(timezone.utc),
|
|
138
|
+
timestamp=timestamp or datetime.now(timezone.utc),
|
|
123
139
|
)
|
|
124
140
|
|
|
125
141
|
await self._enqueue(operation)
|
|
@@ -128,6 +144,7 @@ class AgentInstanceManager:
|
|
|
128
144
|
self,
|
|
129
145
|
instance_id: str,
|
|
130
146
|
status: "FinishStatus" = "complete",
|
|
147
|
+
timestamp: datetime | None = None,
|
|
131
148
|
) -> None:
|
|
132
149
|
"""Mark an instance as finished.
|
|
133
150
|
|
|
@@ -136,11 +153,13 @@ class AgentInstanceManager:
|
|
|
136
153
|
Args:
|
|
137
154
|
instance_id: The ID of the instance to finish.
|
|
138
155
|
status: Terminal status for the instance. Defaults to ``"complete"``.
|
|
156
|
+
timestamp: Optional ISO 8601 finish time (defaults to current time).
|
|
139
157
|
"""
|
|
140
158
|
await self.finish_with_idempotency_key(
|
|
141
159
|
instance_id,
|
|
142
160
|
generate_idempotency_key(),
|
|
143
161
|
status=status,
|
|
162
|
+
timestamp=timestamp,
|
|
144
163
|
)
|
|
145
164
|
|
|
146
165
|
async def finish_with_idempotency_key(
|
|
@@ -148,8 +167,16 @@ class AgentInstanceManager:
|
|
|
148
167
|
instance_id: str,
|
|
149
168
|
idempotency_key: str,
|
|
150
169
|
status: "FinishStatus" = "complete",
|
|
170
|
+
timestamp: datetime | None = None,
|
|
151
171
|
) -> None:
|
|
152
|
-
"""Queue a finish operation using a stable idempotency key.
|
|
172
|
+
"""Queue a finish operation using a stable idempotency key.
|
|
173
|
+
|
|
174
|
+
Args:
|
|
175
|
+
instance_id: The ID of the instance to finish.
|
|
176
|
+
idempotency_key: Stable key for idempotent retries.
|
|
177
|
+
status: Terminal status for the instance. Defaults to ``"complete"``.
|
|
178
|
+
timestamp: Optional ISO 8601 finish time (defaults to current time).
|
|
179
|
+
"""
|
|
153
180
|
operation = Operation(
|
|
154
181
|
type=OperationType.FINISH_AGENT_INSTANCE,
|
|
155
182
|
payload={
|
|
@@ -157,7 +184,7 @@ class AgentInstanceManager:
|
|
|
157
184
|
"idempotency_key": idempotency_key,
|
|
158
185
|
"status": status,
|
|
159
186
|
},
|
|
160
|
-
timestamp=datetime.now(timezone.utc),
|
|
187
|
+
timestamp=timestamp or datetime.now(timezone.utc),
|
|
161
188
|
)
|
|
162
189
|
|
|
163
190
|
await self._enqueue(operation)
|
|
@@ -231,19 +258,27 @@ class AgentInstanceHandle:
|
|
|
231
258
|
"""
|
|
232
259
|
return self._instance_id
|
|
233
260
|
|
|
234
|
-
async def start(self) -> None:
|
|
261
|
+
async def start(self, timestamp: datetime | None = None) -> None:
|
|
235
262
|
"""Mark the instance as started.
|
|
236
263
|
|
|
237
264
|
This queues a start operation for the instance.
|
|
265
|
+
|
|
266
|
+
Args:
|
|
267
|
+
timestamp: Optional ISO 8601 start time (defaults to current time).
|
|
238
268
|
"""
|
|
239
269
|
manager = self._client.instance_manager
|
|
240
270
|
assert manager is not None
|
|
241
271
|
await manager.start_with_idempotency_key(
|
|
242
272
|
self._instance_id,
|
|
243
273
|
self._start_idempotency_key,
|
|
274
|
+
timestamp=timestamp,
|
|
244
275
|
)
|
|
245
276
|
|
|
246
|
-
async def finish(
|
|
277
|
+
async def finish(
|
|
278
|
+
self,
|
|
279
|
+
status: "FinishStatus" = "complete",
|
|
280
|
+
timestamp: datetime | None = None,
|
|
281
|
+
) -> None:
|
|
247
282
|
"""Mark the instance as finished.
|
|
248
283
|
|
|
249
284
|
Resets the termination monitor (fence + new event) before enqueueing
|
|
@@ -253,6 +288,7 @@ class AgentInstanceHandle:
|
|
|
253
288
|
Args:
|
|
254
289
|
status: Terminal status for the instance — one of ``"complete"``,
|
|
255
290
|
``"failed"``, or ``"cancelled"``. Defaults to ``"complete"``.
|
|
291
|
+
timestamp: Optional ISO 8601 finish time (defaults to current time).
|
|
256
292
|
"""
|
|
257
293
|
monitor = getattr(self._client, "_termination_monitor", None)
|
|
258
294
|
if monitor is not None:
|
|
@@ -264,6 +300,7 @@ class AgentInstanceHandle:
|
|
|
264
300
|
self._instance_id,
|
|
265
301
|
self._finish_idempotency_key,
|
|
266
302
|
status=status,
|
|
303
|
+
timestamp=timestamp,
|
|
267
304
|
)
|
|
268
305
|
|
|
269
306
|
async def update(
|
|
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
|
{prefactor_core-0.3.0 → prefactor_core-0.4.0}/src/prefactor_core/monitoring/termination_monitor.py
RENAMED
|
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
|