Expand Relay plugin configuration - #22
Conversation
… for relay plugin configurations not available as environment variables Signed-off-by: David Gardner <dagardner@nvidia.com>
… hermes specific Signed-off-by: David Gardner <dagardner@nvidia.com>
…er adapters to the utils.py module Signed-off-by: David Gardner <dagardner@nvidia.com>
Signed-off-by: David Gardner <dagardner@nvidia.com>
Signed-off-by: David Gardner <dagardner@nvidia.com>
Signed-off-by: David Gardner <dagardner@nvidia.com>
Signed-off-by: David Gardner <dagardner@nvidia.com>
Signed-off-by: David Gardner <dagardner@nvidia.com>
…fied using hermes_sdk in the main branch Signed-off-by: David Gardner <dagardner@nvidia.com>
…common/hermes and common/utils tests Signed-off-by: David Gardner <dagardner@nvidia.com>
Signed-off-by: David Gardner <dagardner@nvidia.com>
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Enterprise Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughShared payload/config and relay helper logic moved into ChangesHermes shared utilities and relay profiles
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
…-config Signed-off-by: David Gardner <dagardner@nvidia.com>
…g JSON to a YAML file is always valid we should not raise exceptions on a missing PyYaml lib Signed-off-by: David Gardner <dagardner@nvidia.com>
Signed-off-by: David Gardner <dagardner@nvidia.com>
There was a problem hiding this comment.
Actionable comments posted: 4
🧹 Nitpick comments (1)
tests/test_adapaters_common_utils.py (1)
86-160: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd direct coverage for
write_relay_plugins_toml().The tests cover loading and artifact collection, but not the new TOML writer or the
FABRIC_RELAY_CONFIG_PATH→relay-plugins.tomlpath contract.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@tests/test_adapaters_common_utils.py` around lines 86 - 160, Add direct test coverage for write_relay_plugins_toml() and the FABRIC_RELAY_CONFIG_PATH-to-relay-plugins.toml contract. Extend the common_utils tests to exercise the TOML writer with a config_root/effective_config payload, then assert the generated relay-plugins.toml is written in the expected location and contains the normalized observability config. Use the existing load_relay_plugin_config() and collect_relay_artifacts() coverage as a guide, and reference write_relay_plugins_toml() plus FABRIC_RELAY_CONFIG_PATH to locate the behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@adapters/common/src/nemo_fabric_adapters/common/hermes.py`:
- Around line 201-205: The relay_model_name helper still assumes the selected
entry from common_utils.models_payload is a dict, so a non-dict model config can
crash downstream adapters. Update relay_model_name to mirror the shared guard by
validating the value returned from models.get(...) before calling .get on it,
and fall back to "unknown" when the model config is not a dict or does not
contain a usable model field.
In `@adapters/common/src/nemo_fabric_adapters/common/utils.py`:
- Around line 162-166: _guard the selected model config in _relay_model_name
before calling .get(): the value retrieved from models_payload(payload) may not
be a mapping, so normalize it to an empty dict when it is not a dict, then keep
the existing fallback chain using settings_payload, models_payload, and the
returned model_config. Ensure _relay_model_name never assumes the selected model
entry supports .get(), matching the safer behavior already used by
selected_model_config._
- Around line 130-141: The artifact collection loop currently uses broad globs
in the section_name-based scan, which can pick up unrelated files from a shared
output_directory. Update the logic in this utility to derive the search pattern
from each section’s configured filename or filename_template instead of
hardcoding "*.jsonl" and "*.json", and keep the existing
enabled/config/directory checks so only the intended artifacts are appended.
In `@tests/fixtures/hermes-cli-agent/bin/fake-hermes.py`:
- Around line 17-20: The fake Hermes CLI contract is too loose in the fixture’s
argument handling: the current `--query` check in fake-hermes.py no longer
enforces the required `chat` subcommand and can still crash when `--query` has
no following value. Update the argument validation around the existing `args`
parsing so it first requires `chat`, then verifies `--query` is present with a
value before reading the prompt, and return a clean error for invalid
invocations instead of raising `IndexError`.
---
Nitpick comments:
In `@tests/test_adapaters_common_utils.py`:
- Around line 86-160: Add direct test coverage for write_relay_plugins_toml()
and the FABRIC_RELAY_CONFIG_PATH-to-relay-plugins.toml contract. Extend the
common_utils tests to exercise the TOML writer with a
config_root/effective_config payload, then assert the generated
relay-plugins.toml is written in the expected location and contains the
normalized observability config. Use the existing load_relay_plugin_config() and
collect_relay_artifacts() coverage as a guide, and reference
write_relay_plugins_toml() plus FABRIC_RELAY_CONFIG_PATH to locate the behavior.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: 33e2b98f-06b2-4c9b-b267-8e7c093247f2
📒 Files selected for processing (11)
adapters/common/src/nemo_fabric_adapters/common/hermes.pyadapters/common/src/nemo_fabric_adapters/common/utils.pyadapters/hermes-cli/src/nemo_fabric_adapters/hermes_cli/adapter.pyadapters/hermes-sdk/src/nemo_fabric_adapters/hermes_sdk/adapter.pyexamples/code-review-agent/profiles/hermes-relay-cli-openinference.yamlexamples/code-review-agent/profiles/hermes-relay-openinference.yamlpyproject.tomltests/fixtures/hermes-cli-agent/bin/fake-hermes.pytests/test_adapaters_common_hermes.pytests/test_adapaters_common_utils.pytests/test_hermes_cli.py
Signed-off-by: David Gardner <dagardner@nvidia.com>
|
@dagardner-nv I think we should split the Relay configuration path by adapter boundary. For For from nemo_relay import plugin
from nemo_relay.observability import (
AtofConfig,
AtifConfig,
ComponentSpec,
ObservabilityConfig,
OtlpConfig,
)
plugin_config = plugin.PluginConfig(
components=[
ComponentSpec(
ObservabilityConfig(
atof=AtofConfig(...),
atif=AtifConfig(...),
openinference=OtlpConfig(...),
)
)
]
)
async with plugin.plugin(plugin_config):
# run Hermes SDK conversation
... |
Signed-off-by: David Gardner <dagardner@nvidia.com>
Signed-off-by: David Gardner <dagardner@nvidia.com>
Signed-off-by: David Gardner <dagardner@nvidia.com>
Signed-off-by: David Gardner <dagardner@nvidia.com>
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
adapters/hermes-sdk/src/nemo_fabric_adapters/hermes_sdk/adapter.py (1)
120-120: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winReaching across module boundary into a private helper.
common_utils._relay_api_plugin_config(...)is consumed here from another module despite its leading underscore marking it as private tocommon.utils. Either promote it to a public name (relay_api_plugin_config) or wrap it behind a public helper so the SDK adapter isn't coupled to an internal symbol that may change without notice.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@adapters/hermes-sdk/src/nemo_fabric_adapters/hermes_sdk/adapter.py` at line 120, The adapter is calling a private helper from another module, which couples Hermes SDK’s adapter logic to an internal symbol. Update the adapter to use a public API instead of common_utils._relay_api_plugin_config, either by renaming/promoting that helper to relay_api_plugin_config in common.utils or by introducing a public wrapper that the adapter can call. Keep the change localized around the relay_api_config assignment in the adapter.py flow so the SDK depends only on supported symbols.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@adapters/common/src/nemo_fabric_adapters/common/utils.py`:
- Around line 179-187: The Relay plugin configuration path skips validation
before activation, so malformed config can reach plugin setup and fail late. In
the flow that builds `relay_api_config` via `_relay_api_plugin_config(...)` and
then enters `async with plugin.plugin(relay_api_config)`, insert a
`plugin.validate(...)` call on `relay_api_config` first and handle failures
before activation, keeping the fix localized to the Relay initialization path.
In `@adapters/hermes-sdk/src/nemo_fabric_adapters/hermes_sdk/adapter.py`:
- Around line 119-128: The relay-enabled branch in adapter.py runs the
synchronous _invoke_hermes() directly inside the async with plugin.plugin(...)
context, which can block the relay event loop and delay span/metric draining.
Update the relay execution path in the adapter logic around relay_enabled,
relay_api_config, and plugin.plugin(...) so Hermes runs off the event loop (for
example via a worker thread) or so the relay context only wraps non-blocking
work, while preserving the current result, enabled_toolsets, relay_artifacts,
and adapter_stdout behavior.
---
Nitpick comments:
In `@adapters/hermes-sdk/src/nemo_fabric_adapters/hermes_sdk/adapter.py`:
- Line 120: The adapter is calling a private helper from another module, which
couples Hermes SDK’s adapter logic to an internal symbol. Update the adapter to
use a public API instead of common_utils._relay_api_plugin_config, either by
renaming/promoting that helper to relay_api_plugin_config in common.utils or by
introducing a public wrapper that the adapter can call. Keep the change
localized around the relay_api_config assignment in the adapter.py flow so the
SDK depends only on supported symbols.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: 95ac7cb7-b52a-4e2b-a56f-267d6a36451a
📒 Files selected for processing (3)
adapters/common/src/nemo_fabric_adapters/common/utils.pyadapters/hermes-sdk/src/nemo_fabric_adapters/hermes_sdk/adapter.pytests/test_hermes_sdk_adapter.py
Signed-off-by: David Gardner <dagardner@nvidia.com>
AjayThorve
left a comment
There was a problem hiding this comment.
This split looks right to me now: CLI keeps serialized TOML/env because it launches Hermes out-of-process, and SDK uses the in-process Relay plugin API with scoped cleanup.
Non-blocking follow-up: it would still be useful to add an SDK regression test that exercises a Relay-enabled run followed by a Relay-disabled run in the same Python process, but I don’t think that needs to block this PR.
PluginConfigwrite_relay_plugins_tomlhelper method for hermes_cli_relay_api_plugin_confighelper method for hermes_sdkadapters/common/src/nemo_fabric_adapters/common/utils.pymodule for methods likewrite_relay_plugins_tomlwhich are not Hermes specific and could be of use to other adapters.tests/test_adapaters_hermes_common.pytests into those for the common/hermes and common/utils testshermes chat --query <prompt>command in thehermes_cliadapter rather that the-zflag, the reason is that with-zthe session is not finalized on completion the way it is withhermes chat, this conforms with behavior of thehermes_sdkadapter.pyyamldependency to be a dependency of thehermesextra (currently only need to write Hermes config files)tomli-wto therelayextraSummary by CodeRabbit
Summary
New Features
Bug Fixes
chat --quiet --query <prompt>(including session continuation).Refactor
Tests