Skip to content

Commit 9033e75

Browse files
Merge pull request #1994 from SamuelMarks:auto_check_and_precommit_and_bash_code_style_sh
PiperOrigin-RevId: 813846084
2 parents fede8e9 + a9c4867 commit 9033e75

99 files changed

Lines changed: 4456 additions & 3910 deletions

File tree

Some content is hidden

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

.editorconfig

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
root = true
2+
3+
[*]
4+
end_of_line = lf
5+
insert_final_newline = true
6+
7+
[*.py]
8+
charset = utf-8
9+
indent_style = space
10+
indent_size = 2
11+
max_line_length = 125

.github/workflows/CPUTests.yml

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -34,20 +34,9 @@ jobs:
3434
- name: Typecheck the code with pytype
3535
run: |
3636
pytype --jobs auto --disable 'import-error,late-directive,wrong-arg-types,module-attr,unsupported-operands' src/MaxText/ || true
37-
- name: Analysing the code with pylint in Maxtext/
37+
- name: pylint
3838
run: |
39-
pylint --verbose --msg-template='[{abspath}] {msg_id}:{line:3d},{column}: {obj}: {msg}' --disable C0114,R0401,R0917,W0201,W0613 src/MaxText/ || true
40-
- name: Analysing the code with pylint in pedagogical_examples/
39+
pylint --disable=R0401,R0917,W0201,W0613 --ignore-patterns='.pytype,.*pyi$' benchmarks end_to_end src tests
40+
- name: pyink
4141
run: |
42-
pylint pedagogical_examples/ && \
43-
echo 'PyLint check on pedagogical_examples/ is successful' || { echo \
44-
'PyLint check has failed. Please run bash code_style.sh to fix issues'; exit 20; }
45-
- name: Analysing the code with pyink in Maxtext/
46-
run: |
47-
pyink src/MaxText --check --diff --color --pyink-indentation=2 --line-length=125 || true
48-
- name: Analysing the code with pyink in pedagogical_examples/
49-
run: |
50-
pyink pedagogical_examples --check --diff --color --pyink-indentation=2 --line-length=125
51-
52-
53-
42+
pyink --pyink-indentation=2 --line-length=122 --check .

.pre-commit-config.yaml

Lines changed: 51 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,54 @@
1+
---
2+
files: ^(.*\.(py|md|sh|yaml|yml|in|cfg|txt|rst|toml|precommit-toml|wordlist))$
3+
exclude: ^(\.[^/]*(cache|assets|uv|venv)/.*)$
14
repos:
25
- repo: https://github.com/codespell-project/codespell
3-
rev: v2.2.4
6+
rev: v2.4.1
47
hooks:
5-
- id: codespell
6-
name: Running codespell for typos
7-
entry: codespell -w --skip="*.txt,pylintrc,.*,src/MaxText/assets/*" .
8+
- id: codespell
9+
args:
10+
- '-w'
11+
- '--skip="*.txt,pylintrc,.*,src/MaxText/assets/*"'
12+
- '-L ND,nd,sems,TE,ROUGE,rouge,astroid'
13+
- '.'
14+
additional_dependencies:
15+
- tomli
16+
17+
# - repo: https://github.com/abravalheri/validate-pyproject
18+
# rev: v0.24.1
19+
# hooks:
20+
# - id: validate-pyproject
21+
# name: Validate pyproject.toml
22+
# language: python
23+
# files: '^pyproject\.toml$'
24+
# entry: python
25+
26+
- repo: https://github.com/pylint-dev/pylint
27+
rev: v3.3.8
28+
hooks:
29+
- id: pylint
30+
args:
31+
- '--disable=R0401,R0917,W0201,W0613'
32+
- "--ignore-patterns='.pytype,.*pyi$'"
33+
- 'benchmarks'
34+
- 'end_to_end'
35+
- 'src'
36+
- 'tests'
37+
38+
# - repo: https://github.com/google/pytype
39+
# rev: 2024.10.11
40+
# hooks:
41+
# - id: pytype
42+
# args:
43+
# - '--jobs=auto'
44+
# - '--keep-going'
45+
# - 'src/MaxText/'
46+
47+
- repo: https://github.com/google/pyink
48+
rev: 24.10.1
49+
hooks:
50+
- id: pyink
51+
args:
52+
- '--pyink-indentation=2'
53+
- '--line-length=122'
54+
- '--check'

.pre-commit-hooks.yaml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
- id: codespell
2+
name: codespell
3+
description: Checks for common misspellings in text files.
4+
entry: codespell
5+
language: python
6+
exclude: '^\.[^/]*(cache|assets|uv|venv)/.*'
7+
types: [ text ]
8+
9+
- id: pyink
10+
name: pyink
11+
description: Run pyink Python code formatter.
12+
entry: pyink
13+
language: python
14+
types:
15+
- python
16+
- text
17+
18+
# - id: pytype
19+
# name: Pytype
20+
# description: A static type analyzer for Python code.
21+
# entry: pytype
22+
# language: system
23+
# types: [ python ]
24+
25+
- id: pylint
26+
name: pylint
27+
description: Checks for errors, enforces a coding standard, looks for code smells.
28+
entry: pylint
29+
language: system
30+
types: [ python ]
31+
32+
# - id: validate-pyproject
33+
# name: check toml
34+
# description: checks pyproject.toml file
35+
# types:
36+
# - python
37+
# - text
38+
# - toml
39+
# files: '^pyproject\.toml$'
40+
# entry: validate-pyproject

benchmarks/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,5 @@
1111
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
14+
15+
"""Init file for the benchmarks directory."""

benchmarks/api_server/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ python -m eval.eval \
291291
--output_path logs
292292
```
293293

294-
An example benchmark outpus will be like:
294+
An example benchmark outputs will be like:
295295

296296
<img src="./images/mmlu_example.png" alt="MMLU Example" width="894"/>
297297

@@ -314,4 +314,4 @@ python -m eval.eval \
314314
```
315315
The valid arguments for `--gen_kwargs` are `temperature`, `top_p`, `top_k`, `stop`, `seed`, `max_tokens` and `max_gen_toks`. The `max_gen_toks` argument is used by some tasks in evaluation harness to control the maximum number of tokens to generate. We suggest pass `max_tokens` and `max_gen_toks` with the same value at the same time.
316316

317-
The evaluation results will be saved to the directory specified by the `--output_path` argument (in the examples above, a directory named `logs`).
317+
The evaluation results will be saved to the directory specified by the `--output_path` argument (in the examples above, a directory named `logs`).

0 commit comments

Comments
 (0)