refactor(nmp-common): split plugin-safe SDK factory + helpers into nemo_platform_plugin#44
Open
marcusds wants to merge 1 commit into
Open
refactor(nmp-common): split plugin-safe SDK factory + helpers into nemo_platform_plugin#44marcusds wants to merge 1 commit into
marcusds wants to merge 1 commit into
Conversation
…mo_platform_plugin
Phase B/C of the nmp-common slim plan (follow-up to ASTD-166).
Canonical homes for plugin-safe helpers now live in nemo_platform_plugin:
- jobs/image.py (get_qualified_image, image_builder)
- http_clients.py (shared sync/async HTTP clients)
- otel_headers.py (MARK_INTERNAL_REQUEST_HEADERS, propagation context)
- auth/ (Principal, AuthContext, principal_from_env,
auth_client_context, get_principal_auth_headers,
build_service_principal_headers, exceptions)
- sdk_factory.py (get_platform_sdk, get_async_platform_sdk, get_task_sdk,
get_request_scoped_sdk, get_sdk_on_behalf_of,
get_entity_parts)
nmp.common modules are thin shims that re-export from these locations so
service-side callers keep working. Plugin call sites in nemo-{anonymizer,
data-designer,guardrails,agents,example-plugin} now import directly from
nemo_platform_plugin.
Also tightens NemoJob.to_spec / NemoJob.compile base signatures: async_sdk
from object to AsyncNeMoPlatform. Resolves Liskov override violations
every concrete subclass was already hitting.
nmp_testing.client and test_sdk_factory updated to mutate the canonical
_test_http_client and patch the canonical module path.
No install-footprint change yet - plugins still import other nmp.common
helpers (entities.*, config.*, service.headers.*). Phase D removes the dep
once those land.
Contributor
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Phase B/C of the nmp-common slim plan (follow-up to ASTD-166). Sets up Phase D (drop
nmp-commonfrom plugin deps) by moving the plugin-callable subset ofnmp.commonintonemo-platform-plugin.Canonical homes in
nemo_platform_plugin:jobs/image.py—get_qualified_image,image_builderhttp_clients.py— shared sync/async HTTP clientsotel_headers.py—MARK_INTERNAL_REQUEST_HEADERS, propagation contextauth/—Principal,AuthContext,principal_from_env,auth_client_context,get_principal_auth_headers,build_service_principal_headers, exceptionssdk_factory.py—get_platform_sdk,get_async_platform_sdk,get_task_sdk,get_request_scoped_sdk,get_sdk_on_behalf_of,get_entity_partsnmp.commonmodules are thin shims that re-export from these locations — service-side callers keep working with no changes. Plugin call sites innemo-{anonymizer,data-designer,guardrails,agents,example-plugin}now import directly fromnemo_platform_plugin.Also tightens
NemoJob.to_spec/NemoJob.compilebase signatures:async_sdk: object→AsyncNeMoPlatform. Resolves Liskov override violations every concrete subclass was already hitting.nmp_testing.clientandtest_sdk_factoryupdated to mutate the canonical_test_http_clientand patch the canonical module path — required because mutating the shim's attribute would not affect the plugin module's free variable.Plugin sdk_factory uses
NemoPlatformConfig(base) instead ofPlatformConfig(extended). Co-hosted-service URL routing falls back to the configured base URL, which is correct for plugin code running outside the platform process.No install-footprint change yet — plugins still import other
nmp.commonhelpers (entities., config., service.headers.*, a few jobs.constants/exceptions sites). Phase D removes the dep entirely once those land.Test plan
uv run --frozen pytest packages/nemo_platform_plugin/tests packages/nmp_common— 1580 passeduv run --frozen pytest plugins -q --timeout=60 -x --ignore=plugins/nemo-switchyard/vendor— 918 passed, 2 pre-existing skipsuv run --frozen ty checkon staged files — passes (# ty: ignoreadded for 3 pre-existing baseline errors surfaced by touchingnmp_testing.client)