Skip to content

Commit 03316eb

Browse files
authored
add pre-commit and static check in workflow (#590)
1 parent 34767d7 commit 03316eb

File tree

92 files changed

+8306
-3468
lines changed

Some content is hidden

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

92 files changed

+8306
-3468
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: "CI: Static Checks"
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
jobs:
10+
lint-and-fmt:
11+
name: lint and fmt
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Checkout
15+
uses: actions/checkout@v6
16+
- name: Setup Python
17+
uses: actions/setup-python@v6
18+
with:
19+
python-version: "3.10"
20+
- name: Run pre-commit
21+
uses: pre-commit/action@v3.0.1

.pre-commit-config.yaml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v6.0.0
4+
hooks:
5+
- id: check-case-conflict
6+
- id: check-yaml
7+
- id: check-json
8+
- id: check-merge-conflict
9+
- id: destroyed-symlinks
10+
- id: mixed-line-ending
11+
12+
- repo: https://github.com/tombi-toml/tombi-pre-commit
13+
rev: v0.7.0
14+
hooks:
15+
- id: tombi-format
16+
exclude: ^Cargo\.lock$
17+
- id: tombi-lint
18+
19+
- repo: https://github.com/astral-sh/ruff-pre-commit
20+
rev: v0.14.6
21+
hooks:
22+
- id: ruff-check
23+
args: [--fix]
24+
- id: ruff-format

.python-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3.10

engine.py

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,28 @@
1+
from __future__ import annotations
2+
13
import os
24

3-
os.environ["FLAGS_use_system_allocator"] = "1"
5+
os.environ["FLAGS_USE_SYSTEM_ALLOCATOR"] = "1"
46
os.environ["NVIDIA_TF32_OVERRIDE"] = "0"
57

68
import argparse
79
from datetime import datetime
810

911
import paddle
1012
import torch
11-
12-
from tester import (APIConfig, APITestAccuracy, APITestAccuracyStable,
13-
APITestCINNVSDygraph, APITestPaddleGPUPerformance,
14-
APITestPaddleOnly, APITestPaddleTorchGPUPerformance,
15-
APITestTorchGPUPerformance,APITestCustomDeviceVSCPU,set_cfg)
16-
from tester.api_config.log_writer import (close_process_files, read_log,
17-
write_to_log)
13+
from tester import (
14+
APIConfig,
15+
APITestAccuracy,
16+
APITestAccuracyStable,
17+
APITestCINNVSDygraph,
18+
APITestCustomDeviceVSCPU,
19+
APITestPaddleGPUPerformance,
20+
APITestPaddleOnly,
21+
APITestPaddleTorchGPUPerformance,
22+
APITestTorchGPUPerformance,
23+
set_cfg,
24+
)
25+
from tester.api_config.log_writer import close_process_files, read_log, write_to_log
1826

1927

2028
def parse_bool(value):
@@ -163,8 +171,8 @@ def main():
163171
paddle.device.cuda.empty_cache()
164172
elif options.api_config_file != "":
165173
finish_configs = read_log("checkpoint")
166-
with open(options.api_config_file, "r") as f:
167-
api_configs = set(line.strip() for line in f if line.strip())
174+
with open(options.api_config_file) as f:
175+
api_configs = {line.strip() for line in f if line.strip()}
168176
api_configs = api_configs - finish_configs
169177
api_configs = sorted(api_configs)
170178
for api_config_str in api_configs:
@@ -223,5 +231,6 @@ def main():
223231

224232
close_process_files()
225233

234+
226235
if __name__ == "__main__":
227236
main()

0 commit comments

Comments
 (0)