Add notebook testing support and developer testing guide#4075
Open
chesterxgchen wants to merge 4 commits intoNVIDIA:mainfrom
Open
Add notebook testing support and developer testing guide#4075chesterxgchen wants to merge 4 commits intoNVIDIA:mainfrom
chesterxgchen wants to merge 4 commits intoNVIDIA:mainfrom
Conversation
e26ca60 to
edd88a5
Compare
Contributor
Greptile OverviewGreptile SummaryEnhanced Key Changes:
Implementation Quality:
Confidence Score: 4.5/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant User
participant runtest.sh
participant maybe_install_deps
participant should_install_deps
participant install_deps
participant notebook_test
participant get_current_kernel
participant validate_kernel
participant pytest
User->>runtest.sh: ./runtest.sh -n [options]
runtest.sh->>runtest.sh: Parse arguments (--timeout, --kernel, --nb-clean, -v)
runtest.sh->>maybe_install_deps: Check dependencies
alt fresh_deps flag set
maybe_install_deps->>install_deps: Force install
install_deps->>install_deps: pip install -e .[dev]
install_deps->>install_deps: Create .deps_marker (timestamp, 0 runs)
else check cache
maybe_install_deps->>should_install_deps: Check cache status
should_install_deps->>should_install_deps: Read .deps_marker file
alt marker missing
should_install_deps-->>maybe_install_deps: return 0 (install needed)
maybe_install_deps->>install_deps: Install dependencies
install_deps->>install_deps: Create .deps_marker
else cache expired (7 days or 50 runs)
should_install_deps-->>maybe_install_deps: return 0 (install needed)
maybe_install_deps->>install_deps: Install dependencies
install_deps->>install_deps: Reset .deps_marker
else cache valid
should_install_deps->>should_install_deps: Increment run count
should_install_deps-->>maybe_install_deps: return 1 (skip install)
end
end
runtest.sh->>notebook_test: Execute notebook_test(target)
alt kernel not specified
notebook_test->>get_current_kernel: Auto-detect kernel
get_current_kernel->>get_current_kernel: Check for python3 kernel
get_current_kernel-->>notebook_test: Return kernel name or empty
end
alt kernel specified/detected
notebook_test->>validate_kernel: Validate kernel exists
validate_kernel->>validate_kernel: jupyter kernelspec list
alt kernel not found
validate_kernel-->>notebook_test: return 1 (error)
notebook_test->>User: Error: kernel not found
else kernel valid
validate_kernel-->>notebook_test: return 0 (valid)
end
end
notebook_test->>notebook_test: Build pytest command array
notebook_test->>notebook_test: Add --nbmake, --nbmake-timeout, --nbmake-clean
notebook_test->>notebook_test: Add --kernel if specified
notebook_test->>notebook_test: Add -v if verbose_flag=true
notebook_test->>pytest: Execute pytest --nbmake [options]
Note over pytest: conftest.py hooks execute:<br/>- filter_notebook()<br/>- Create .backup file<br/>- Remove skip-execution cells<br/>- Update kernel spec<br/>- Execute notebook<br/>- Restore from backup<br/>- Clean outputs per --nbmake-clean
pytest-->>notebook_test: Return exit status
notebook_test->>notebook_test: report_status()
notebook_test-->>User: Test results
|
This comment was marked as outdated.
This comment was marked as outdated.
edd88a5 to
d572afc
Compare
This comment was marked as outdated.
This comment was marked as outdated.
b1808da to
8dd3f52
Compare
This comment was marked as outdated.
This comment was marked as outdated.
Collaborator
Author
|
/build |
8ac24c2 to
38235ee
Compare
…eloper guide Summary: This PR enhances runtest.sh with new testing capabilities, transparent dependency caching for faster development iteration, and comprehensive documentation. Developer Testing Improvements: - Dependency caching: First run installs; subsequent runs skip (auto-expires after 7 days or 50 runs) - Verbose mode (-v): Detailed pytest output for all test types - --fresh-deps: Force dependency reinstall when needed - Command printing: Shows exact command being executed for debugging Notebook Testing (-n option): - Run Jupyter notebooks as tests using nbmake - Default kernel detection (prefers python3 if available) - Configurable timeout, kernel, and output cleaning - Cell skipping via tags (skip-execution, skip, colab) - Automatic notebook backup and restore during tests Usage: ./runtest.sh # Full suite (license, style, unit tests) ./runtest.sh -u # Unit tests only (faster iteration) ./runtest.sh -n # Notebook tests ./runtest.sh -n -v # Notebook tests with verbose output ./runtest.sh --fresh-deps # Force dependency reinstall Documentation: - developer_testing.rst: General runtest.sh usage guide - notebook_testing.rst: Notebook-specific testing guide Note: Not all notebooks are ready for automated testing yet.
- Fix script name typo: runtests.sh -> runtest.sh
- Fix missing $ in color variable: {noColor} -> ${noColor}
- Fix race condition: use atomic file operations (temp file + mv) for marker file
- Add kernel validation: validate kernel exists before running notebook tests
- Add numeric validation for marker file values to handle corruption
- Move get_current_kernel() call from script load to notebook_test() runtime - Remove intermediate kernel_opt variable, use kernel directly - Allows jupyter to be installed after script loads
f47fdc6 to
e36d53c
Compare
Collaborator
Author
|
/build |
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.
Summary
This PR enhances
runtest.shwith new testing capabilities, transparent dependency caching for faster development iteration, and comprehensive documentation for developers.Features
Developer Testing Improvements
-v): Detailed pytest output for all test types--fresh-deps: Force dependency reinstall when neededNotebook Testing (
-noption)python3if available)skip-execution,skip,colab)Usage
Dependency Caching
The script automatically caches dependency installation:
--fresh-depsor--cleanExample output:
Documentation
developer_testing.rst: Generalruntest.shusage guide covering all test commandsnotebook_testing.rst: Notebook-specific testing guideFiles Changed
runtest.sh: Added notebook testing, dependency caching, verbose modedocs/programming_guide/developer_testing.rst: New general testing guidedocs/programming_guide/notebook_testing.rst: New notebook testing guidedocs/programming_guide.rst: Updated toctree