|
| 1 | +# Contribute Code |
| 2 | + |
| 3 | +You encourage and appreciate researchers and developers to contribute to project **PPViT**. |
| 4 | + |
| 5 | +This document explains our workflow and working style. |
| 6 | + |
| 7 | +## Workflow |
| 8 | + |
| 9 | +PPViT uses this [Git branching model](http://nvie.com/posts/a-successful-git-branching-model/). You can follow the listed steps for common contributions. |
| 10 | + |
| 11 | +### 1. Fork the repo |
| 12 | + |
| 13 | + Please **file `Pull Requests` from your fork**. |
| 14 | + |
| 15 | + To make a fork, just head over to our GitHub repo page and click the ["Fork"](https://help.github.com/articles/fork-a-repo/) button. |
| 16 | + |
| 17 | +### 2. Clone the repo |
| 18 | + |
| 19 | + To make a copy of your fork to your local env: |
| 20 | + |
| 21 | + ```bash |
| 22 | + $ git clone https://github.com/your-github-account/PPViT |
| 23 | + $ cd PPViT |
| 24 | + ``` |
| 25 | + |
| 26 | +### 3. Create local `feature` branch |
| 27 | + |
| 28 | + For daily works like adding a new feature or fixing a bug, open a `feature` branch based on `develop` branch before coding: |
| 29 | + |
| 30 | + ```bash |
| 31 | + $ git checkout develop |
| 32 | + $ git checkout -b feature |
| 33 | + ``` |
| 34 | + wher `feature` can be replaced with the name of your feature you are working on. |
| 35 | + |
| 36 | +### 4. Commit |
| 37 | + |
| 38 | + Commit your code to the local repository **during and after** your coding. |
| 39 | + |
| 40 | + ```shell |
| 41 | + $ git add -A |
| 42 | + $ git commit -m “message” |
| 43 | + ``` |
| 44 | + |
| 45 | +### 5. Test |
| 46 | + |
| 47 | + - We encourage writing `unittest` to test your class and method. |
| 48 | + - Please test and report model performance on related datasets before you start to merge. |
| 49 | + |
| 50 | +### 6. Keep pulling |
| 51 | + |
| 52 | + An experienced Git user pulls from the official repo often -- daily or even hourly, so they notice conflicts with others work early, and it's easier to resolve smaller conflicts. |
| 53 | + |
| 54 | + ```bash |
| 55 | + $ git remote add upstream https://github.com/xperzy/PPViT |
| 56 | + $ git pull upstream develop |
| 57 | + ``` |
| 58 | + |
| 59 | +### 7. Push and file a `Pull Request` |
| 60 | + |
| 61 | + 1. **Push** your local work into your forked repo: |
| 62 | + |
| 63 | + ```bash |
| 64 | + $ git push origin my-cool-stuff |
| 65 | + ``` |
| 66 | + |
| 67 | + The push allows you to create a pull request, requesting owners of this [official repo](https://github.com/BR-IDL/PaddleViT) to pull your change into the official one. |
| 68 | + |
| 69 | + 2. To create a `Pull Request`, please follow [these steps](https://help.github.com/articles/creating-a-pull-request/). |
| 70 | + |
| 71 | + If your change is for fixing an issue, please write ["Fixes <issue-URL>"](https://help.github.com/articles/closing-issues-using-keywords/) in the description section of your pull request. Github would close the issue when the owners merge your pull request. |
| 72 | + |
| 73 | + Please remember to specify some reviewers for your pull request. If you don't know who are the right ones, please follow Github's recommendation. |
| 74 | + |
| 75 | +### 8. Delete local and remote `feature` branches |
| 76 | + |
| 77 | + After merging into `develop` branch successfully, delete your `feature` branch. |
| 78 | + To keep your local workspace and your fork clean, you might want to remove merged branches: |
| 79 | + |
| 80 | + ```bash |
| 81 | + $ git push origin :my-cool-stuff |
| 82 | + $ git checkout develop |
| 83 | + $ git pull upstream develop |
| 84 | + $ git branch -d my-cool-stuff |
| 85 | + ``` |
| 86 | + |
| 87 | +## Code Review |
| 88 | + |
| 89 | +- Please feel free to ping your reviewers by sending them the URL of your pull request via IM or email. |
| 90 | + |
| 91 | +- Please answer reviewers' every comment. If you are to follow the comment, please write "Done"; please give a reason otherwise. |
| 92 | +
|
| 93 | +- If you don't want your reviewers to get overwhelmed by email notifications, you might reply their comments by [in a batch](https://help.github.com/articles/reviewing-proposed-changes-in-a-pull-request/). |
| 94 | + |
| 95 | +- Reduce the unnecessary commits. Some developers commit often. It is recommended to append a sequence of small changes into one commit by running `git commit --amend` instead of `git commit`. |
| 96 | + |
| 97 | +## Coding Standard |
| 98 | + |
| 99 | +### Code Style |
| 100 | + |
| 101 | +Our Python code follows the [PEP8 language guide](https://zh-google-styleguide.readthedocs.io/en/latest/google-python-styleguide/python_language_rules/) and [PEP8 style guide](https://zh-google-styleguide.readthedocs.io/en/latest/google-python-styleguide/python_style_rules/). |
| 102 | + |
| 103 | +### Use Pylint |
| 104 | + |
| 105 | +[Pylint](http://pylint.pycqa.org/en/latest/) is a Python code analysis tool that analyzes errors in Python code and finds code that does not meet coding style standards and has potential problems. |
| 106 | + |
| 107 | +### Comments and Annotations |
| 108 | + |
| 109 | +To make it easier for others to use and generate online documents, please include a docstring for each function on each class method. |
| 110 | + |
| 111 | +### Unit Tests |
| 112 | + |
| 113 | +Please remember to add related unit tests. |
| 114 | + |
| 115 | +- For Python code, please use [Python's standard `unittest` package](http://pythontesting.net/framework/unittest/unittest-introduction/). |
| 116 | +
|
| 117 | +Try to have unit tests for each function on each class method. |
| 118 | + |
0 commit comments