Skip to content

Conversation

@dagardner-nv
Copy link
Contributor

@dagardner-nv dagardner-nv commented Oct 24, 2025

Description

  • I opted to use load_config to instantiate a config object to be slightly more efficient, however I think there's an argument to not doing that to simplify the example

By Submitting this PR I confirm:

  • I am familiar with the Contributing Guidelines.
  • We require that all contributors "sign-off" on their commits. This certifies that the contribution is your original work, or you have rights to submit it under the same license, or a compatible license.
    • Any contribution which contains commits that are not Signed-Off will not be accepted.
  • When the PR is ready for review, new or existing tests cover these changes.
  • When the PR is ready for review, the documentation is up to date with these changes.

Summary by CodeRabbit

  • Documentation
    • Simplified the Getting Started example notebook with a streamlined, configuration-driven workflow approach for improved clarity and ease of use.

@dagardner-nv dagardner-nv self-assigned this Oct 24, 2025
@dagardner-nv dagardner-nv added improvement Improvement to existing functionality non-breaking Non-breaking change labels Oct 24, 2025
@review-notebook-app
Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@coderabbitai
Copy link

coderabbitai bot commented Oct 24, 2025

Walkthrough

The notebook example replaced a dynamic workflow loader pattern with a simplified configuration-driven approach. The amain function now loads configuration once and processes stdin queries using run_workflow directly instead of yielding callables. Error handling was adjusted accordingly, and unused helper functions and imports were removed.

Changes

Cohort / File(s) Summary
Notebook workflow refactoring
examples/notebooks/1_getting_started_with_nat.ipynb
Replaced load_workflow (yielded callable pattern) with load_config and run_workflow (configuration-driven approach). Updated amain to load config once and invoke run_workflow for each stdin query. Removed get_callable_for_workflow helper and adjusted error handling from iterating yielded callables to parsing EOFError. Updated imports accordingly.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant amain as amain()
    participant Config as load_config()
    participant Workflow as run_workflow()
    
    rect rgb(220, 240, 255)
    Note over User,Workflow: New approach
    User->>amain: stdin queries + config path
    amain->>Config: load_config(path)
    Config-->>amain: config object
    loop Each stdin query
        User->>amain: query
        amain->>Workflow: run_workflow(config, prompt=query)
        Workflow-->>amain: result
        amain-->>User: output
    end
    amain->>amain: catch EOFError, exit
    end
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

  • Single file modification with a straightforward refactoring pattern
  • Control flow change is clear and consistent throughout
  • Minimal logic complexity; primarily an API swap with corresponding adjustments
  • No changes to external file imports or dependencies requiring deep context
  • Main focus: verify that the new run_workflow API is called correctly for each query and that error handling preserves intended behavior

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title "Update example notebook to use the run_workflow function" is concise at 58 characters (within the 72-character limit), uses imperative mood with the verb "Update," and is clearly descriptive of the main changes. The title directly aligns with the changeset, which centers on refactoring the example notebook to adopt the new run_workflow function alongside load_config as part of a simplified configuration-driven approach, replacing the previous dynamic workflow loader pattern. The title accurately summarizes the key modification without being vague or off-topic.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@dagardner-nv dagardner-nv marked this pull request as ready for review October 24, 2025 21:38
@dagardner-nv dagardner-nv requested a review from a team as a code owner October 24, 2025 21:38
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
examples/notebooks/1_getting_started_with_nat.ipynb (1)

1-13: Missing required SPDX Apache-2.0 license header.

The coding guidelines mandate that every file, including .ipynb files, must start with the standard SPDX Apache-2.0 header. This notebook is missing the required header.

As per coding guidelines, add the Apache-2.0 SPDX header. For Jupyter notebooks, this should typically be placed in the first markdown cell or as a comment in the notebook metadata. You can reference other notebooks in the repository for the correct format.

🧹 Nitpick comments (1)
examples/notebooks/1_getting_started_with_nat.ipynb (1)

536-546: Consider adding basic error handling for missing config path.

