Note
This repo is continously updating with more tools. Any contribution is welcome.
To ensure high standards in engineering projects, we offer a standardized template specifically designed for open-source Python research projects. This template is an excellent choice if you:
- Want to facilitate seamless collaboration and extension of your project by other researchers.
- Aim to bridge communication gaps among collaborators effectively.
- Seek to make rapid iterations with assurance that small code modifications won’t disrupt the overall project.
- Wish to reduce the frequency of frustrating runtime errors during experiments.
Here's a clearer and more straightforward guideline of the steps for working with your codebase. If working in a small group or working on a simple project, some of the steps can be skipped.
-
Create Issue
Before starting, open a new issue in the repository detailing what you plan to implement. Assign the issue to yourself.
-
Sync Repo
Update your local repository to match the latest version of the remote repository.
-
Create Branch
Create a new branch for your task. Name it appropriately based on the type of task, such as
feature/feature-name
,bug/bug-name
, orexp/exp-name
. -
Implement Code
Work on your task and make necessary changes to the codebase.
-
Test Locally
Run tests using tools like mypy, pytest, and pre-commit. Ensure all tests pass before proceeding.
-
Change Commit
Add and commit your changes to the branch, then push the branch to the repository.
-
Create PR
Open a Pull Request (PR) for the branch you've pushed.
-
Link PR to Issue
In your PR, include "Closes #ISSUE_NUM" to link it to the original issue.
-
Pass Continuous Integration
Ensure all GitHub Actions checks pass. If they fail, revise your code based on the errors reported.
-
Review PR Checklist
Verify that all items in the PR checklist are completed, such as updating documentation or adding package requirements.
-
Ask for Code Review
Invite a colleague to review your PR. One approved, Use the "Squash and Merge" option to merge your PR, ensuring a clean commit history.
-
Troubleshooting
If you break down the commit history or main branch, contact the repository owner for assistance with
rebase
or other needed actions.
The current project template supports the final package release of our codebase.
Template/
│
├── .github/ # Contains GitHub related files like workflows
├── docs/ # Documentation for the project
├── src/ # Main package directory
├── stubs/ # Type stubs for static typing (for mypy strict mode)
├── tests/ # Test scripts and resources
│
├── .gitignore # Specifies untracked files to ignore
├── .pre-commit-config.yaml # Configurations for pre-commit hooks
├── poetry.lock # Lock file generated by poetry for dependencies
├── pyproject.toml # Project metadata and tool configurations
An issue typically describes a new feature (feature
), fixing an old bug (bug
), launching a group of experiments (exp
), or refactoring part of the code (refactor
). Using different issue templates for different issues.
A PR typically implements the content mentioned in one issue.
Notice about the development:
- When creating an issue, assign the responsible member for fixing that if possible
- When creating a PR, make sure you uses
feature/feature-name
,bug/bug-name
,exp/exp-name
for its branch - When finishing one PR, make sure all the github action is passed and all the checks are done.
- When merging one PR, make sure using
squash and merge
instead ofmerge a pull request
. - Avoid making any direct commit to the
main
branch and try to avoid any--force
push to any branch unless you are pretty sure about that.
-
Tools
-
static type checking (
mypy
) -
dynamic type checking (
beartype
)
-
-
Guidelines
- Run
mypy --strict ./
under the root of the current repo to test the static type.
- Run
-
Tools
- testing code components based on testing function (
pytest
)
- testing code components based on testing function (
-
Guidelines
- Run
pytest
under the root of the current repo to check unit test results.
- Run
-
Tools
- code spell checking (
codespell
)
- code spell checking (
-
Guidelines
- Commonly need to ignore part of the files in the repository like
/data
.
- Commonly need to ignore part of the files in the repository like
-
Tools
-
code formatting (
prettier
) -
import package sorting (
isort
) -
ipynb output clear (
nbstripout
) -
code bug checking and formatting (
ruff
)
-
-
Guidelines
-
Run
python -m pip install pre-commit
to installpre-commit
-
Run
pre-commit install
to allow hooking pre-commit with anygit commit
commands.
-
-
Tools
- We utilize
poetry
to support the dependency requirements. Dependency for different usage of the repo can be defined separately inpyproject.toml
.
- We utilize
-
Guidelines
-
Run
pip install poetry
to finish the installation of poetry. -
Create
conda environment
with a specified Python version -
Run
poetry install
to install required dependencies.
-
I welcome all kinds of contributions, e.g. adding more tools, better practices, and discussion on trade-offs.