prefactor-core 0.2.6__tar.gz → 0.2.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.
- {prefactor_core-0.2.6 → prefactor_core-0.2.7}/.gitignore +0 -1
- {prefactor_core-0.2.6 → prefactor_core-0.2.7}/PKG-INFO +2 -2
- {prefactor_core-0.2.6 → prefactor_core-0.2.7}/pyproject.toml +1 -1
- {prefactor_core-0.2.6 → prefactor_core-0.2.7}/src/prefactor_core/_version.py +1 -1
- {prefactor_core-0.2.6 → prefactor_core-0.2.7}/src/prefactor_core/client.py +8 -0
- {prefactor_core-0.2.6 → prefactor_core-0.2.7}/tests/test_agent_instance_finish_status.py +3 -0
- {prefactor_core-0.2.6 → prefactor_core-0.2.7}/tests/test_agent_instance_register.py +3 -0
- {prefactor_core-0.2.6 → prefactor_core-0.2.7}/tests/test_failure_handling.py +31 -0
- {prefactor_core-0.2.6 → prefactor_core-0.2.7}/tests/test_sdk_header.py +8 -0
- {prefactor_core-0.2.6 → prefactor_core-0.2.7}/README.md +0 -0
- {prefactor_core-0.2.6 → prefactor_core-0.2.7}/examples/agent_e2e.py +0 -0
- {prefactor_core-0.2.6 → prefactor_core-0.2.7}/src/prefactor_core/__init__.py +0 -0
- {prefactor_core-0.2.6 → prefactor_core-0.2.7}/src/prefactor_core/config.py +0 -0
- {prefactor_core-0.2.6 → prefactor_core-0.2.7}/src/prefactor_core/context_stack.py +0 -0
- {prefactor_core-0.2.6 → prefactor_core-0.2.7}/src/prefactor_core/exceptions.py +0 -0
- {prefactor_core-0.2.6 → prefactor_core-0.2.7}/src/prefactor_core/managers/__init__.py +0 -0
- {prefactor_core-0.2.6 → prefactor_core-0.2.7}/src/prefactor_core/managers/agent_instance.py +0 -0
- {prefactor_core-0.2.6 → prefactor_core-0.2.7}/src/prefactor_core/managers/span.py +0 -0
- {prefactor_core-0.2.6 → prefactor_core-0.2.7}/src/prefactor_core/models.py +0 -0
- {prefactor_core-0.2.6 → prefactor_core-0.2.7}/src/prefactor_core/monitoring/__init__.py +0 -0
- {prefactor_core-0.2.6 → prefactor_core-0.2.7}/src/prefactor_core/monitoring/termination_monitor.py +0 -0
- {prefactor_core-0.2.6 → prefactor_core-0.2.7}/src/prefactor_core/operations.py +0 -0
- {prefactor_core-0.2.6 → prefactor_core-0.2.7}/src/prefactor_core/queue/__init__.py +0 -0
- {prefactor_core-0.2.6 → prefactor_core-0.2.7}/src/prefactor_core/queue/base.py +0 -0
- {prefactor_core-0.2.6 → prefactor_core-0.2.7}/src/prefactor_core/queue/executor.py +0 -0
- {prefactor_core-0.2.6 → prefactor_core-0.2.7}/src/prefactor_core/queue/memory.py +0 -0
- {prefactor_core-0.2.6 → prefactor_core-0.2.7}/src/prefactor_core/schema_registry.py +0 -0
- {prefactor_core-0.2.6 → prefactor_core-0.2.7}/src/prefactor_core/span_context.py +0 -0
- {prefactor_core-0.2.6 → prefactor_core-0.2.7}/src/prefactor_core/utils.py +0 -0
- {prefactor_core-0.2.6 → prefactor_core-0.2.7}/tests/monitoring/__init__.py +0 -0
- {prefactor_core-0.2.6 → prefactor_core-0.2.7}/tests/monitoring/test_termination_monitor.py +0 -0
- {prefactor_core-0.2.6 → prefactor_core-0.2.7}/tests/test_client.py +0 -0
- {prefactor_core-0.2.6 → prefactor_core-0.2.7}/tests/test_imports.py +0 -0
- {prefactor_core-0.2.6 → prefactor_core-0.2.7}/tests/test_queue.py +0 -0
- {prefactor_core-0.2.6 → prefactor_core-0.2.7}/tests/test_span_context.py +0 -0
- {prefactor_core-0.2.6 → prefactor_core-0.2.7}/tests/test_span_manager.py +0 -0
- {prefactor_core-0.2.6 → prefactor_core-0.2.7}/tests/test_utils.py +0 -0
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: prefactor-core
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.7
|
|
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.1.
|
|
8
|
+
Requires-Dist: prefactor-http>=0.1.5
|
|
9
9
|
Requires-Dist: pydantic>=2.0.0
|
|
10
10
|
Description-Content-Type: text/markdown
|
|
11
11
|
|
|
@@ -142,6 +142,14 @@ class PrefactorCoreClient:
|
|
|
142
142
|
)
|
|
143
143
|
await self._http.__aenter__()
|
|
144
144
|
|
|
145
|
+
try:
|
|
146
|
+
await self._http.validate_token()
|
|
147
|
+
except BaseException as exc:
|
|
148
|
+
http = self._http
|
|
149
|
+
self._http = None
|
|
150
|
+
await http.__aexit__(type(exc), exc, exc.__traceback__)
|
|
151
|
+
raise
|
|
152
|
+
|
|
145
153
|
# Initialize executor
|
|
146
154
|
self._executor = TaskExecutor(
|
|
147
155
|
queue=self._queue,
|
|
@@ -56,6 +56,9 @@ class _StubHttpClient:
|
|
|
56
56
|
async def __aexit__(self, exc_type, exc, tb):
|
|
57
57
|
return None
|
|
58
58
|
|
|
59
|
+
async def validate_token(self):
|
|
60
|
+
return {"status": "success"}
|
|
61
|
+
|
|
59
62
|
|
|
60
63
|
@pytest.mark.asyncio
|
|
61
64
|
async def test_create_agent_instance_passes_environment_id_to_register():
|
|
@@ -68,17 +68,28 @@ class _StubHttpClient:
|
|
|
68
68
|
*_args,
|
|
69
69
|
agent_instances: _StubAgentInstances | None = None,
|
|
70
70
|
agent_spans: _StubAgentSpans | None = None,
|
|
71
|
+
validate_token_error: PrefactorAuthError | None = None,
|
|
71
72
|
**_kwargs,
|
|
72
73
|
) -> None:
|
|
73
74
|
self.agent_instances = agent_instances or _StubAgentInstances()
|
|
74
75
|
self.agent_spans = agent_spans or _StubAgentSpans()
|
|
76
|
+
self._validate_token_error = validate_token_error
|
|
77
|
+
self.enter_calls = 0
|
|
78
|
+
self.exit_calls = 0
|
|
75
79
|
|
|
76
80
|
async def __aenter__(self):
|
|
81
|
+
self.enter_calls += 1
|
|
77
82
|
return self
|
|
78
83
|
|
|
79
84
|
async def __aexit__(self, exc_type, exc, tb):
|
|
85
|
+
self.exit_calls += 1
|
|
80
86
|
return None
|
|
81
87
|
|
|
88
|
+
async def validate_token(self):
|
|
89
|
+
if self._validate_token_error is not None:
|
|
90
|
+
raise self._validate_token_error
|
|
91
|
+
return {"status": "success"}
|
|
92
|
+
|
|
82
93
|
|
|
83
94
|
def _make_client_config(max_retries: int = 0) -> PrefactorCoreConfig:
|
|
84
95
|
return PrefactorCoreConfig(
|
|
@@ -375,3 +386,23 @@ async def test_latched_failure_drops_already_queued_backlog():
|
|
|
375
386
|
await client.close()
|
|
376
387
|
|
|
377
388
|
assert exc_info.value.dropped_operations == 1
|
|
389
|
+
|
|
390
|
+
|
|
391
|
+
@pytest.mark.asyncio
|
|
392
|
+
async def test_initialize_raises_auth_error_when_token_validation_fails():
|
|
393
|
+
"""Invalid tokens should fail during initialize() before workers start."""
|
|
394
|
+
stub_http = _StubHttpClient(
|
|
395
|
+
validate_token_error=PrefactorAuthError("Token expired", "bad_authtoken", 401)
|
|
396
|
+
)
|
|
397
|
+
|
|
398
|
+
with patch("prefactor_core.client.PrefactorHttpClient", return_value=stub_http):
|
|
399
|
+
client = PrefactorCoreClient(_make_client_config())
|
|
400
|
+
with pytest.raises(PrefactorAuthError) as exc_info:
|
|
401
|
+
await client.initialize()
|
|
402
|
+
|
|
403
|
+
assert exc_info.value.code == "bad_authtoken"
|
|
404
|
+
assert stub_http.enter_calls == 1
|
|
405
|
+
assert stub_http.exit_calls == 1
|
|
406
|
+
assert client._http is None
|
|
407
|
+
assert client._executor is None
|
|
408
|
+
await client.close()
|
|
@@ -37,6 +37,10 @@ class TestPrefactorCoreSdkHeader:
|
|
|
37
37
|
"prefactor_http.client.PrefactorHttpClient.__aexit__",
|
|
38
38
|
AsyncMock(return_value=None),
|
|
39
39
|
),
|
|
40
|
+
patch(
|
|
41
|
+
"prefactor_http.client.PrefactorHttpClient.validate_token",
|
|
42
|
+
AsyncMock(return_value={"status": "success"}),
|
|
43
|
+
),
|
|
40
44
|
):
|
|
41
45
|
await client.initialize()
|
|
42
46
|
assert client._http is not None
|
|
@@ -59,6 +63,10 @@ class TestPrefactorCoreSdkHeader:
|
|
|
59
63
|
"prefactor_http.client.PrefactorHttpClient.__aexit__",
|
|
60
64
|
AsyncMock(return_value=None),
|
|
61
65
|
),
|
|
66
|
+
patch(
|
|
67
|
+
"prefactor_http.client.PrefactorHttpClient.validate_token",
|
|
68
|
+
AsyncMock(return_value={"status": "success"}),
|
|
69
|
+
),
|
|
62
70
|
):
|
|
63
71
|
await client.initialize()
|
|
64
72
|
assert client._http is not None
|
|
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.2.6 → prefactor_core-0.2.7}/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
|