Contributor's Guide#
Getting Started#
These contributing guidelines should be read by software developers wishing to contribute code or documentation changes into WOMBAT, or to push changes upstream to the main WISDEM/WOMBAT repository.
Create a fork of WOMBAT on GitHub
Clone your fork of the repository
git clone -b develop https://github.com/<your-GitHub-username>/WOMBAT.git
Move into the WOMBAT source code directory
cd WOMBAT/
Install WOMBAT in editable mode with the appropriate developer tools
".[dev]"
is for the linting, autoformatting, testing, and code checking tools".[docs]"
is for the documentation building tools. Ideally, developers should also be contributing to the documentation, and therefore checking that the documentation builds locally.
pip install -e ".[dev,docs]"
Turn on the automated linting and code checking tools. Pre-commit runs at the commit level, and will only check files that have been modified and staged (e.g.,
git add <your-changed-file>
).pre-commit install
Keeping your fork in sync with WISDEM/WOMBAT#
The "main" WOMBAT repository is regularly updated with ongoing research at NREL and beyond. After creating and cloning your fork from the previous section, you might be wondering how to keep it up to date with the latest improvements.
Please note that the below process may introduce merge conflicts with your work, and this does not provide guidance about how to deal with those conflicts. Here is a good resource for working on merge conflicts that will inevitably arise in development work.
Ensure you're in the WOMBAT folder. This may look different depending on your operating system.
cd /your/path/to/WOMBAT/
If you haven't already, add WISDEM/WOMBAT as the "upstream" location (or whichever naming convention you prefer).
git remote add upstream https://github.com/WISDEM/WOMBAT.git
To find the name you've given WISDEM/WOMBAT again, you can simply run the following to display all the remote sources you're tracking.
git remote -v
Fetch all the remote changes
git fetch --all
Sync the upstream (WISDEM) changes
# If there was a new release this will need to be updated git checkout main git pull upstream main # Most common branch to bring up to speed git checkout develop git pull upstream develop
Bring your feature branch up to date with the latest changes, assuming you started from the develop branch.
git checkout feature/your_contribution git merge develop
Issue Tracking#
New feature requests, changes, enhancements, non-methodology features, and bug reports can be filed as new issues in the Github.com issue tracker at any time. Please be sure to fully describe the issue.
For other issues, please email rob.hammond@nrel.gov.
Issue Submission Checklist#
Does the issue already exist? Yes: If you find your issue already exists, make relevant comments and add your reaction. Use a reaction in place of a "+1" comment:
👍 - upvote
👎 - downvote
Is this an individual bug report or feature request?
Can the bug be easily reproduced?
Be sure to include enough details about your setup and the issue you've encountered
Simplify as much of the code as possible to better isolate the problem
Will someone else understand the issue or change requested given the information provided?
Repository#
The WOMBAT repository is hosted on Github, and located here: WISDEM/WOMBAT
This repository is organized using a modified git-flow system. Branches are organized as follows:
main: Stable release version. Must have good test coverage and may not have all the newest features.
develop: Development branch which contains the newest features. Tests must pass, but code may be unstable.
feature/xxx: Feature ranch from develop, should reference a GitHub issue number.
fix/xxx: Bug fix branch from develop, should reference a GitHub issue number. Can be based off main if this is a necessary patch.
To work on a feature, please fork WOMBAT first and then create a feature branch in your own fork. Work out of this feature branch before submitting a pull request.
Be sure to periodically synchronize the upstream develop branch into your feature branch to avoid conflicts in the pull request.
When your branch is ready, make a pull request to WISDEM/WOMBAT through the GitHub web interface.
Coding Style#
This code uses a pre-commit
workflow where code styling and linting is taken care of when a user
commits their code. Specifically, this code utilizes black
for automatic formatting (line
length, quotation usage, hanging lines, etc.), isort
for automatic import sorting, mypy
for typing, and ruff
for linting.
To activate the pre-commit
workflow, the user must install the developer version as outlined in
the getting started section, and run the following line:
pre-commit install
Documentation#
Documentation is written primarily using Markdown, with some components written in
ReStructured Text, and is located in the WOMBAT/docs/
directory. Additionally, all method and class
documentation is written as NumPy-style docstrings in the code itself, with some aspects documented
inline as needed.
If the docs
extras haven't already been installed, be sure to do so before you attempt to build
the documentation site.
# Navigate to the top level directory of the repository
cd WOMBAT/
# Install the additional dependencies
pip install -e ".[docs]"
Now, run the build command as follows.
# Build the docs
jupyter-book build docs
Testing#
All code should be paired with a corresponding unit, regression, or integration test written with the pytest framework.
To run the tests you can use any of the following commands, depending on your needs.
All the tests and check for test coverage:
pytest --cov=WOMBAT
All the tests:
pytest
Pull Request#
Pull requests must be made for all changes. Most pull requests should be made against the develop branch unless patching a bug that needs to be addressed immediately, and only core developers should make pull requests to the main branch.
All pull requests, regardless of the base branch, must include updated documentation and pass all tests. In addition, code coverage should not be significantly negatively affected.
Scope#
Encapsulate the changes of one issue, or multiple if they are highly related. Three small pull requests is greatly preferred over one large pull request. Not only will the review process be shorter, but the review will be more focused and of higher quality, benefitting the author and code base. Be sure to write a complete description of these changes in the pull request body.
Tests#
All tests must pass. Pull requests will be rejected or have changes requested if tests do not pass, or cannot pass with changes. Tests are automatically run through Github Actions for any pull request or push to the main or develop branches, but should also be run locally before submission.
Test Coverage#
The testing framework described below will generate a coverage report from the tests run through GitHub Actions. Please ensure that your work is fully covered by running them locally with the coverage report enabled.
Documentation#
Include any relevant changes to inline documentation, docstrings, and any of the documentation files
located in WOMBAT/docs/
. Pull requests will not be accepted until these changes are complete.
Be sure to build the documentation and run the examples in the CLI locally prior to submission.
Changelog#
All changes must be documented appropriately in CHANGELOG.md in the [Unreleased] section.
Release Process#
This section is a reference for WOMBAT's maintainers to keep processes largely consistent over time, regardless of who the core developers are.
Bump version number and metadata in
WOMBAT/__init__.py
Bump version numbers of any dependencies in
setup.py
. Be sure to separate to keep dependencies separated by what they are required for (see theproject.optional-dependencies
section ofpyproject.toml
)Update the changelog at
WOMBAT/CHANGELOG.md
, changing the "UNRELEASED" section to the new version and the release date (e.g. "[2.3 - 2022-01-18]").Make a pull request into develop with these updates, and be sure to follow the guide in Pull Requests.
Merge develop into main through the git command line
git checkout main
git merge develop
git push
Tag the new release version:
git tag -a v1.2.3 -m "Tag message for v1.2.3" git push origin v1.2.3
The above process will trigger the
.github/workflows/python-publish-test.yml
GitHub Action that builds the package and pushes it to Test PyPI. If this is successful, you can move to the next step, otherwise the errors from the action should be addressed, and the tag should be deleted, then recreated after the fix is published.Deploying a Package to PyPi
The repository is equipped with a GitHub Action to build and publish new versions to PyPI. A maintainer can invoke this workflow by creating a new release on GitHub that corresponds to the created tag in the previous step.
The action is defined in
.github/workflows/python-publish.yml
.