Skip to content

Commit 92d49b3

Browse files
committed
Update
1 parent 2f731b5 commit 92d49b3

4 files changed

Lines changed: 78 additions & 16 deletions

File tree

.github/workflows/_build-tutorials-base.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ jobs:
210210
if: always()
211211
shell: bash
212212
run: |
213-
python -m tools.deprecation_checker.api_report \
213+
python3 -m tools.deprecation_checker.api_report \
214214
--build-log _build/build.log \
215215
-o _build/api_report.md \
216216
--create-issue || true

.jenkins/build.sh

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -164,13 +164,8 @@ elif [[ "${JOB_TYPE}" == "manager" ]]; then
164164
# Step 5.1: Run post-processing script on .ipynb files:
165165
python .jenkins/post_process_notebooks.py
166166

167-
# Step 5.2: Merge build logs from all workers and create/update GitHub Issue
168-
mkdir -p _build
169-
for ((worker_id=1;worker_id<NUM_WORKERS+1;worker_id++)); do
170-
awsv2 s3 cp s3://${BUCKET_NAME}/${BUILD_PREFIX}/${COMMIT_ID}/build_log_${worker_id}.txt _build/build_log_${worker_id}.txt || true
171-
done
172-
cat _build/build_log_*.txt > _build/build.log 2>/dev/null || true
173-
python -m tools.deprecation_checker.api_report --build-log _build/build.log -o _build/api_report.md --create-issue || true
167+
# Step 5.2: API deprecation report is generated by the GHA workflow after
168+
# merging worker build logs from artifacts. See _build-tutorials-base.yml.
174169

175170
# Step 6: Copy generated HTML files and static files to S3
176171
7z a manager.7z docs

tools/deprecation_checker/api_report.py

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
from pathlib import Path
3131
from typing import List
3232

33-
from .build_warning_parser import BuildWarning, is_tutorial_source, parse_log
33+
from .build_warning_parser import BuildWarning, classify_dependency, is_tutorial_source, parse_log
3434

3535
# --------------------------------------------------------------------------- #
3636
# Constants
@@ -117,11 +117,32 @@ def generate_report(warnings: List[BuildWarning]) -> str:
117117
"",
118118
]
119119

120-
if other_warnings:
120+
# Classify dependency warnings
121+
pytorch_warnings = [w for w in other_warnings if classify_dependency(w.file) == "pytorch"]
122+
pytorch_lib_warnings = [w for w in other_warnings if classify_dependency(w.file) == "pytorch_libs"]
123+
third_party_warnings = [w for w in other_warnings if classify_dependency(w.file) == "third_party"]
124+
125+
if pytorch_warnings:
126+
parts += [
127+
"## PyTorch warnings",
128+
"",
129+
_findings_section(pytorch_warnings),
130+
"",
131+
]
132+
133+
if pytorch_lib_warnings:
134+
parts += [
135+
"## PyTorch libraries warnings",
136+
"",
137+
_findings_section(pytorch_lib_warnings),
138+
"",
139+
]
140+
141+
if third_party_warnings:
121142
parts += [
122-
"## Warnings from dependencies / non-tutorial code",
143+
"## Third-party dependency warnings",
123144
"",
124-
_findings_section(other_warnings),
145+
_findings_section(third_party_warnings),
125146
"",
126147
]
127148

tools/deprecation_checker/build_warning_parser.py

Lines changed: 50 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,15 @@
1111
from pathlib import Path
1212
from typing import List
1313

14+
# Strip ANSI escape sequences and carriage-return progress lines
15+
_ANSI_RE = re.compile(r"\x1b\[[0-9;]*[A-Za-z]")
16+
1417
# Matches standard Python warning output:
1518
# /path/to/file.py:42: DeprecationWarning: some message
19+
# <unknown>:2: DeprecationWarning: invalid escape sequence '\s'
1620
# The message may span continuation lines (indented), but we grab the first line.
1721
_WARNING_RE = re.compile(
18-
r"^(?P<path>.+?\.py):(?P<lineno>\d+):\s+"
22+
r"(?P<path>/?[^\s:]+\.py|<unknown>):(?P<lineno>\d+):\s+"
1923
r"(?P<category>DeprecationWarning|FutureWarning):\s+"
2024
r"(?P<message>.+)$"
2125
)
@@ -68,14 +72,20 @@ def parse_log(log_path: str | Path) -> List[BuildWarning]:
6872
repeating the same warning 50 times.
6973
"""
7074
log_path = Path(log_path)
71-
if not log_path.exists():
75+
try:
76+
text = log_path.read_text(errors="replace")
77+
except FileNotFoundError:
7278
return []
7379

7480
seen: dict[tuple[str, str], BuildWarning] = {}
7581
warnings: list[BuildWarning] = []
7682

77-
for line in log_path.read_text(errors="replace").splitlines():
78-
m = _WARNING_RE.match(line)
83+
for line in text.splitlines():
84+
# Strip ANSI escapes and split on \r to handle progress-line overwriting
85+
line = _ANSI_RE.sub("", line)
86+
if "\r" in line:
87+
line = line.rsplit("\r", 1)[-1]
88+
m = _WARNING_RE.search(line)
7989
if m is None:
8090
continue
8191

@@ -101,3 +111,39 @@ def parse_log(log_path: str | Path) -> List[BuildWarning]:
101111
def is_tutorial_source(path: str) -> bool:
102112
"""Return True if *path* belongs to a known tutorial source directory."""
103113
return any(path.startswith(d) for d in _SOURCE_DIRS)
114+
115+
116+
# Package prefixes that belong to PyTorch core
117+
_PYTORCH_CORE_PACKAGES = (
118+
"/torch/",
119+
"torch/",
120+
)
121+
122+
# Package prefixes for PyTorch ecosystem libraries
123+
_PYTORCH_LIB_PACKAGES = (
124+
"/torchvision/",
125+
"/torchaudio/",
126+
"/torchtext/",
127+
"/torchrl/",
128+
"/tensordict/",
129+
"/torchdata/",
130+
"/torchtune/",
131+
"/torchtitan/",
132+
"/functorch/",
133+
"/torch_xla/",
134+
"/executorch/",
135+
)
136+
137+
138+
def classify_dependency(path: str) -> str:
139+
"""Classify a non-tutorial warning path into a dependency category.
140+
141+
Returns one of: ``"pytorch"``, ``"pytorch_libs"``, ``"third_party"``.
142+
"""
143+
for prefix in _PYTORCH_CORE_PACKAGES:
144+
if prefix in path:
145+
return "pytorch"
146+
for prefix in _PYTORCH_LIB_PACKAGES:
147+
if prefix in path:
148+
return "pytorch_libs"
149+
return "third_party"

0 commit comments

Comments
 (0)