forked from huggingface/transformers
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
107 lines (82 loc) · 3.1 KB
/
Makefile
File metadata and controls
107 lines (82 loc) · 3.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
# make sure to test the local checkout in scripts and not the pre-installed one (don't use quotes!)
export PYTHONPATH = src
.PHONY: style typing check-code-quality check-repository-consistency check-repo fix-repo test test-examples benchmark codex claude clean-ai
# Checker lists. The two CI jobs (CircleCI runs `make check-code-quality` and
# `make check-repository-consistency` in parallel) own the canonical sets below.
# Local convenience targets `check-repo` and `fix-repo` are *derived* from them,
# so they can never drift out of sync (e.g. silently dropping `auto_mappings`
# from CI, as happened in #45018 → fixed in #45774).
STYLE_CHECKERS := ruff_check, ruff_format, init_isort, sort_auto_mappings
TYPING_CHECKERS := types, modeling_structure
CODE_QUALITY_CHECKERS := $(TYPING_CHECKERS), $(STYLE_CHECKERS)
REPO_CONSISTENCY_CHECKERS := \
auto_mappings, \
imports, \
import_complexity, \
copies, \
modular_conversion, \
doc_toc, \
modeling_rules_doc, \
docstrings, \
dummies, \
repo, \
inits, \
pipeline_typing, \
config_docstrings, \
config_attributes, \
doctest_list, \
update_metadata, \
add_dates, \
deps_table
ALL_CHECKERS := $(CODE_QUALITY_CHECKERS), $(REPO_CONSISTENCY_CHECKERS)
# Runs all linting/formatting scripts, most notably ruff
style:
@python utils/checkers.py $(STYLE_CHECKERS) --fix
# Runs ty type checker and model structure rules
typing:
@python utils/checkers.py $(TYPING_CHECKERS)
# Runs typing, ruff linting/formatting, import-order checks and auto-mappings
check-code-quality:
@python utils/checkers.py $(CODE_QUALITY_CHECKERS)
# Runs a full repository consistency check.
check-repository-consistency:
@python utils/checkers.py $(REPO_CONSISTENCY_CHECKERS)
# Runs typing and formatting checks + repository consistency check (ignores errors)
check-repo:
@python utils/checkers.py $(ALL_CHECKERS) --keep-going
# Run all repo checks for which there is an automatic fix, most notably modular conversions
fix-repo:
@python utils/checkers.py $(ALL_CHECKERS) --fix --keep-going
# Run tests for the library, requires pytest-random-order
test:
python -m pytest -p random_order -n auto --dist=loadfile -s -v --random-order-bucket=module ./tests/
# Run tests for examples, requires pytest-random-order
test-examples:
python -m pytest -p random_order -n auto --dist=loadfile -s -v --random-order-bucket=module ./examples/pytorch/
# Run benchmark
benchmark:
python3 benchmark/benchmark.py --config-dir benchmark/config --config-name generation --commit=diff backend.model=google/gemma-2b backend.cache_implementation=null,static backend.torch_compile=false,true --multirun
codex:
mkdir -p .agents
rm -rf .agents/skills
ln -snf ../.ai/skills .agents/skills
claude:
mkdir -p .claude
rm -rf .claude/skills
ln -snf ../.ai/skills .claude/skills
clean-ai:
rm -rf .agents/skills .claude/skills
# Release stuff
pre-release:
python utils/release.py
pre-patch:
python utils/release.py --patch
post-release:
python utils/release.py --post_release
post-patch:
python utils/release.py --post_release --patch
build-release:
rm -rf dist
rm -rf build
python setup.py bdist_wheel
python setup.py sdist