From ff33edaf73d3720f61477c085336d8f2308c63de Mon Sep 17 00:00:00 2001 From: zenggyh1900 Date: Tue, 13 Dec 2022 14:23:57 +0800 Subject: [PATCH] update community --- docs/en/community/contributing.md | 275 ++++++++++++++++++++++++ docs/en/community/contribution_guide.md | 68 ------ docs/en/community/projects.md | 29 +-- docs/en/index.rst | 2 +- 4 files changed, 292 insertions(+), 82 deletions(-) create mode 100644 docs/en/community/contributing.md delete mode 100644 docs/en/community/contribution_guide.md diff --git a/docs/en/community/contributing.md b/docs/en/community/contributing.md new file mode 100644 index 0000000000..bce2e9a914 --- /dev/null +++ b/docs/en/community/contributing.md @@ -0,0 +1,275 @@ +# Contributing to MMEditing + +Welcome to the MMEditing community, we are committed to building a toolbox for cutting-edge image, video and 3D content generation, editing and processing techniques. + +This section introduces following contents: + +- [Pull Request Workflow](#pull-request-workflow) + - [1. fork and clone](#1-fork-and-clone) + - [2. configure pre-commit](#2-configure-pre-commit) + - [3. create a development branch](#3-create-a-development-branch) + - [4. commit the code and pass the unit test](#4-commit-the-code-and-pass-the-unit-test) + - [5. push the code to remote](#5-push-the-code-to-remote) + - [6. create a pull request](#6-create-a-pull-request) + - [7. resolve conflicts](#7-resolve-conflicts) +- [Guidance](#guidance) + - [unit test](#unit-test) + - [document rendering](#document-rendering) +- [Code Style](#code-style) + - [Python](#python) + - [C++ and CUDA](#c-and-cuda) + - [PR Specs](#pr-specs) + +All kinds of contributions are welcomed, including but not limited to + +**Fix bug** + +You can directly post a Pull Request to fix typo in code or documents + +The steps to fix the bug of code implementation are as follows. + +1. If the modification involve significant changes, you should create an issue first and describe the error information and how to trigger the bug. Other developers will discuss with you and propose an proper solution. + +2. Posting a pull request after fixing the bug and adding corresponding unit test. + +**New Feature or Enhancement** + +1. If the modification involve significant changes, you should create an issue to discuss with our developers to propose an proper design. +2. Post a Pull Request after implementing the new feature or enhancement and add corresponding unit test. + +**Document** + +You can directly post a pull request to fix documents. If you want to add a document, you should first create an issue to check if it is reasonable. + +### Pull Request Workflow + +If you're not familiar with Pull Request, don't worry! The following guidance will tell you how to create a Pull Request step by step. If you want to dive into the develop mode of Pull Request, you can refer to the [official documents](https://docs.github.com/en/github/collaborating-with-issues-and-pull-requests/about-pull-requests) + +#### 1. Fork and clone + +If you are posting a pull request for the first time, you should fork the OpenMMLab repositories by clicking the **Fork** button in the top right corner of the GitHub page, and the forked repositories will appear under your GitHub profile. + + + +Then, you can clone the repositories to local: + +```shell +git clone git@github.com:{username}/mmediting.git +``` + +After that, you should ddd official repository as the upstream repository + +```bash +git remote add upstream git@github.com:open-mmlab/mmediting +``` + +Check whether remote repository has been added successfully by `git remote -v` + +```bash +origin git@github.com:{username}/mmediting.git (fetch) +origin git@github.com:{username}/mmediting.git (push) +upstream git@github.com:open-mmlab/mmediting (fetch) +upstream git@github.com:open-mmlab/mmediting (push) +``` + +```{note} +Here's a brief introduction to origin and upstream. When we use "git clone", we create an "origin" remote by default, which points to the repository cloned from. As for "upstream", we add it ourselves to point to the target repository. Of course, if you don't like the name "upstream", you could name it as you wish. Usually, we'll push the code to "origin". If the pushed code conflicts with the latest code in official("upstream"), we should pull the latest code from upstream to resolve the conflicts, and then push to "origin" again. The posted Pull Request will be updated automatically. +``` + +#### 2. Configure pre-commit + +You should configure [pre-commit](https://pre-commit.com/#intro) in the local development environment to make sure the code style matches that of OpenMMLab. **Note**: The following code should be executed under the mmediting directory. + +```shell +pip install -U pre-commit +pre-commit install +``` + +Check that pre-commit is configured successfully, and install the hooks defined in `.pre-commit-config.yaml`. + +```shell +pre-commit run --all-files +``` + + + + + +```{note} +Chinese users may fail to download the pre-commit hooks due to the network issue. In this case, you could download these hooks from gitee by setting the .pre-commit-config-zh-cn.yaml + +pre-commit install -c .pre-commit-config-zh-cn.yaml +pre-commit run --all-files -c .pre-commit-config-zh-cn.yaml +``` + +If the installation process is interrupted, you can repeatedly run `pre-commit run ... ` to continue the installation. + +If the code does not conform to the code style specification, pre-commit will raise a warning and fixes some of the errors automatically. + + + +If we want to commit our code bypassing the pre-commit hook, we can use the `--no-verify` option(**only for temporarily commit**. + +```shell +git commit -m "xxx" --no-verify +``` + +#### 3. Create a development branch + +After configuring the pre-commit, we should create a branch based on the master branch to develop the new feature or fix the bug. The proposed branch name is `username/pr_name` + +```shell +git checkout -b yhc/refactor_contributing_doc +``` + +In subsequent development, if the master branch of the local repository is behind the master branch of "upstream", we need to pull the upstream for synchronization, and then execute the above command: + +```shell +git pull upstream master +``` + +#### 4. Commit the code and pass the unit test + +- MMEditing introduces mypy to do static type checking to increase the robustness of the code. Therefore, we need to add Type Hints to our code and pass the mypy check. If you are not familiar with Type Hints, you can refer to [this tutorial](https://docs.python.org/3/library/typing.html). + +- The committed code should pass through the unit test + + ```shell + # Pass all unit tests + pytest tests + + # Pass the unit test of runner + pytest tests/test_runner/test_runner.py + ``` + + If the unit test fails for lack of dependencies, you can install the dependencies referring to the [guidance](#unit-test) + +- If the documents are modified/added, we should check the rendering result referring to [guidance](#document-rendering) + +#### 5. Push the code to remote + +We could push the local commits to remote after passing through the check of unit test and pre-commit. You can associate the local branch with remote branch by adding `-u` option. + +```shell +git push -u origin {branch_name} +``` + +This will allow you to use the `git push` command to push code directly next time, without having to specify a branch or the remote repository. + +#### 6. Create a Pull Request + +(1) Create a pull request in GitHub's Pull request interface + + + +(2) Modify the PR description according to the guidelines so that other developers can better understand your changes + + + +Find more details about Pull Request description in [pull request guidelines](#pr-specs). + +**note** + +(a) The Pull Request description should contain the reason for the change, the content of the change, and the impact of the change, and be associated with the relevant Issue (see [documentation](https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue) + +(b) If it is your first contribution, please sign the CLA + + + +(c) Check whether the Pull Request pass through the CI + + + +MMEditing will run unit test for the posted Pull Request on different platforms (Linux, Window, Mac), based on different versions of Python, PyTorch, CUDA to make sure the code is correct. We can see the specific test information by clicking `Details` in the above image so that we can modify the code. + +(3) If the Pull Request passes the CI, then you can wait for the review from other developers. You'll modify the code based on the reviewer's comments, and repeat the steps [4](#4-commit-the-code-and-pass-the-unit-test)-[5](#5-push-the-code-to-remote) until all reviewers approve it. Then, we will merge it ASAP. + + + +#### 7. Resolve conflicts + +If your local branch conflicts with the latest master branch of "upstream", you'll need to resolove them. There are two ways to do this: + +```shell +git fetch --all --prune +git rebase upstream/master +``` + +or + +```shell +git fetch --all --prune +git merge upstream/master +``` + +If you are very good at handling conflicts, then you can use rebase to resolve conflicts, as this will keep your commit logs tidy. If you are not familiar with `rebase`, then you can use `merge` to resolve conflicts. + +### Guidance + +#### Unit test + +We should make sure the committed code will not decrease the coverage of unit test, we could run the following command to check the coverage of unit test: + +```shell +python -m coverage run -m pytest /path/to/test_file +python -m coverage html +# check file in htmlcov/index.html +``` + +#### Document rendering + +If the documents are modified/added, we should check the rendering result. We could install the dependencies and run the following command to render the documents and check the results: + +```shell +pip install -r requirements/docs.txt +cd docs/zh_cn/ +# or docs/en +make html +# check file in ./docs/zh_cn/_build/html/index.html +``` + +### Code style + +#### Python + +We adopt [PEP8](https://www.python.org/dev/peps/pep-0008/) as the preferred code style. + +We use the following tools for linting and formatting: + +- [flake8](https://github.com/PyCQA/flake8): A wrapper around some linter tools. +- [isort](https://github.com/timothycrosley/isort): A Python utility to sort imports. +- [yapf](https://github.com/google/yapf): A formatter for Python files. +- [codespell](https://github.com/codespell-project/codespell): A Python utility to fix common misspellings in text files. +- [mdformat](https://github.com/executablebooks/mdformat): Mdformat is an opinionated Markdown formatter that can be used to enforce a consistent style in Markdown files. +- [docformatter](https://github.com/myint/docformatter): A formatter to format docstring. + +Style configurations of yapf and isort can be found in [setup.cfg](../../../setup.cfg). + +We use [pre-commit hook](https://pre-commit.com/) that checks and formats for `flake8`, `yapf`, `isort`, `trailing whitespaces`, `markdown files`, +fixes `end-of-files`, `double-quoted-strings`, `python-encoding-pragma`, `mixed-line-ending`, sorts `requirments.txt` automatically on every commit. +The config for a pre-commit hook is stored in [.pre-commit-config](../../../.pre-commit-config.yaml). + +#### C++ and CUDA + +We follow the [Google C++ Style Guide](https://google.github.io/styleguide/cppguide.html). + +### PR Specs + +1. Use [pre-commit](https://pre-commit.com) hook to avoid issues of code style + +2. One short-time branch should be matched with only one PR + +3. Accomplish a detailed change in one PR. Avoid large PR + + - Bad: Support Faster R-CNN + - Acceptable: Add a box head to Faster R-CNN + - Good: Add a parameter to box head to support custom conv-layer number + +4. Provide clear and significant commit message + +5. Provide clear and meaningful PR description + + - Task name should be clarified in title. The general format is: \[Prefix\] Short description of the PR (Suffix) + - Prefix: add new feature \[Feature\], fix bug \[Fix\], related to documents \[Docs\], in developing \[WIP\] (which will not be reviewed temporarily) + - Introduce main changes, results and influences on other modules in short description + - Associate related issues and pull requests with a milestone diff --git a/docs/en/community/contribution_guide.md b/docs/en/community/contribution_guide.md deleted file mode 100644 index a7669e771b..0000000000 --- a/docs/en/community/contribution_guide.md +++ /dev/null @@ -1,68 +0,0 @@ -# Contributing to MMEditing - -This section introduces following contents: - -- [Workflow](#workflow) -- [Code style](#code-style) - - [Python](#python) - - [C++ and CUDA](#c-and-cuda) - -All kinds of contributions are welcome, including but not limited to the following. - -- Fix typo or bugs -- Add documentation or translate the documentation into other languages -- Add new features and components - -## Workflow - -1. fork and pull the latest MMEditing repository (MMEditing) -2. checkout a new branch (do not use master branch for PRs) -3. commit your changes -4. 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. -``` - -## Code style - -### Python - -We adopt [PEP8](https://www.python.org/dev/peps/pep-0008/) as the preferred code style. - -We use the following tools for linting and formatting: - -- [flake8](https://github.com/PyCQA/flake8): A wrapper around some linter tools. -- [isort](https://github.com/timothycrosley/isort): A Python utility to sort imports. -- [yapf](https://github.com/google/yapf): A formatter for Python files. -- [codespell](https://github.com/codespell-project/codespell): A Python utility to fix common misspellings in text files. -- [mdformat](https://github.com/executablebooks/mdformat): Mdformat is an opinionated Markdown formatter that can be used to enforce a consistent style in Markdown files. -- [docformatter](https://github.com/myint/docformatter): A formatter to format docstring. - -Style configurations can be found in [setup.cfg](https://github.com/open-mmlab/mmediting/blob/1.x/setup.cfg). - -We use [pre-commit hook](https://pre-commit.com/) that checks and formats for `flake8`, `yapf`, `isort`, `trailing whitespaces`, `markdown files`, -fixes `end-of-files`, `double-quoted-strings`, `python-encoding-pragma`, `mixed-line-ending`, sorts `requirments.txt` automatically on every commit. -The config for a pre-commit hook is stored in [.pre-commit-config](https://github.com/open-mmlab/mmediting/blob/1.x/.pre-commit-config.yaml). - -After you clone the repository, you will need to install initialize pre-commit hook. - -```shell -pip install -U pre-commit -``` - -From the repository folder - -```shell -pre-commit install -``` - -After this on every commit check code linters and formatter will be enforced. - -```{important} -Before you create a PR, make sure that your code lints and is formatted by yapf. -``` - -### C++ and CUDA - -We follow the [Google C++ Style Guide](https://google.github.io/styleguide/cppguide.html). diff --git a/docs/en/community/projects.md b/docs/en/community/projects.md index 9adf606d79..fe234251c6 100644 --- a/docs/en/community/projects.md +++ b/docs/en/community/projects.md @@ -1,14 +1,26 @@ # Projects based on MMEditing -There are many projects built upon MMEditing. +There are many awesome projects built upon MMEditing. We list some of them as examples of how to extend MMEditing for your own projects. As the page might not be completed, please feel free to create a PR to update this page. -## Research papers +We also welcome any pull request to contribute your projects in the [projects of MMEditing](https://github.com/open-mmlab/mmediting/tree/dev-1.x/projects). + +## Projects as an extension + +Some projects extend the boundary of MMEditing for deployment or other research fields. +They reveal the potential of what MMEditing can do. We list several of them as below. + +- [PowerVQE](https://github.com/ryanxingql/powervqe): Open framework for quality enhancement of compressed videos based on PyTorch and MMEditing. +- [VR-Baseline](https://github.com/linjing7/VR-Baseline): Video Restoration Toolbox. +- [Manga-Colorization-with-CycleGAN](https://github.com/chandlerbing65nm/Manga-Colorization-with-CycleGAN): Colorizing Black&White Japanese Manga using Generative Adversarial Network. + +## Projects of papers There are also projects released with papers. -Some of the papers are published in top-tier conferences (CVPR, ECCV, and NeurIPS). -Methods already supported and maintained by MMEditing are not listed. +Some of the papers are published in top-tier conferences (CVPR, ICCV, and ECCV), the others are also highly influential. +To make this list also a reference for the community to develop and compare new object detection algorithms, we list them following the time order of top-tier conferences. +Methods already supported and maintained by MMDetection are not listed. - Towards Interpretable Video Super-Resolution via Alternating Optimization, ECCV 2022 [\[paper\]](https://arxiv.org/abs/2207.10765)[\[github\]](https://github.com/caojiezhang/DAVSR) @@ -35,12 +47,3 @@ Methods already supported and maintained by MMEditing are not listed. - A Multi-Modality Ovarian Tumor Ultrasound Image Dataset for Unsupervised Cross-Domain Semantic Segmentation, arXiv 2022 [\[paper\]](https://arxiv.org/pdf/2207.06799.pdf)[\[github\]](https://github.com/cv516buaa/mmotu_ds2net) - Arbitrary-Scale Image Synthesis, CVPR 2022 [\[paper\]](https://arxiv.org/pdf/2204.02273.pdf)[\[github\]](https://github.com/vglsd/ScaleParty) - -## Open-source projects - -Some open-source projects extend MMEditing for more functions and fields. -They reveal the potential of what MMEditing can do. We list several of them as below. - -- [PowerVQE](https://github.com/ryanxingql/powervqe): Open framework for quality enhancement of compressed videos based on PyTorch and MMEditing. -- [VR-Baseline](https://github.com/linjing7/VR-Baseline): Video Restoration Toolbox. -- [Manga-Colorization-with-CycleGAN](https://github.com/chandlerbing65nm/Manga-Colorization-with-CycleGAN): Colorizing Black&White Japanese Manga using Generative Adversarial Network. diff --git a/docs/en/index.rst b/docs/en/index.rst index 44b45f6d90..37bf3068e5 100644 --- a/docs/en/index.rst +++ b/docs/en/index.rst @@ -38,7 +38,7 @@ Documentation :maxdepth: 1 :caption: Community - community/contribution_guide.md + community/contributing.md community/projects.md