Pull Request Review Process¶
Pull Request Author Guidelines¶
- PRs (Pull Requests) should be modular and as targeted as possible.
- PRs for new features should focus on a minimum viable product. Embellishments can be added in additional PRs.
- PRs should not contain unrelated changes as much as possible. Open a new PR for unrelated changes.
- Commits for PRs should be succinct but descriptive. Try to avoid trivial “update file.py” type commit messages.
- When a PR is ready for review, apply the “ready to review” label. At this point, additional changes should only be made if necessary or as part of the review. Let the team know it’s ready so someone can volunteer to review it.
The steps below do not necessarily need to be followed precisely in this order. Not all PRs will require all steps and some will not require an in-depth review at all (e.g., minor documentation updates).
Step 0: Set up a local PlantCV environment for the branch being reviewed¶
- Read through the steps of the contributing guide.
- Email email@example.com to get added as a contributor.
- Install PlantCV from the source code
- Activate the plantcv environment, then change the current directory to the location where plantcv is installed. Then, run
git checkout <pull-request-branch>to navigate to the branch to be reviewed.
Step 1: Familiarize yourself with the PR¶
Before starting the review it is convenient to understand the type of update and/or the intended functionality.
- Inspect the files changed.
- Read the updated documentation. To compile the documentation locally, run:
mkdocs serve --theme readthedocsin a local terminal with an activated PlantCV environment (Testing the documentation is done in step 4).
Step 2: Prepare materials for the review¶
- Maintain a shared team directory for reviews (data and notebooks) in the PlantCV Google Drive. Email firstname.lastname@example.org from a Gmail account to have the team share access to this Google Drive.
- Find appropriate sample data (either already in the shared directory or new data), ideally not data used by the PR author.
- Update your local development environment to use the PR branch.
- Create a new Jupyter notebook named
Step 3: Review the PR functionality¶
Read the PR documentation and use your intuition to run relevant parts of PlantCV to test the PR code. For example, test upstream and downstream functionality to ensure the new function works well with other steps in a workflow. Try more than one data type if a function works on both RGB and grayscale. Potential findings to report to the PR author and/or to propose fixes for:
- Errors: the code does not work as written or does not function as intended (on new data for example).
- Process: in using the code, you think the process can be simplified or made clearer (e.g., fewer inputs, renamed arguments, etc.).
- Documentation: both the documentation and docstrings should match the code in terms of syntax and process.
Iterate as needed.
Step 4: Review the tests¶
- Do all tests pass?
- Running relevant tests locally:
py.test --cov=plantcv -k test_name_or_keywordsin a local terminal with an activated PlantCV environment. If you get an error, make sure pytest-cov is installed in your environment (e.g.
conda install pytest-cov)
- Running relevant tests locally:
- Does coverage remain at 100%?
- Do any new or modified tests accurately test the PR code?
Propose updates as needed.
Step 5: Test the documentation¶
Reviewing the documentation code is important, but compiling the documentation locally ensures that the resulting pages are rendered correctly. The easiest way to view the documentation live on your local machine is to run:
mkdocs serve --theme readthedocs in a local terminal with an activated PlantCV environment
Some common oversights that are hard to see in the code but easy to detect in the compiled documentation:
- New pages are not added to the table of contents
plantcv/mkdocs.yml(mkdocs will display a warning when you run the command above).
- Typos in page or image filenames (mkdocs will often display a warning, or the image may appear as a broken link).
- Typos in formatting markup lead to incorrectly displayed styling (e.g., not closing bold or italics, not having a blank line before a bulleted or numbered list, etc.).
- Changes to function input/output signatures or new functions should be added to updating.md.
- Link out to source code at the end of a documentation page.
Step 6: Review the code¶
Once the PR is working as intended, review the code itself for potential improvements. Some common types of improvements to suggest:
- Uniform style (linting): Most IDEs, including PyCharm and VScode, will indicate when the code does not match the community style guides laid out in PEP8. The command-line tool
flake8can also be used if an IDE that supports these checks cannot be used. A report from deepsource.io is also generated automatically for each PR.
- Code simplification: Any reorganization that makes the code more succinct, readable, maintainable, etc. In particular, complex, nested logical blocks and for loops increase code complexity (and testing demand). The deepsource.io report may also included automated suggestions for code simplification.
- Algorithmic improvement: Could potentially be an alternate approach that is significantly faster or more user-friendly.
- Scope: Check any new code and test data in the
plantcv/testsmodule (no need to fix out-of-scope linting issues).
- Documentation: The documentation is more flexible, but try to avoid very long lines. Markdown will automatically connect consecutive lines that do not have a blank line between them. Crop down images in documentation. In general, resizing such that the image width is equal to 400px will result in a documentation page that is still mobile friendly.
- Unnecessary New Test Data: If new test data was added, check if an existing test data could be used to save memory.
Communicate via GitHub with PR author(s) and directly contribute changes to the PR branch as appropriate until it is ready to merge.
Step 7: Approve the PR¶
Once you and the PR author have refined the PR and it is ready to merge, the PR can be approved. It’s important that the PR not be approved until it is actually ready to merge. Please add the name of the Jupyter notebook used for review, in the shared directory (but not a link to it) to the PR approval.