transformers - ✅(Solved) Fix Plug model rule in development flow and extend it [1 pull requests, 1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
huggingface/transformers#44619Fetched 2026-04-08 00:27:23
View on GitHub
Comments
0
Participants
1
Timeline
2
Reactions
0
Participants
Assignees
Timeline (top)
assigned ×1sub_issue_added ×1

PR fix notes

PR #44174: Expand model-structure lint rules with a fast AST-based, ruff-like framework

Description (problem / solution / changelog)

This draft expands utils/check_modeling_structure.py into a rule-driven linter for model code, with new checks and tests, while keeping runtime very low.

Key features:

  • The checker is intentionally AST-only (no heavy imports/execution), so it stays fast (<3 seconds against all models)
  • It's built in a CI/PR-friendly way, so when devs proposes new models it's easy to provide feedback automatically
  • It provides a nice CLI UI to explain every rules, like how Ruff does with ruff rule XXX
  • it's agentic-friendly

See utils/check_modeling_structure_rules.toml for the set of rules

Changed files

  • Makefile (modified, +13/-1)
  • tests/repo_utils/test_check_modeling_structure.py (added, +319/-0)
  • utils/check_modeling_structure.py (modified, +876/-23)
  • utils/check_modeling_structure_rules.toml (added, +159/-0)
RAW_BUFFERClick to expand / collapse

This is a follow-up from https://github.com/huggingface/transformers/pull/44174

We're now plugging the tool into developer flow:

  • add an opt-in github hook for checking the model
  • automatically run make check-model-rules on PRs to generate reports
  • add a ref to the CLI in the AI agents files
  • fix models that are in allow lists and can be fixed
  • modularize the code (add a mlinter sub package in utils)

extent analysis

Fix Plan

Step 1: Configure GitHub Hook

  • Create a new GitHub webhook for the repository.
  • Set the Content Type to application/json.
  • Set the Event to pull_request.
  • Set the Active status to true.
  • Add the webhook URL from your server.

Step 2: Run make check-model-rules on PRs

  • Create a GitHub Actions workflow file (e.g., .github/workflows/check-model-rules.yml) with the following content:
name: Check Model Rules

on:
  pull_request:
    types: [opened, synchronize]

jobs:
  check-model-rules:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@v2
      - name: Run make check-model-rules
        run: make check-model-rules

Step 3: Add Ref to CLI in AI Agents Files

  • Update the AI agents files to include a reference to the CLI.
  • For example, in a Python file:
import subprocess

def get_cli_reference():
    return subprocess.check_output(["make", "cli-reference"]).decode("utf-8")

Step 4: Fix Models in Allow Lists

  • Identify models in the allow lists that can be fixed.
  • Update the models to meet the required standards.
  • Run make check-model-rules to generate reports for the updated models.

Step 5: Test and Verify

  • Test the GitHub hook and the make check-model-rules workflow.
  • Verify that the CLI reference is correctly added to the AI agents files.
  • Check that the models in the allow lists meet the required standards.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING