Skip to content

refactor(nmp-common): split plugin-safe SDK factory + helpers into nemo_platform_plugin#44

Open
marcusds wants to merge 1 commit into
mainfrom
slim-nmp-common-plugin-deps/mschwab
Open

refactor(nmp-common): split plugin-safe SDK factory + helpers into nemo_platform_plugin#44
marcusds wants to merge 1 commit into
mainfrom
slim-nmp-common-plugin-deps/mschwab

Conversation

@marcusds
Copy link
Copy Markdown
Contributor

Summary

Phase B/C of the nmp-common slim plan (follow-up to ASTD-166). Sets up Phase D (drop nmp-common from plugin deps) by moving the plugin-callable subset of nmp.common into nemo-platform-plugin.

Canonical homes in nemo_platform_plugin:

  • jobs/image.pyget_qualified_image, image_builder
  • http_clients.py — shared sync/async HTTP clients
  • otel_headers.pyMARK_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.pyget_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 — service-side callers keep working with no changes. 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: objectAsyncNeMoPlatform. 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 — required because mutating the shim's attribute would not affect the plugin module's free variable.

Plugin sdk_factory uses NemoPlatformConfig (base) instead of PlatformConfig (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.common helpers (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 passed
  • uv run --frozen pytest plugins -q --timeout=60 -x --ignore=plugins/nemo-switchyard/vendor — 918 passed, 2 pre-existing skips
  • uv run --frozen ty check on staged files — passes (# ty: ignore added for 3 pre-existing baseline errors surfaced by touching nmp_testing.client)
  • Pre-commit hooks: ruff format, ty, copyright headers, merge conflicts all green
  • Plugin SDK factory + sdk_on_behalf_of + url routing tests pass
  • NemoJob Liskov override warnings cleared across the codebase

…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.
@marcusds marcusds requested review from a team as code owners May 26, 2026 01:49
@github-actions
Copy link
Copy Markdown
Contributor

Suite Lines Covered Line Rate Branch Rate
Unit Tests 18297/24246 75.5% 61.9%
Integration Tests 11718/23028 50.9% 25.9%

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant