Skip to content

Commit 292b3ed

Browse files
committed
refactor(etl-uvicorn): simplify settings resolver integration
1 parent 1a7d177 commit 292b3ed

2 files changed

Lines changed: 6 additions & 17 deletions

File tree

test/api/test_invocation_envelope.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -424,9 +424,7 @@ def resolve(payload):
424424
return resolved
425425

426426
monkeypatch.setattr(
427-
invocation_settings_transport._invocation_settings_contract,
428-
"resolve_invocation_settings",
429-
resolve,
427+
invocation_settings_transport, "resolve_invocation_settings", resolve
430428
)
431429

432430
recorder, response = _post_invoke({"invocation_settings": opaque_payload})
@@ -442,7 +440,7 @@ def resolve(_payload):
442440
resolver_threads.append(get_ident())
443441
return {"model": "m"}
444442

445-
monkeypatch.setattr(invocation_settings_transport, "_resolve_invocation_settings", resolve)
443+
monkeypatch.setattr(invocation_settings_transport, "resolve_invocation_settings", resolve)
446444

447445
recorder, response = _post_invoke({"invocation_settings": {"opaque": "payload"}})
448446

@@ -461,7 +459,7 @@ def test_resolution_failure_uses_blame_for_http_status(
461459
def fail(_payload):
462460
raise _ResolutionFailure(blame)
463461

464-
monkeypatch.setattr(invocation_settings_transport, "_resolve_invocation_settings", fail)
462+
monkeypatch.setattr(invocation_settings_transport, "resolve_invocation_settings", fail)
465463

466464
recorder, response = _post_invoke({"invocation_settings": {"opaque": "payload"}})
467465

@@ -475,7 +473,7 @@ def test_resolution_failure_never_exposes_exception_message(self, monkeypatch, c
475473
def fail(_payload):
476474
raise _ResolutionFailure(Blame.RECIPIENT, secret)
477475

478-
monkeypatch.setattr(invocation_settings_transport, "_resolve_invocation_settings", fail)
476+
monkeypatch.setattr(invocation_settings_transport, "resolve_invocation_settings", fail)
479477

480478
recorder, response = _post_invoke({"invocation_settings": {"opaque": "payload"}})
481479

unstructured_platform_plugins/invocation_settings.py

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636
from contextvars import ContextVar
3737
from typing import Any, Optional, TypeVar
3838

39-
import utic_invocation_settings as _invocation_settings_contract
4039
from fastapi import Depends, FastAPI, Request
4140
from starlette.requests import ClientDisconnect
4241
from starlette.responses import JSONResponse
@@ -48,6 +47,7 @@
4847
Blame,
4948
InvocationSettingsError,
5049
MalformedEnvelopeError,
50+
resolve_invocation_settings,
5151
)
5252

5353
from unstructured_platform_plugins.invocation_context import (
@@ -101,15 +101,6 @@ def current_invocation_context() -> Optional[InvocationContext]:
101101
return _INVOCATION.get()[1]
102102

103103

104-
def _resolve_invocation_settings(payload: Any) -> Optional[dict[str, Any]]:
105-
"""Resolve a contract-owned payload to the ordinary mapping bound to a plugin.
106-
107-
This deliberately thin call is the only integration point with the settings wire contract.
108-
The transport does not inspect ``dag_node_settings`` or any field envelope within it.
109-
"""
110-
return _invocation_settings_contract.resolve_invocation_settings(payload)
111-
112-
113104
@contextmanager
114105
def invocation_envelope(
115106
invocation_settings: Optional[dict], invocation_context: Optional[InvocationContext]
@@ -225,7 +216,7 @@ async def bind_invocation_envelope(request: Request) -> AsyncIterator[None]:
225216
try:
226217
# Off the event loop: resolution may perform blocking cryptography for independently
227218
# sealed fields, and this dependency fronts every invoke on the pod.
228-
invocation_settings = await asyncio.to_thread(_resolve_invocation_settings, raw_settings)
219+
invocation_settings = await asyncio.to_thread(resolve_invocation_settings, raw_settings)
229220
except Exception as exc:
230221
# Class name only — never envelope contents, and never the exception's own message,
231222
# which can embed request-controlled values.

0 commit comments

Comments
 (0)