You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/source/en/modeling_rules.md
+8-8Lines changed: 8 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -13,22 +13,22 @@ specific language governing permissions and limitations under the License.
13
13
14
14
# Model structure rules
15
15
16
-
Transformers enforces a set of static rules on every `modeling_*.py`, `modular_*.py`, and `configuration_*.py` file. The [mlinter](https://github.com/huggingface/transformers-mlinter)tool checks them as part of `make typing` and errors out if violations are found.
16
+
Transformers enforces a set of static rules on every `modeling_*.py`, `modular_*.py`, and `configuration_*.py` file. The [mlinter](https://github.com/huggingface/transformers-mlinter)package provides the checker engine, and the repository keeps its active rule set in `utils/rules.toml`. That local TOML lets us enable, disable, or tweak rules quickly without waiting for a new `transformers-mlinter` release.
17
17
18
18
These are the expected model conventions for adding or changing modeling code. They keep the codebase consistent and ensure compatibility with features like pipeline parallelism, device maps, and weight tying.
19
19
20
20
## Running the checker
21
21
22
-
`make typing` runs `mlinter` alongside the `ty` type checker. Run `mlinter` on its own with the following commands.
22
+
`make typing` runs `mlinter` alongside the `ty` type checker through the repo wrapper, so it picks up `utils/rules.toml`. Run the same wrapper directly with the following commands.
23
23
24
24
```bash
25
-
mlinter # check all modeling files
26
-
mlinter --changed-only# check only files changed vs origin/main
27
-
mlinter --list-rules# list all rules and their enabled status
28
-
mlinter --rule TRF001# show built-in docs for a specific rule
25
+
python utils/check_modeling_structure.py# check all modeling files
26
+
python utils/check_modeling_structure.py --changed-only # check only files changed vs origin/main
27
+
python utils/check_modeling_structure.py --list-rules # list all rules and their enabled status
28
+
python utils/check_modeling_structure.py --rule TRF001 # show built-in docs for a specific rule
29
29
```
30
30
31
-
The `--changed-only` flag is the fastest option during development. It only checks the files you've modified relative to the main branch.
31
+
The `--changed-only` flag is the fastest option during development. It only checks the files you've modified relative to the main branch. If you invoke `mlinter` directly instead of the wrapper, pass `--rules-toml utils/rules.toml` so local overrides are applied.
32
32
33
33
## Fixing a violation
34
34
@@ -52,7 +52,7 @@ Use the rule ID to look up the fix in the [rules reference](#rules-reference). T
52
52
53
53
## Rules reference
54
54
55
-
Each rule below lists what it enforces and a diff showing the fix. Run `mlinter --rule TRF001` to see the built-in docs for any rule.
55
+
Each rule below lists what it enforces and a diff showing the fix. Run `python utils/check_modeling_structure.py --rule TRF001` to see the built-in docs for any rule with the repo's current rule set.
0 commit comments