Skip to content

Conversation

Pouyanpi
Copy link
Collaborator

@Pouyanpi Pouyanpi commented Aug 18, 2025

tests for nemoguardrails CLI

requires #1343

@Pouyanpi Pouyanpi requested a review from Copilot August 18, 2025 14:56
Copilot

This comment was marked as outdated.

Update verbose logging to safely handle cases where log records may not
have 'id' or 'task' attributes. Prevents potential AttributeError and
improves robustness of LLM and prompt log output formatting.
@codecov-commenter
Copy link

codecov-commenter commented Aug 19, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 73.75%. Comparing base (949e422) to head (4c9209a).
⚠️ Report is 21 commits behind head on develop.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #1339      +/-   ##
===========================================
+ Coverage    70.70%   73.75%   +3.04%     
===========================================
  Files          161      171      +10     
  Lines        16312    17025     +713     
===========================================
+ Hits         11533    12556    +1023     
+ Misses        4779     4469     -310     
Flag Coverage Δ
python 73.75% <100.00%> (+3.04%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
nemoguardrails/logging/verbose.py 90.90% <100.00%> (+0.39%) ⬆️

... and 28 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@Pouyanpi Pouyanpi requested review from tgasser-nv and Copilot August 28, 2025 10:49
@Pouyanpi Pouyanpi added this to the v0.17.0 milestone Aug 28, 2025
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds comprehensive test coverage for the NemoGuardRails CLI and reorganizes the existing test files into a more structured directory layout.

Key changes:

  • Move existing CLI tests to a dedicated tests/cli/ directory structure
  • Add extensive test coverage for CLI commands including migration, provider management, debugger, and chat functionality
  • Fix a potential AttributeError in the verbose logging module when handling log records

Reviewed Changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
tests/test_cli_migration.py Removed - moved to tests/cli/test_migration.py
tests/test_cli.py Removed - moved to tests/cli/test_cli_main.py
tests/cli/test_migration.py New comprehensive test suite for CLI migration functionality
tests/cli/test_llm_providers.py New test suite for LLM provider selection and management
tests/cli/test_debugger.py New test suite for CLI debugger commands
tests/cli/test_cli_main.py New test suite for main CLI commands and functionality
tests/cli/test_chat.py New test suite for chat interface functionality
nemoguardrails/logging/verbose.py Fix AttributeError when log records lack 'id' attribute

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment on lines +57 to +59
id_str = getattr(record, "id", None)
id_display = f"({id_str[:5]}..)" if id_str else ""
console.print(f"[cyan]LLM {title} {id_display}[/]")
Copy link
Preview

Copilot AI Aug 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The getattr call should provide a default value that prevents IndexError when id_str is not None but has fewer than 5 characters. Consider using id_str[:5] if id_str and len(id_str) >= 5 else id_str or handle empty/short strings explicitly.

Copilot uses AI. Check for mistakes.

Comment on lines +71 to +72
id_str = getattr(record, "id", None)
id_display = f"({id_str[:5]}..)" if id_str else ""
Copy link
Preview

Copilot AI Aug 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same issue as above - the slicing operation id_str[:5] could fail if id_str is not None but has fewer than 5 characters. The conditional should verify the string length before slicing.

Copilot uses AI. Check for mistakes.

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.

2 participants