|
| 1 | +# [Contribution Guidelines](@id contributing-overview) |
| 2 | + |
| 3 | +Welcome to the contribution guidelines for `RxInfer.jl`. Here you'll find detailed instructions on how to contribute effectively to the project. |
| 4 | + |
| 5 | +## Reporting bugs |
| 6 | + |
| 7 | +If you encounter any bugs while using the software, please report them via [GitHub issues](https://github.com/reactivebayes/RxInfer.jl/issues). To ensure efficient bug resolution, please provide comprehensive and reproducible bug reports. Include details such as the versions of Julia and `RxInfer` you're using, along with a concise description of the issue. Additionally, attach relevant code snippets, test cases, screenshots, or any other pertinent information that could aid in replicating and addressing the problem. |
| 8 | + |
| 9 | +### Nightly Julia status |
| 10 | + |
| 11 | +Check the badge below to see if `RxInfer` can be installed on a Julia nightly version. A failing badge may indicate issues with `RxInfer` or its dependencies. Click on the badge to access the latest evaluation report. |
| 12 | + |
| 13 | +[](https://JuliaCI.github.io/NanosoldierReports/pkgeval_badges/report.html) |
| 14 | + |
| 15 | +## Suggesting features |
| 16 | + |
| 17 | +We encourage proposals for new features. Before submitting a feature request, consider the following: |
| 18 | + |
| 19 | +- Determine if the feature necessitates changes to the core `RxInfer` code. If not, such as adding a factor node for a specific application, consider local extensions in your script/notebook or creating a separate repository for your extensions. |
| 20 | +- For feature implementations requiring significant changes to the core `RxInfer` code, open a [GitHub issue](https://github.com/reactivebayes/RxInfer.jl/issues) to discuss your proposal before proceeding with implementation. This allows for thorough deliberation and avoids investing time in features that may be challenging to integrate later on. |
| 21 | + |
| 22 | +## Contributing code |
| 23 | + |
| 24 | +### Installing RxInfer |
| 25 | + |
| 26 | +For development purposes, it's recommended to use the `dev` command from the Julia package manager to install `RxInfer`. Use your fork's URL in the dev command to work on your forked version. For example: |
| 27 | + |
| 28 | +``` |
| 29 | +] dev git@github.com:your_username/RxInfer.jl.git |
| 30 | +``` |
| 31 | + |
| 32 | +The `dev` command clones `RxInfer` to `~/.julia/dev/RxInfer`. All local changes to `RxInfer` code will be reflected in imported code. |
| 33 | + |
| 34 | +!!! note |
| 35 | + It is also might be useful to install [Revise.jl](https://github.com/timholy/Revise.jl) package as it allows you to modify code and use the changes without restarting Julia. |
| 36 | + |
| 37 | +### Core dependencies |
| 38 | + |
| 39 | +`RxInfer.jl` depends heavily on the core packages `ReactiveMP.jl`, `GraphPPL.jl`, and `Rocket.jl`. Ensure `RxInfer.jl` is updated whenever any of these packages undergo major updates or API changes. While making changes to `RxInfer.jl`, developers are advised to use the `dev` command for these packages as well. Note that standard Julia testing utilities ignore the local development environment and test the package with the latest released versions of core dependencies. Refer to the Makefile section below to learn how to test `RxInfer.jl` with locally installed core dependencies. |
| 40 | + |
| 41 | +### Committing code |
| 42 | + |
| 43 | +We use the standard [GitHub Flow](https://guides.github.com/introduction/flow/) workflow where all contributions are added through pull requests. To contribute: |
| 44 | +- [Fork](https://guides.github.com/activities/forking/) the repository |
| 45 | +- Commit your contributions to your fork |
| 46 | +- Create a pull request on the `main` branch of the `RxInfer` repository. |
| 47 | + |
| 48 | +Before opening a pull request, ensure all tests pass without errors. Additionally, ensure all examples (found in the `/examples/` directory) run succesfully. |
| 49 | + |
| 50 | +!!! note |
| 51 | + Use `make test`, `make examples` and `make docs` commands to verify that all tests, examples, and documentation build correctly. See the `Makefile` section below for detailed command descriptions. |
| 52 | + |
| 53 | +### Style conventions |
| 54 | + |
| 55 | +We use the default [Julia style guide](https://docs.julialang.org/en/v1/manual/style-guide/index.html). There are a couple of important points modifications to the Julia style guide to take into account: |
| 56 | + |
| 57 | +- Use 4 spaces for indentation |
| 58 | +- Type names use `UpperCamelCase`. For example: `AbstractFactorNode`, `RandomVariable`, etc.. |
| 59 | +- Function names are `lowercase` with underscores, when necessary. For example: `activate!`, `randomvar`, `as_variable`, etc.. |
| 60 | +- Variable names and function arguments use `snake_case` |
| 61 | +- The name of a method that modifies its argument(s) must end in `!` |
| 62 | + |
| 63 | +!!! note |
| 64 | + The `RxInfer` repository contains scripts to automatically format code according to our guidelines. Use `make format` command to fix code style. This command overwrites files. Use `make lint` to run a linting procedure without overwriting the actual source files. |
| 65 | + |
| 66 | +### Unit tests |
| 67 | + |
| 68 | +We use the test-driven development (TDD) methodology for `RxInfer` development. Aim for comprehensive test coverage, ensuring tests cover each piece of added code. |
| 69 | + |
| 70 | +All unit tests are located in the `/test/` directory. The `/test/` directory follows the structure of the `/src/` directory. Each test file should have the following filename format: `*_tests.jl`. Some tests are also present in `jldoctest` docs annotations directly in the source code. |
| 71 | +See [Julia's documentation](https://docs.julialang.org/en/v1/manual/documentation/index.html) about doctests. |
| 72 | + |
| 73 | +The tests can be evaluated by running following command in the Julia REPL: |
| 74 | + |
| 75 | +``` |
| 76 | +] test RxInfer |
| 77 | +``` |
| 78 | + |
| 79 | +In addition tests can be evaluated by running following command in the `RxInfer` root directory: |
| 80 | + |
| 81 | +```bash |
| 82 | +make test |
| 83 | +``` |
| 84 | + |
| 85 | +!!! note |
| 86 | + Use `make devtest` to use local `dev`-ed versions of the core packages. |
| 87 | + |
| 88 | +### Makefile |
| 89 | + |
| 90 | +`RxInfer.jl` uses `Makefile` for most common operations: |
| 91 | + |
| 92 | +- `make help`: Shows help snippet |
| 93 | +- `make test`: Run tests, supports extra arguments |
| 94 | + - `make test test_args="distributions:normal_mean_variance"` would run tests only from `distributions/test_normal_mean_variance.jl` |
| 95 | + - `make test test_args="distributions:normal_mean_variance models:lgssm"` would run tests both from `distributions/test_normal_mean_variance.jl` and `models/test_lgssm.jl` |
| 96 | + - `make test dev=true` would run tests while using `dev-ed` versions of core packages |
| 97 | +- `make devtest`: Alias for the `make test dev=true ...` |
| 98 | +- `make docs`: Compile documentation |
| 99 | +- `make devdocs`: Same as `make docs`, but uses `dev-ed` versions of core packages |
| 100 | +- `make examples`: Run all examples and put them in the `docs/` folder if successfull |
| 101 | +- `make devexamples`: Same as `make examples`, but uses `dev-ed` versions of core packages |
| 102 | +- `make lint`: Check codestyle |
| 103 | +- `make format`: Check and fix codestyle |
| 104 | + |
| 105 | +!!! note |
| 106 | + Core packages include `ReactiveMP.jl`, `GraphPPL.jl` and `Rocket.jl`. When using any of the `dev` commands from the `Makefile` those packages must be present in the `Pkg.devdir()` directory. |
0 commit comments