feat(plugin-api): export the configuration, build, and run surfaces - #2148
Draft
DABH wants to merge 1 commit into
Draft
feat(plugin-api): export the configuration, build, and run surfaces#2148DABH wants to merge 1 commit into
DABH wants to merge 1 commit into
Conversation
Third-party plugins that build workflows or drive runs (front ends, execution instrumentation, test harnesses) currently have to import implementation modules for that flow, contradicting the guidance that external plugin packages import only from nat.plugin_api. - Re-export Config, load_config, PluginTypes, discover_and_register_plugins, WorkflowBuilder, Runner, and ExporterManager through nat.plugin_api and extend __all__. - Add a public read-only entry_fn property to Workflow so callers can reach the entry Function without touching private attributes. - Pin the new exports in EXPECTED_PLUGIN_API_EXPORTS and add a consumer-style test that loads a config, builds it with WorkflowBuilder, reads workflow.entry_fn, and drives a run with Runner using facade imports alone. - Document the new provisional surface rows in docs/source/extend/plugin-api.md. Signed-off-by: David Hyde <DABH@users.noreply.github.com>
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Enterprise Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
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.
Description
Third-party plugin packages are asked to import plugin-authoring symbols only from the stable
nat.plugin_apifacade (perdocs/source/extend/third-party-plugins.md). However, plugins that programmatically load, build, or drive workflows — front ends, execution instrumentation, and test harnesses — currently have to import implementation modules for every step of that flow:Config(nat.data_models.config) plusload_config,PluginTypes, anddiscover_and_register_plugins(nat.runtime.loader) to discover installed plugins and produce a validated configuration object.WorkflowBuilder(nat.builder.workflow_builder) to build the configured workflow.Runner(nat.runtime.runner) andExporterManager(nat.observability.exporter_manager) to drive a run the same wayWorkflow.rundoes.On top of that, the built
Workflowkeeps its entry function private (self._entry_fn), so a caller that wants to construct aRunnerfor it, or introspect the workflow's input and output contracts, has to reach into a private attribute.This change is purely additive:
nat.plugin_apiand extend__all__.entry_fnproperty toWorkflowwith a docstring; internal call sites are unchanged.EXPECTED_PLUGIN_API_EXPORTS.nat.plugin_api, registers a function, loads a minimal config, builds it withWorkflowBuilder, readsworkflow.entry_fn, and drives a run withRunner, sourcing the exporter manager from the built workflow's public read-onlyexporter_managerproperty the same wayWorkflow.rundoes, so the demonstrated pattern preserves configured telemetry exporters.docs/source/extend/plugin-api.md: two new surface-review rows ("Configuration loading and plugin discovery" and "Workflow build and run", both proposed as provisional public, matching the promotion tier of the runtime context access row), a new public-surface bullet, and a reworkedWorkflowBuildernote in the private-modules section. The runtime context access row no longer lists exporter management as unpromoted, and the builder-type row no longer describes concrete builders as implementation details — it now points at the "Workflow build and run" row, which also tells callers constructing aRunnerdirectly to source the exporter manager from the built workflow.Workflow.runremains the simplest way to execute a built workflow.RunnerandExporterManagerare exported for callers that need to own the run scope — for example supplying their ownContextStateor instrumenting the runner lifecycle — andExporterManageris the declared type of both the built workflow's publicexporter_managerproperty andRunner's requiredexporter_managerparameter, so driving a run through the facade needs it importable.register_front_endand the front-end hosting contract remain deferred; this PR only promotes the objects needed to load a configuration, build it, and drive runs.No tracking issue exists for this yet; happy to file one if the team prefers.
Testing
uv run pytest packages/nvidia_nat_core/tests/nat/test_plugin_api.py— 8 passed (includes the new consumer-style test).uv run pytest packages/nvidia_nat_core/tests/nat/builder packages/nvidia_nat_core/tests/nat/runtime packages/nvidia_nat_core/tests/nat/middleware packages/nvidia_nat_core/tests/nat/observability— 1341 passed.uv run pytest packages/nvidia_nat_core/tests --ignore=packages/nvidia_nat_core/tests/eval/test_eval_callbacks.py --ignore=packages/nvidia_nat_core/tests/nat/finetuning/interfaces/test_trajectory_builder.py— 2585 passed, 236 skipped. The two ignored modules import the eval plugin extra (not installed locally) and fail to collect identically on the base branch.uv run pre-commit run yapf --files <touched files>anduv run pre-commit run ruff-check --files <touched files>,uv run python ci/scripts/copyright.py --verify-apache-v2,valeand the markdown-link-check hook on the touched Markdown file, anduv run python ci/scripts/path_checks.pyall pass.By Submitting this PR I confirm: