Skip to content

Commit c3d524a

Browse files
committed
Merge branch 'develop' of https://github.com/PaddlePaddle/PaddleNLP into zoo_ernie_m
2 parents d8e952b + 7148926 commit c3d524a

File tree

177 files changed

+4671
-1679
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

177 files changed

+4671
-1679
lines changed

CODE_OF_CONDUCT.md renamed to .github/CODE_OF_CONDUCT.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
**简体中文**🀄 | [English🌎](./CODE_OF_CONDUCT_en.md)
12

23
# 贡献者公约
34

CODE_OF_CONDUCT_en.md renamed to .github/CODE_OF_CONDUCT_en.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
[简体中文🀄](./CODE_OF_CONDUCT.md) | **English**🌎
12

23
# Contributor Covenant Code of Conduct
34

.github/CONTRIBUTING_en.md

Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
[简体中文🀄](../CONTRIBUTING.md) | **English**🌎
2+
3+
# Contributing to PaddleNLP
4+
5+
We highly welcome and value your contributions to `PaddleNLP`. The first step to start your contribution is to sign the [PaddlePaddle Contributor License Agreement](https://cla-assistant.io/PaddlePaddle/PaddleNLP).
6+
7+
This document explains our workflow and work style:
8+
9+
## Finding out what to work on Workflow
10+
11+
## Development Workflow
12+
13+
PaddleNLP uses the [Git branching model](http://nvie.com/posts/a-successful-git-branching-model/). The following steps guide usual contributions.
14+
15+
#### 1. Fork
16+
17+
Our development community has been growing fastly; it doesn't make sense for everyone to write into the official repo. So, please file Pull Requests from your fork. To make a fork, just head over to the GitHub page and click the ["Fork" button](https://help.github.com/articles/fork-a-repo/).
18+
19+
#### 2. Clone
20+
21+
To make a copy of your fork to your local computers, please run
22+
23+
```bash
24+
git clone https://github.com/<your-github-account>/PaddleNLP
25+
cd PaddleNLP
26+
```
27+
28+
#### 3. Create the local feature branch
29+
30+
For daily works like adding a new feature or fixing a bug, please open your feature branch before coding:
31+
32+
```bash
33+
git checkout -b my-cool-feature
34+
```
35+
36+
#### 4. Set up the development environment
37+
38+
Before you start coding, you need to setup the development environment. We highly recommend doing all your development in a virtual environment such as
39+
[venv](https://docs.python.org/3/library/venv.html) or [conda](https://docs.conda.io/en/latest/). After you setup and activated your virtual environment,
40+
run the following command:
41+
42+
```bash
43+
make install
44+
```
45+
46+
This will setup all the dependencies of `PaddleNLP` as well as the [`pre-commit`](http://pre-commit.com/) tool.
47+
48+
If you are working on the `examples` or `applications` module and require importing from `PaddleNLP`, make sure you install `PaddleNLP` in editable mode.
49+
If `PaddleNLP` is already installed in the virtual environment, remove it with `pip uninstall paddlenlp` before reinstalling it in editable mode with
50+
`pip install -e .`
51+
52+
#### 5. Develop
53+
54+
As you develop your new exciting feature, keep in mind that it should be covered by unit tests. All of our unit tests can be found under the `tests` directory.
55+
You can either modify existing unit test to cover the new feature, or create a new test from scratch.
56+
As you finish up the your code, you should make sure the test suite passes. You can run the tests impacted by your changes like this:
57+
58+
```bash
59+
pytest tests/<test_to_run>.py
60+
```
61+
62+
#### 6. Commit
63+
64+
We utilizes [`pre-commit`](http://pre-commit.com/) (with [black](https://black.readthedocs.io/en/stable/), [isort](https://pycqa.github.io/isort/) and
65+
[flake8](https://flake8.pycqa.org/en/latest/) under the hood) to check the style of code and documentation in every commit. When you run run `git commit`, you will see
66+
something like the following:
67+
68+
```
69+
➜ (my-virtual-env) git commit -m "commiting my cool feature"
70+
black....................................................................Passed
71+
isort....................................................................Passed
72+
flake8...................................................................Passed
73+
check for merge conflicts................................................Passed
74+
check for broken symlinks............................(no files to check)Skipped
75+
detect private key.......................................................Passed
76+
fix end of files.....................................(no files to check)Skipped
77+
trim trailing whitespace.............................(no files to check)Skipped
78+
CRLF end-lines checker...............................(no files to check)Skipped
79+
CRLF end-lines remover...............................(no files to check)Skipped
80+
No-tabs checker......................................(no files to check)Skipped
81+
Tabs remover.........................................(no files to check)Skipped
82+
copyright_checker........................................................Passed
83+
```
84+
85+
But most of the time things don't go so smoothly. When your code or documentation doesn't meet the standard, the `pre-commit` check will fail.
86+
```
87+
➜ (my-virtual-env) git commit -m "commiting my cool feature"
88+
black....................................................................Passed
89+
isort....................................................................Failed
90+
- hook id: isort
91+
- files were modified by this hook
92+
93+
Fixing examples/information_extraction/waybill_ie/run_ernie_crf.py
94+
95+
flake8...................................................................Passed
96+
check for merge conflicts................................................Passed
97+
check for broken symlinks............................(no files to check)Skipped
98+
detect private key.......................................................Passed
99+
fix end of files.....................................(no files to check)Skipped
100+
trim trailing whitespace.............................(no files to check)Skipped
101+
CRLF end-lines checker...............................(no files to check)Skipped
102+
CRLF end-lines remover...............................(no files to check)Skipped
103+
No-tabs checker......................................(no files to check)Skipped
104+
Tabs remover.........................................(no files to check)Skipped
105+
copyright_checker........................................................Passed
106+
```
107+
108+
But **don't panic**!
109+
Our tooling will fix most of the style errors automatically. Some errors will need to be addressed manually. Fortunately, the error messages are straight forward and
110+
the errors are usually simple to fix. After addressing the errors, you can run `git add <files>` and `git commit` again, which will trigger `pre-commit` again.
111+
Once the `pre-commit` checks pass, you are ready to push the code.
112+
113+
[Google][http://google.com/] or [StackOverflow](https://stackoverflow.com/) are great tools to help you understand the code style errors.
114+
Don't worry if you still can't figure it out. You can commit with `git commit -m "style error" --no-verify` and we are happy to help you once you create a Pull Request.
115+
116+
#### 7. Keep pulling
117+
118+
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.
119+
120+
```bash
121+
git remote add upstream https://github.com/PaddlePaddle/PaddleNLP
122+
git pull upstream develop
123+
```
124+
125+
#### 8. Push and file a pull request
126+
127+
You can "push" your local work into your forked repo:
128+
129+
```bash
130+
git push origin my-cool-stuff
131+
```
132+
133+
The push allows you to create a pull request, requesting owners of this [official repo](https://github.com/PaddlePaddle/PaddleNLP) to pull your change into the official one.
134+
135+
To create a pull request, please follow [these steps](https://help.github.com/articles/creating-a-pull-request/).
136+
137+
#### 9. Delete local and remote branches
138+
139+
To keep your local workspace and your fork clean, you might want to remove merged branches:
140+
141+
```bash
142+
git push origin my-cool-stuff
143+
git checkout develop
144+
git pull upstream develop
145+
git branch -d my-cool-stuff
146+
```
147+
148+
## Code Review
149+
150+
- Please feel free to ping your reviewers by @-mentioning the in the Pull Request. Please do this after your pull request passes the CI.
151+
152+
- Please answer reviewers' every comment. If you are to follow the comment, please write "Done"; Otherwise, please start a discussion under the comment.
153+
154+
- 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/).
File renamed without changes.
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: FastTokenizer
2+
3+
on:
4+
push:
5+
paths:
6+
- 'fast_tokenizer/*'
7+
pull_request:
8+
paths:
9+
- 'fast_tokenizer/*'
10+
11+
jobs:
12+
fast_tokenizer_cpp:
13+
name: fast_tokenizer_cpp
14+
runs-on: ubuntu-22.04
15+
permissions:
16+
pull-requests: write
17+
contents: read
18+
id-token: write
19+
steps:
20+
- uses: actions/checkout@v3
21+
- name: compile
22+
working-directory: ./fast_tokenizer
23+
run: make fast_tokenizer_cpp_compile
24+
- name: test
25+
working-directory: ./fast_tokenizer
26+
run: make fast_tokenizer_cpp_test
27+
fast_tokenizer_python38:
28+
name: fast_tokenizer_python38
29+
runs-on: ubuntu-22.04
30+
permissions:
31+
pull-requests: write
32+
contents: read
33+
id-token: write
34+
steps:
35+
- uses: actions/checkout@v3
36+
- uses: actions/setup-python@v1
37+
with:
38+
python-version: 3.8
39+
- name: install
40+
working-directory: ./fast_tokenizer
41+
run: make fast_tokenizer_python_install
42+
- name: compile
43+
working-directory: ./fast_tokenizer
44+
run: make fast_tokenizer_python_compile
45+
- name: test
46+
working-directory: ./fast_tokenizer
47+
run: make fast_tokenizer_python_test
48+

.github/workflows/lint.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,10 @@ jobs:
1717
else
1818
echo "local develop branch exist, skipping"
1919
fi
20-
- uses: actions/setup-python@v1
20+
- uses: actions/setup-python@v4
2121
with:
2222
python-version: 3.8
23+
cache: 'pip' # caching pip dependencies
2324
- name: Install dependencies
2425
run: |
2526
python -m pip install --upgrade pip

.github/workflows/tests.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,10 @@ jobs:
1212
id-token: write
1313
steps:
1414
- uses: actions/checkout@v3
15-
- uses: actions/setup-python@v1
15+
- uses: actions/setup-python@v4
1616
with:
1717
python-version: 3.8
18+
cache: 'pip' # caching pip dependencies
1819
- name: Install dependencies
1920
run: |
2021
python -m pip install --upgrade pip

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ repos:
77
files: \.(py|pyi)$
88
additional_dependencies: [toml]
99
- repo: https://github.com/PyCQA/isort
10-
rev: 5.10.1
10+
rev: 5.11.5
1111
hooks:
1212
- id: isort
1313
- repo: https://github.com/PyCQA/flake8

.readthedocs.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ sphinx:
2121
python:
2222
version: 3.8
2323
install:
24-
- requirements: docs/requirements.txt
2524
- requirements: requirements.txt
25+
- requirements: docs/requirements.txt
2626
- method: setuptools
2727
path: .
28-
system_packages: true
28+
system_packages: true

.style.yapf

Lines changed: 0 additions & 3 deletions
This file was deleted.

0 commit comments

Comments
 (0)