While the implementation correctly loads the config once and processes multiple queries efficiently, there's no validation that sys.argv[1] exists. This could lead to an IndexError if the script is run without arguments.

For production code, consider adding a check:

if len(sys.argv) < 2:
    print("Usage: python nat_embedded.py <config_file>", file=sys.stderr)
    sys.exit(1)
config = load_config(sys.argv[1])

However, keeping example code simple is also a valid choice, so this is optional.

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 36acd69 and de5bd55.

📒 Files selected for processing (1)
  • examples/notebooks/1_getting_started_with_nat.ipynb (1 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
{**/*.py,**/*.sh,**/*.md,**/*.toml,**/*.y?(a)ml,**/*.json,**/*.txt,**/*.ini,**/*.cfg,**/*.ipynb}

📄 CodeRabbit inference engine (.cursor/rules/general.mdc)

{**/*.py,**/*.sh,**/*.md,**/*.toml,**/*.y?(a)ml,**/*.json,**/*.txt,**/*.ini,**/*.cfg,**/*.ipynb}: Every file must start with the standard SPDX Apache-2.0 header
Confirm copyright years are up to date when a file is changed
All source files must include the SPDX Apache-2.0 header template (copy from an existing file)

Files:

  • examples/notebooks/1_getting_started_with_nat.ipynb
**/*

⚙️ CodeRabbit configuration file

**/*: # Code Review Instructions

  • Ensure the code follows best practices and coding standards. - For Python code, follow
    PEP 20 and
    PEP 8 for style guidelines.
  • Check for security vulnerabilities and potential issues. - Python methods should use type hints for all parameters and return values.
    Example:
    def my_function(param1: int, param2: str) -> bool:
        pass
  • For Python exception handling, ensure proper stack trace preservation:
    • When re-raising exceptions: use bare raise statements to maintain the original stack trace,
      and use logger.error() (not logger.exception()) to avoid duplicate stack trace output.
    • When catching and logging exceptions without re-raising: always use logger.exception()
      to capture the full stack trace information.

Documentation Review Instructions - Verify that documentation and comments are clear and comprehensive. - Verify that the documentation doesn't contain any TODOs, FIXMEs or placeholder text like "lorem ipsum". - Verify that the documentation doesn't contain any offensive or outdated terms. - Verify that documentation and comments are free of spelling mistakes, ensure the documentation doesn't contain any

words listed in the ci/vale/styles/config/vocabularies/nat/reject.txt file, words that might appear to be
spelling mistakes but are listed in the ci/vale/styles/config/vocabularies/nat/accept.txt file are OK.

Misc. - All code (except .mdc files that contain Cursor rules) should be licensed under the Apache License 2.0,

and should contain an Apache License 2.0 header comment at the top of each file.

  • Confirm that copyright years are up-to date whenever a file is changed.

Files:

  • examples/notebooks/1_getting_started_with_nat.ipynb
examples/**/*

⚙️ CodeRabbit configuration file

examples/**/*: - This directory contains example code and usage scenarios for the toolkit, at a minimum an example should
contain a README.md or file README.ipynb.

  • If an example contains Python code, it should be placed in a subdirectory named src/ and should
    contain a pyproject.toml file. Optionally, it might also contain scripts in a scripts/ directory.
  • If an example contains YAML files, they should be placed in a subdirectory named configs/. - If an example contains sample data files, they should be placed in a subdirectory named data/, and should
    be checked into git-lfs.

Files:

  • examples/notebooks/1_getting_started_with_nat.ipynb
🔇 Additional comments (2)
examples/notebooks/1_getting_started_with_nat.ipynb (2)

531-532: LGTM! Simplified API imports.

The updated imports correctly use the simplified load_config and run_workflow APIs, replacing the previous generator-based approach.


549-549: LGTM!

Using asyncio.run(amain()) is the correct and idiomatic way to execute the async main function.

@dagardner-nv
Copy link
Contributor Author

/merge

@rapids-bot rapids-bot bot merged commit 0eb8512 into NVIDIA:develop Oct 27, 2025
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

improvement Improvement to existing functionality non-breaking Non-breaking change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants