Skip to content

Commit ed887b5

Browse files
Bordaglenn-jocher
andauthored
Add pre-commit CI actions (#4982)
* define pre-commit * add CI code * configure * apply pre-commit * fstring * apply MD * pre-commit * Update torch_utils.py * Update print strings * notes * Cleanup code-format.yml * Update setup.cfg * Update .pre-commit-config.yaml Co-authored-by: Glenn Jocher <[email protected]>
1 parent a4fece8 commit ed887b5

30 files changed

+273
-113
lines changed

.github/ISSUE_TEMPLATE/feature-request.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ assignees: ''
1313

1414
## Motivation
1515

16-
<!-- Please outline the motivation for the proposal. Is your feature request related to a problem?
16+
<!-- Please outline the motivation for the proposal. Is your feature request related to a problem?
1717
e.g., I'm always frustrated when [...]. If this is related to another GitHub issue, please link here too -->
1818

1919
## Pitch

.github/workflows/ci-testing.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ jobs:
8383
# Python
8484
python - <<EOF
8585
import torch
86-
# Known issue, urllib.error.HTTPError: HTTP Error 403: rate limit exceeded, will be resolved in torch==1.10.0
86+
# Known issue, urllib.error.HTTPError: HTTP Error 403: rate limit exceeded, will be resolved in torch==1.10.0
8787
# model = torch.hub.load('ultralytics/yolov5', 'custom', path='runs/train/exp/weights/last.pt')
8888
EOF
8989

.github/workflows/code-format.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# Run code formatting GitHub Action, can be replaced by this bot: https://github.com/marketplace/pre-commit-ci
2+
3+
name: Code formatting
4+
5+
on: # https://help.github.com/en/actions/reference/events-that-trigger-workflows
6+
push:
7+
branches: [master]
8+
pull_request: {}
9+
10+
jobs:
11+
pep8-check-flake8:
12+
runs-on: ubuntu-20.04
13+
steps:
14+
- uses: actions/checkout@master
15+
- uses: actions/setup-python@v2
16+
with:
17+
python-version: 3.7
18+
- name: Install dependencies
19+
run: |
20+
pip install flake8
21+
pip list
22+
shell: bash
23+
- name: PEP8
24+
run: |
25+
flake8 .
26+
27+
pre-commit-check:
28+
runs-on: ubuntu-20.04
29+
steps:
30+
- uses: actions/checkout@v2
31+
# for private repo - first is the checkout step, which needs to use unlimited fetch depth for pushing
32+
with:
33+
fetch-depth: 0
34+
- uses: actions/setup-python@v2
35+
36+
- name: set PY
37+
run: echo "PY=$(python -VV | sha256sum | cut -d' ' -f1)" >> $GITHUB_ENV
38+
- uses: actions/cache@v2
39+
with:
40+
path: ~/.cache/pre-commit
41+
key: pre-commit|${{ env.PY }}|${{ hashFiles('.pre-commit-config.yaml') }}
42+
43+
- uses: pre-commit/[email protected]
44+
# this action also provides an additional behaviour when used in private repositories
45+
# when configured with a github token, the action will push back fixes to the pull request branch
46+
with:
47+
token: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/codeql-analysis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# This action runs GitHub's industry-leading static analysis engine, CodeQL, against a repository's source code to find security vulnerabilities.
1+
# This action runs GitHub's industry-leading static analysis engine, CodeQL, against a repository's source code to find security vulnerabilities.
22
# https://github.com/github/codeql-action
33

44
name: "CodeQL"

.github/workflows/greetings.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,4 +57,3 @@ jobs:
5757
<a href="https://github.com/ultralytics/yolov5/actions"><img src="https://github.com/ultralytics/yolov5/workflows/CI%20CPU%20testing/badge.svg" alt="CI CPU testing"></a>
5858
5959
If this badge is green, all [YOLOv5 GitHub Actions](https://github.com/ultralytics/yolov5/actions) Continuous Integration (CI) tests are currently passing. CI tests verify correct operation of YOLOv5 training ([train.py](https://github.com/ultralytics/yolov5/blob/master/train.py)), validation ([val.py](https://github.com/ultralytics/yolov5/blob/master/val.py)), inference ([detect.py](https://github.com/ultralytics/yolov5/blob/master/detect.py)) and export ([export.py](https://github.com/ultralytics/yolov5/blob/master/export.py)) on MacOS, Windows, and Ubuntu every 24 hours and on every commit.
60-

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
*.data
2121
*.json
2222
*.cfg
23+
!setup.cfg
2324
!cfg/yolov3*.cfg
2425

2526
storage.googleapis.com

.pre-commit-config.yaml

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# Define hooks for code formations
2+
# Will be applied on any updated commit files if a user has installed and linked commit hook
3+
4+
default_language_version:
5+
python: python3.8
6+
7+
# Define bot property if installed via https://github.com/marketplace/pre-commit-ci
8+
ci:
9+
autofix_prs: true
10+
autoupdate_commit_msg: '[pre-commit.ci] pre-commit suggestions'
11+
autoupdate_schedule: quarterly
12+
# submodules: true
13+
14+
repos:
15+
- repo: https://github.com/pre-commit/pre-commit-hooks
16+
rev: v4.0.1
17+
hooks:
18+
- id: end-of-file-fixer
19+
- id: trailing-whitespace
20+
- id: check-case-conflict
21+
- id: check-yaml
22+
- id: check-toml
23+
- id: pretty-format-json
24+
- id: check-docstring-first
25+
26+
- repo: https://github.com/asottile/pyupgrade
27+
rev: v2.23.1
28+
hooks:
29+
- id: pyupgrade
30+
args: [--py36-plus]
31+
name: Upgrade code
32+
33+
# TODO
34+
#- repo: https://github.com/PyCQA/isort
35+
# rev: 5.9.3
36+
# hooks:
37+
# - id: isort
38+
# name: imports
39+
40+
# TODO
41+
#- repo: https://github.com/pre-commit/mirrors-yapf
42+
# rev: v0.31.0
43+
# hooks:
44+
# - id: yapf
45+
# name: formatting
46+
47+
# TODO
48+
#- repo: https://github.com/executablebooks/mdformat
49+
# rev: 0.7.7
50+
# hooks:
51+
# - id: mdformat
52+
# additional_dependencies:
53+
# - mdformat-gfm
54+
# - mdformat-black
55+
# - mdformat_frontmatter
56+
57+
# TODO
58+
#- repo: https://github.com/asottile/yesqa
59+
# rev: v1.2.3
60+
# hooks:
61+
# - id: yesqa
62+
63+
- repo: https://github.com/PyCQA/flake8
64+
rev: 3.9.2
65+
hooks:
66+
- id: flake8
67+
name: PEP8

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -671,4 +671,4 @@ into proprietary programs. If your program is a subroutine library, you
671671
may consider it more useful to permit linking proprietary applications with
672672
the library. If this is what you want to do, use the GNU Lesser General
673673
Public License instead of this License. But first, please read
674-
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
674+
<http://www.gnu.org/philosophy/why-not-lgpl.html>.

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ YOLOv5 🚀 is a family of object detection architectures and models pretrained
4646
open-source research into future vision AI methods, incorporating lessons learned and best practices evolved over thousands of hours of research and development.
4747
</p>
4848

49-
<!--
49+
<!--
5050
<a align="center" href="https://ultralytics.com/yolov5" target="_blank">
5151
<img width="800" src="https://github.com/ultralytics/yolov5/releases/download/v1.0/banner-api.png"></a>
5252
-->
@@ -109,7 +109,7 @@ the [latest YOLOv5 release](https://github.com/ultralytics/yolov5/releases) and
109109

110110
```bash
111111
$ python detect.py --source 0 # webcam
112-
file.jpg # image
112+
file.jpg # image
113113
file.mp4 # video
114114
path/ # directory
115115
path/*.jpg # glob
@@ -136,7 +136,7 @@ $ python train.py --data coco.yaml --cfg yolov5s.yaml --weights '' --batch-size
136136

137137
<img width="800" src="https://user-images.githubusercontent.com/26833433/90222759-949d8800-ddc1-11ea-9fa1-1c97eed2b963.png">
138138

139-
</details>
139+
</details>
140140

141141
<details open>
142142
<summary>Tutorials</summary>
@@ -178,7 +178,7 @@ Get started in seconds with our verified environments. Click each icon below for
178178
<a href="https://github.com/ultralytics/yolov5/wiki/GCP-Quickstart">
179179
<img src="https://github.com/ultralytics/yolov5/releases/download/v1.0/logo-gcp-small.png" width="15%"/>
180180
</a>
181-
</div>
181+
</div>
182182

183183
## <div align="center">Integrations</div>
184184

@@ -239,7 +239,7 @@ We are super excited about our first-ever Ultralytics YOLOv5 🚀 EXPORT Competi
239239
|[YOLOv5s6][assets] |1280 |44.5 |63.0 |385 |8.2 |3.6 |16.8 |12.6
240240
|[YOLOv5m6][assets] |1280 |51.0 |69.0 |887 |11.1 |6.8 |35.7 |50.0
241241
|[YOLOv5l6][assets] |1280 |53.6 |71.6 |1784 |15.8 |10.5 |76.8 |111.4
242-
|[YOLOv5x6][assets]<br>+ [TTA][TTA]|1280<br>1536 |54.7<br>**55.4** |**72.4**<br>72.3 |3136<br>- |26.2<br>- |19.4<br>- |140.7<br>- |209.8<br>-
242+
|[YOLOv5x6][assets]<br>+ [TTA][TTA]|1280<br>1536 |54.7<br>**55.4** |**72.4**<br>72.3 |3136<br>- |26.2<br>- |19.4<br>- |140.7<br>- |209.8<br>-
243243

244244
<details>
245245
<summary>Table Notes (click to expand)</summary>

data/Objects365.yaml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,21 +62,21 @@ names: ['Person', 'Sneakers', 'Chair', 'Other Shoes', 'Hat', 'Car', 'Lamp', 'Gla
6262
download: |
6363
from pycocotools.coco import COCO
6464
from tqdm import tqdm
65-
65+
6666
from utils.general import Path, download, np, xyxy2xywhn
67-
67+
6868
# Make Directories
6969
dir = Path(yaml['path']) # dataset root dir
7070
for p in 'images', 'labels':
7171
(dir / p).mkdir(parents=True, exist_ok=True)
7272
for q in 'train', 'val':
7373
(dir / p / q).mkdir(parents=True, exist_ok=True)
74-
74+
7575
# Train, Val Splits
7676
for split, patches in [('train', 50 + 1), ('val', 43 + 1)]:
7777
print(f"Processing {split} in {patches} patches ...")
7878
images, labels = dir / 'images' / split, dir / 'labels' / split
79-
79+
8080
# Download
8181
url = f"https://dorc.ks3-cn-beijing.ksyun.com/data-set/2020Objects365%E6%95%B0%E6%8D%AE%E9%9B%86/{split}/"
8282
if split == 'train':
@@ -86,11 +86,11 @@ download: |
8686
download([f'{url}zhiyuan_objv2_{split}.json'], dir=dir, delete=False) # annotations json
8787
download([f'{url}images/v1/patch{i}.tar.gz' for i in range(15 + 1)], dir=images, curl=True, delete=False, threads=8)
8888
download([f'{url}images/v2/patch{i}.tar.gz' for i in range(16, patches)], dir=images, curl=True, delete=False, threads=8)
89-
89+
9090
# Move
9191
for f in tqdm(images.rglob('*.jpg'), desc=f'Moving {split} images'):
9292
f.rename(images / f.name) # move to /images/{split}
93-
93+
9494
# Labels
9595
coco = COCO(dir / f'zhiyuan_objv2_{split}.json')
9696
names = [x["name"] for x in coco.loadCats(coco.getCatIds())]

0 commit comments

Comments
 (0)