-
Notifications
You must be signed in to change notification settings - Fork 41
Add CONTRIBUTING.md with development instructions #413
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
Open
Copilot
wants to merge
7
commits into
main
Choose a base branch
from
copilot/fix-397
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 5 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
bc34fd8
Initial plan
Copilot 84b6061
Add comprehensive testing instructions to docs
Copilot 73790eb
Move development instructions from README to CONTRIBUTING.md
Copilot d340433
Apply suggestions from code review
yebai 4713e64
Remove Tracker from CONTRIBUTING.md - support removed in #409
Copilot 62fa9e8
Specify JuliaFormatter version 1 in installation command
Copilot e217afb
Apply suggestions from code review
yebai 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,140 @@ | ||
| # Contributing to Bijectors.jl | ||
|
|
||
| Thank you for your interest in contributing to Bijectors.jl! This guide will help you set up your development environment and understand how to run tests locally. | ||
|
|
||
| ## Development Setup | ||
|
|
||
| 1. **Clone the repository**: | ||
|
|
||
| ```bash | ||
| git clone https://github.com/TuringLang/Bijectors.jl.git | ||
| cd Bijectors.jl | ||
| ``` | ||
|
|
||
| 2. **Install dependencies**: | ||
|
|
||
| ```bash | ||
| julia --project=. -e "using Pkg; Pkg.instantiate()" | ||
| ``` | ||
| 3. **Verify the package loads**: | ||
|
|
||
| ```bash | ||
| julia --project=. -e "using Bijectors; println(\"Package loaded successfully\")" | ||
| ``` | ||
|
|
||
| ## Running Tests | ||
|
|
||
| ### Reproducing CI Test Failures | ||
|
|
||
| When CI tests fail, the output often shows incomplete reproduction instructions. Here are the correct commands to reproduce different CI scenarios locally: | ||
|
|
||
| #### Interface Tests | ||
|
|
||
| ```bash | ||
| julia --project=. -e "ENV[\"GROUP\"] = \"Interface\"; using Pkg; Pkg.test()" | ||
| ``` | ||
|
|
||
| #### AD Tests with Specific Backend | ||
|
|
||
| Replace `BackendName` with the failing AD backend from the CI output: | ||
|
|
||
| ```bash | ||
| # ForwardDiff | ||
| julia --project=. -e "ENV[\"GROUP\"] = \"AD\"; ENV[\"AD\"] = \"ForwardDiff\"; using Pkg; Pkg.test()" | ||
| # ReverseDiff | ||
| julia --project=. -e "ENV[\"GROUP\"] = \"AD\"; ENV[\"AD\"] = \"ReverseDiff\"; using Pkg; Pkg.test()" | ||
| # Enzyme (may fail on some systems - this is expected) | ||
| julia --project=. -e "ENV[\"GROUP\"] = \"AD\"; ENV[\"AD\"] = \"Enzyme\"; using Pkg; Pkg.test()" | ||
| # Mooncake | ||
| julia --project=. -e "ENV[\"GROUP\"] = \"AD\"; ENV[\"AD\"] = \"Mooncake\"; using Pkg; Pkg.test()" | ||
| ``` | ||
|
|
||
| #### Full Test Suite | ||
|
|
||
| ```bash | ||
| julia --project=. -e "using Pkg; Pkg.test()" | ||
| ``` | ||
|
|
||
| ### CI Test Matrix | ||
|
|
||
| Our CI runs tests with the following configurations: | ||
|
|
||
| - **Interface tests**: Core functionality tests (GROUP=Interface) | ||
| - **AD tests**: Automatic differentiation tests with multiple backends (GROUP=AD, AD={ForwardDiff,ReverseDiff,Enzyme,Mooncake}) | ||
|
|
||
| ### Important Notes | ||
|
|
||
| 1. **Always use `--project=.`**: This ensures Julia uses the correct project environment with the right dependencies. | ||
|
|
||
| 2. **Environment variables matter**: The `GROUP` and `AD` environment variables control which tests run, matching the CI configuration. | ||
| 3. **Enzyme tests may fail**: Due to system compatibility issues, Enzyme tests may fail on some machines. This is expected and not a blocker for development. | ||
| 4. **Test timing**: | ||
|
|
||
| + Interface tests: ~7.5 minutes | ||
| + AD tests (single backend): ~1.5 minutes | ||
| + Full test suite: 20+ minutes | ||
|
|
||
| ## Code Formatting | ||
|
|
||
| We use JuliaFormatter.jl for consistent code formatting: | ||
|
|
||
| ```bash | ||
| # Install formatter (one-time setup) | ||
| julia --project=. -e "using Pkg; Pkg.add(\"JuliaFormatter\")" | ||
| # Format code | ||
| julia --project=. -e "using JuliaFormatter; format(\".\")" | ||
| ``` | ||
|
|
||
| ## Documentation | ||
|
|
||
| To build documentation locally: | ||
|
|
||
| ```bash | ||
| julia --project=docs -e "using Pkg; Pkg.develop(PackageSpec(path=pwd())); Pkg.instantiate(); include(\"docs/make.jl\")" | ||
| ``` | ||
|
|
||
| ## Validation Checklist | ||
|
|
||
| Before submitting a PR, please ensure: | ||
|
|
||
| - [ ] Package loads without errors: `julia --project=. -e "using Bijectors"` | ||
| - [ ] Interface tests pass: `julia --project=. -e "ENV[\"GROUP\"] = \"Interface\"; using Pkg; Pkg.test()"` | ||
| - [ ] Code is formatted: `julia --project=. -e "using JuliaFormatter; format(\".\")"` | ||
| - [ ] Basic functionality works (see test scenarios below) | ||
|
|
||
| ### Basic Test Scenarios | ||
|
|
||
| You can manually verify basic functionality: | ||
|
|
||
| ```julia | ||
| using Bijectors, Distributions | ||
| # Test 1: Basic bijector for LogNormal | ||
| d = LogNormal() | ||
| b = bijector(d) | ||
| x = 1.0 | ||
| y = b(x) # Should return 0.0 | ||
| # Test 2: Inverse transformation | ||
| x_reconstructed = inverse(b)(y) # Should return 1.0 | ||
| # Test 3: Log absolute determinant of Jacobian | ||
| logjac = logabsdetjac(b, x) | ||
| # Test 4: Combined transformation | ||
| z, logabsdet = with_logabsdet_jacobian(b, x) | ||
| ``` | ||
|
|
||
| ## Getting Help | ||
|
|
||
| If you need help: | ||
|
|
||
| - Join the #turing channel on [Julia Slack](https://julialang.org/slack/) | ||
| - Ask questions on [Julia Discourse](https://discourse.julialang.org) | ||
| - Open a GitHub issue for bugs or feature requests | ||
|
|
||
| Thank you for contributing to Bijectors.jl! | ||
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
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.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to specify using the version 1 formatter.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated the CONTRIBUTING.md to specify JuliaFormatter version 1 in the installation command using
PackageSpec(name="JuliaFormatter", version="1"). (62fa9e8)