-
Notifications
You must be signed in to change notification settings - Fork 34
feat: add local backend for built-in nemo guardrails #197
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
rapids-bot
merged 34 commits into
NVIDIA:main
from
afourniernv:afournier/relay-149-implement-local-python-backed-backend-for-built-in-nemo
Jun 7, 2026
Merged
Changes from 3 commits
Commits
Show all changes
34 commits
Select commit
Hold shift + click to select a range
253c845
feat: add local backend for built-in nemo guardrails
afourniernv ec49259
docs: refine local guardrails mode docs
afourniernv 98d4915
test: factor local guardrails coverage fixtures
afourniernv 244f29f
style: apply rustfmt for local guardrails tests
afourniernv ffa88dc
refactor: name local guardrails imports
afourniernv f8dead5
fix: address local guardrails review nits
afourniernv 67fd1b9
test: extend local guardrails cli coverage
afourniernv 8823aef
Merge remote-tracking branch 'github/main' into guardrails-cli-local-…
afourniernv e86ae58
refactor: embed local guardrails helper snapshot
afourniernv 763ad75
Merge remote-tracking branch 'github/main' into guardrails-cli-local-…
afourniernv 3c7eecd
refactor: move local guardrails backend into core
afourniernv 7e8f4e1
Merge remote-tracking branch 'github/main' into guardrails-cli-local-…
afourniernv e249238
refactor: own local NeMo Guardrails runtime in Rust
willkill07 7e0b3af
refactor: gate fn impl on cfg rather than branch
willkill07 31584ef
Merge branch 'main' into afournier/relay-149-implement-local-python-b…
willkill07 9ad985e
Centralize Python Rust dependency versions
willkill07 5dba153
fix: stabilize local guardrails branch checks
afourniernv 0260c7e
Merge remote-tracking branch 'github-fork/afournier/relay-149-impleme…
afourniernv 4aee554
fix: restore python guardrails coverage split
afourniernv 430dc50
Merge branch 'main' into afournier/relay-149-implement-local-python-b…
willkill07 aba629c
fix: run local guardrails through python subprocess
willkill07 cdbd1a0
test: adapt guardrails coverage to subprocess backend
willkill07 dfee75b
chore: restore cargo manifests
willkill07 527b1f8
fix: address local guardrails review feedback
willkill07 6d68272
fix: harden local guardrails worker flow
willkill07 33df99f
fix: track local guardrails worker tasks
willkill07 8527102
Merge branch 'main' into afournier/relay-149-implement-local-python-b…
willkill07 55bc4b9
fix: use real python executable in guardrails tests
willkill07 47ca8cb
fix: scope guardrails worker python path
willkill07 1dc1328
Merge branch 'main' into afournier/relay-149-implement-local-python-b…
willkill07 1f3d406
fix: preserve guardrails worker python environment
willkill07 827c939
fix: select managed python for guardrails worker
willkill07 e7b28b9
fix: restore pass-through local guardrails streaming
afourniernv dafb996
test: relax streamed guardrails ordering assertion
afourniernv File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| // SPDX-FileCopyrightText: Copyright (c) 2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| use std::sync::{Arc, LazyLock, Mutex, MutexGuard}; | ||
|
|
||
| use crate::plugin::{PluginError, PluginRegistrationContext, Result as PluginResult}; | ||
|
|
||
| use super::NeMoGuardrailsConfig; | ||
|
|
||
| type LocalBackendProvider = Arc< | ||
| dyn Fn(NeMoGuardrailsConfig, &mut PluginRegistrationContext) -> PluginResult<()> + Send + Sync, | ||
| >; | ||
|
|
||
| static LOCAL_BACKEND_PROVIDER: LazyLock<Mutex<Option<LocalBackendProvider>>> = | ||
| LazyLock::new(|| Mutex::new(None)); | ||
|
|
||
| fn local_backend_provider_guard() -> PluginResult<MutexGuard<'static, Option<LocalBackendProvider>>> { | ||
| LOCAL_BACKEND_PROVIDER.lock().map_err(|e| { | ||
| PluginError::Internal(format!( | ||
| "NeMo Guardrails local backend provider lock poisoned: {e}" | ||
| )) | ||
| }) | ||
| } | ||
|
|
||
| #[doc(hidden)] | ||
| pub fn register_local_backend_provider(provider: LocalBackendProvider) -> PluginResult<()> { | ||
| let mut guard = local_backend_provider_guard()?; | ||
| *guard = Some(provider); | ||
| Ok(()) | ||
| } | ||
|
|
||
| #[doc(hidden)] | ||
| pub fn clear_local_backend_provider() -> PluginResult<()> { | ||
| let mut guard = local_backend_provider_guard()?; | ||
| *guard = None; | ||
| Ok(()) | ||
| } | ||
|
|
||
| pub(super) fn register_local_backend( | ||
| config: NeMoGuardrailsConfig, | ||
| ctx: &mut PluginRegistrationContext, | ||
| ) -> PluginResult<()> { | ||
| let provider = local_backend_provider_guard()?.clone(); | ||
|
|
||
| match provider { | ||
| Some(provider) => provider(config, ctx), | ||
| None => Err(PluginError::RegistrationFailed( | ||
| "built-in NeMo Guardrails local backend is unavailable in this runtime".to_string(), | ||
| )), | ||
| } | ||
| } |
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.