All kinds of contributions are welcome, including but not limited to the following.
- Fixes (typo, bugs)
- New features and components
Contents
- Workflow
- Code style
- fork and pull the latest mmocr
- checkout a new branch (do not use main branch for PRs)
- commit your changes
- create a PR
Note
- If you plan to add some new features that involve large changes, it is encouraged to open an issue for discussion first.
- If you are the author of some papers and would like to include your method to mmocr, please let us know (open an issue or contact the maintainers). We will much appreciate your contribution.
- For new features and new modules, unit tests are required to improve the code's robustness.
The official public repository holds only one branch with an infinite lifetime: main
The main branch is the main branch where the source code of HEAD always reflects a state with the latest development changes for the next release.
Feature branches are used to develop new features for the upcoming or a distant future release.
All new developers to MMOCR need to follow the following steps:
-
Fork the repo on GitHub or GitLab to your personal account. Click the
Fork
button on the project page. -
Clone your new forked repo to your computer.
git clone https://github.com/<your name>/mmocr.git
- Add the official repo as an upstream:
git remote add upstream https://github.com/open-mmlab/mmocr.git
Whenever you want to update your fork with the latest upstream changes, you need to fetch the upstream repo's branches and latest commits to bring them into your repository:
# Fetch from upstream remote
git fetch upstream
# Update your main branch
git checkout main
git rebase upstream/main
git push origin main
-
Create an issue on github
-
Create a feature branch
-
git checkout -b feature/iss_<index> main # index is the issue index on github above
Develop your new feature and test it to make sure it works well, then commit.
Please run
pre-commit run --all-files
pytest tests
and fix all failures before every git commit.
git commit -m "fix #<issue_index>: <commit_message>"
- Make sure to link your pull request to the related issue. Please refer to the instructon
# fetch from upstream remote. i.e., the official repo
git fetch upstream
# update the main branch of your fork
git checkout main
git rebase upstream/main
git push origin main
# update the <your_feature_branch> branch
git checkout <your_feature_branch>
git rebase main
# solve conflicts if any and Test
git checkout <your_feature_branch>
git push origin <your_feature_branch>
Go to the page for your fork on GitHub, select your new feature branch, and click the pull request button to integrate your feature branch into the upstream remote’s develop branch.
If PR is not accepted, pls follow steps above till your PR is accepted.
git branch -d <your_feature_branch>
git push origin :<your_feature_branch>
We adopt PEP8 as the preferred code style.
We use the following tools for linting and formatting:
Style configurations of yapf and isort can be found in setup.cfg.
We use pre-commit hook that checks and formats for flake8
, yapf
, isort
, trailing whitespaces
,
fixes end-of-files
, sorts requirments.txt
automatically on every commit.
The config for a pre-commit hook is stored in .pre-commit-config.
After you clone the repository, you will need to install initialize pre-commit hook.
pip install -U pre-commit
From the repository folder
pre-commit install
If you are facing issue when installing markdown lint, you may install ruby for markdown lint by following
# install rvm
curl -L https://get.rvm.io | bash -s -- --autolibs=read-fail
# set up environment
# Note that you might need to edit ~/.bashrc, ~/.bash_profile.
rvm autolibs disable
# install ruby
rvm install 2.7.1
After this on every commit check code linters and formatter will be enforced.
Before you create a PR, make sure that your code lints and is formatted by yapf.
We follow the Google C++ Style Guide.