This repository was archived by the owner on Mar 31, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathTaskfile.yml
More file actions
158 lines (138 loc) · 4.33 KB
/
Taskfile.yml
File metadata and controls
158 lines (138 loc) · 4.33 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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
version: "3"
tasks:
pull_grammar:
cmds:
- curl -L https://github.com/python/cpython/raw/main/Grammar/python.gram > tasks/cpython.gram
- curl -L https://github.com/we-like-parsers/pegen/raw/main/data/python.gram > tasks/python.gram
generate-meta:
cmds:
- git checkout pegen/grammar_parser.py
- uv run python3 -m pegen pegen/metagrammar.gram -o pegen/grammar_parser.py
- ruff format pegen/grammar_parser.py
generate:
deps:
- dev
cmds:
- uv run python3 tasks/generator.py
- ruff check --fix peg_parser/parser.py
- ruff format peg_parser/parser.py
- scc peg_parser/parser.py --uloc
- ls -lh peg_parser/parser.py
generates:
- peg_parser/parser.py
sources:
- tasks/*.py
- tasks/*.gram
- pegen/*.py
check-duplicates:
cmds:
- pylint --enable=R0801 --disable=W,C,R0916,R0911,R0912,R0904 --min-similarity-lines=1 peg_parser/parser.py
- jscpd peg_parser/parser.py
profile-tasks:
cmds:
- uv run python tasks/profile_mem.py | tee -a {{.LOG_FILE}}
- uv run python tasks/simple.py | tee -a {{.LOG_FILE}}
vars:
LOG_FILE:
sh: echo ".local/logs/xonsh-parser-$(date "+%Y%m%d-%H%M%S").$(git rev-parse --short HEAD).log"
dev:
cmds:
- cd crates/winnow-parser && maturin develop
profile:
# deps:
# - profile-tasks
cmds:
- mkdir -p .local/logs
- asv run --python=same --show-stderr | tee -a {{.LOG_FILE}}
# - asv profile --python=same benchmarks.PeakMemSuite.peakmem_parser_large_file | tee -a {{.LOG_FILE}}
vars:
LOG_FILE:
sh: echo ".local/logs/xonsh-parser-$(date "+%Y%m%d-%H%M%S").$(git rev-parse --short HEAD).log"
pegen-add:
cmds:
- git fetch https://github.com/we-like-parsers/pegen.git main:tmp-pegen-main --no-tags --depth 1
- git show tmp-pegen-main:data/python.gram > .local/python.gram
- git read-tree --prefix=pegen -u tmp-pegen-main:src/pegen
test:
deps:
- generate
cmds:
- uv run python -m pytest {{.CLI_ARGS}}
# sources:
# - '**/*.py'
test-cov:
cmd: task test -- --cov=peg_parser --cov-report=html
wtest:
cmds:
- watchexec -e py,gram --clear -- task test -- --ff -x -vv --testmon
asv-bench:
cmds:
- asv run "main^!" -v
- asv publish
- asv preview
memray:
cmds:
- uv run pytest --memray
mypy1:
deps:
- generate
cmds:
- uv run mypy peg_parser
mypy:
cmds:
- watchexec -e py,toml,gram --clear -- task generate mypy1
build_dep:
cmds:
- uv run uv pip install setuptools_scm wheel
mypycify:
deps:
- build_dep
cmds:
- env COMPILE_WITH_MYPYC=1 uv pip install -e . --no-build-isolation
sources:
- peg_parser/subheader.py
- peg_parser/toke*.py
cythonize:
deps:
- build_dep
cmds:
- env COMPILE_WITH_CYTHON=1 uv pip install -e . --no-build-isolation
sources:
- peg_parser/*.py
- peg_parser/*.pxd
clean:
cmds:
- find peg_parser -name "*.so" -delete -print
- find peg_parser -name "*.c" -delete -print
- find peg_parser -name "*.html" -delete -print
release:
# https://python-semantic-release.readthedocs.io/en/latest/commands.html
cmds:
- semantic-release version --no-vcs-release {{.CLI_ARGS}}
- git push --follow-tags
pytest-bench:
cmds:
- uv run pytest tests/benchmarks.py --benchmark-only --benchmark-autosave {{.CLI_ARGS}}
bench-lexer:
deps:
- dev
cmds:
- uv run pytest tests/bench_lexer.py --benchmark-only --benchmark-autosave {{.CLI_ARGS}}
pytest-bench-plot:
desc: Generate an SVG histogram of all recorded benchmarks
cmds:
- pytest-benchmark compare .benchmarks/* --histogram history_plot
pytest-bench-trend:
desc: Generate a PNG trend chart of the PegenParser large file benchmark
cmds:
- uv run python3 plot_benchmarks.py "tests/benchmarks.py::test_large_file[PegenParser]"
hyperfine:
desc: compare pegen and treesitter
cmds:
- hyperfine
"uv run pytest tests/benchmarks.py::test_large_file[PegenParser]"
"uv run pytest tests/benchmarks.py::test_large_file[RuffParser]"
"uv run pytest tests/benchmarks.py::test_large_file[TreeSitter]"
-n pegen
-n ruff
-n treesitter