Development

Initial setup

Fork the repository on Github, then clone the fork:

git clone git@github.com:YourGithubUserName/rbartpackages.git
cd rbartpackages

Install R and uv (for example, with Homebrew do brew install r uv). The bartMachine R package additionally needs a Java toolchain (e.g. brew install temurin, then R CMD javareconf). Then run

make setup

to set up the Python and R environments. (Note: at the time of writing, the R installation instructions for ubuntu miss a sudo apt install r-base-dev at the end.)

The Python environment is managed by uv. To run commands that involve the Python installation, do uv run <command>. The R environment (managed by renv) is automatically active when you use R in the project directory; the wrapped R packages are pinned in renv.lock and listed in DESCRIPTION.

Contributing

To contribute code changes to the main repository, create a pull request from your fork to the main repo.

Pre-defined commands

Development commands are defined in a makefile. Run make without arguments to list the targets. All commands that simply invoke a tool with the right command line arguments use the ARGS variable to add extra arguments, for example:

make tests ARGS='-k test_gbart_fit'

Documentation

To build the documentation for the current working copy, do

make docs

Building the API reference imports the wrappers, so it needs the R packages installed. To debug the build, do make docs SPHINXOPTS='--fresh-env --pdb'.

Unit tests

The typical workflow to debug new changes is to first run all tests with

make tests

Then, if some tests fail, use pytest directly to run and debug only the relevant tests, e.g. with uv run pytest --lf --sw --pdb. Tests that need an R package which is not installed are skipped rather than failing.

Debugging dependencies

To debug tests that fail with old versions of dependencies, piggyback on the predefined make target using ARGS:

make tests-old ARGS='-n0 -k test_gbart_fit'

Where -n0 disables test parallelization.

Benchmarks

The benchmarks are managed with asv. The basic asv workflow is:

uv run asv run      # run and save benchmarks on main branch
uv run asv publish  # create html report
uv run asv preview  # start a local server to view the report

The most useful command during development is

make asv-quick ARGS='--bench <pattern>'

This runs only benchmarks whose name matches <pattern>, only once, within the working copy and current Python environment.