Commit 6ba4b7d
authored
Add file status to tutorial statistics (#6912)
This PR adds file status information Added (A), Copied (C), Deleted (D),
Modified (M), Renamed (R) to the tutorial statistics tracking. The
change enhances the `get_tutorials_stats.py` script to capture Git
status information using the `--name-status` flag and store it in the
`filenames.csv` output.
Changes:
* Added status field to FileInfo class
* Modified file parsing logic to extract status information from Git
output
* Status is now included in the **filenames.csv** output for each file
Local test generates this `filenames.csv`:
| commit_id | date | filename | lines_added | lines_deleted | status |
|-----------|------|----------|-------------|---------------|--------|
| 7c45ceb313 | 2025-07-11 | tutorials/index.rst | 17 | 171 | M |
| f4dda5dca1 | 2025-07-10 | tutorials/conf.py | 4 | 2 | M |
| 3569db3e78 | 2025-07-10 | tutorials/conf.py | 0 | 1 | M |
...
How to test:
1. Comment out the part that uploads to S3
2. Add save to local file:
```
def save_to_local_file(filename: str, docs: list[dict[str, Any]]) ->
None:
print(f"Writing {len(docs)} documents to {filename}")
with open(filename, "w", newline="") as f:
writer = csv.DictWriter(f, fieldnames=sorted(docs[0].keys()))
writer.writeheader()
writer.writerows(docs)
print(f"Done writing to {filename}")
```
4. Add this to main:
```
save_to_local_file("metadata.csv", history_log)
save_to_local_file("filenames.csv", filenames)
```
5. Make sure the tutorias_dir and pytorch_doc_dir point to the correct
location of tutorials and pytorch repos.1 parent 68ed115 commit 6ba4b7d
1 file changed
Lines changed: 63 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
103 | 103 | | |
104 | 104 | | |
105 | 105 | | |
| 106 | + | |
106 | 107 | | |
107 | 108 | | |
108 | 109 | | |
| |||
123 | 124 | | |
124 | 125 | | |
125 | 126 | | |
126 | | - | |
127 | 127 | | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
128 | 140 | | |
129 | 141 | | |
130 | 142 | | |
| |||
134 | 146 | | |
135 | 147 | | |
136 | 148 | | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
137 | 152 | | |
138 | 153 | | |
139 | 154 | | |
140 | | - | |
| 155 | + | |
141 | 156 | | |
142 | | - | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
143 | 202 | | |
144 | 203 | | |
145 | 204 | | |
| |||
153 | 212 | | |
154 | 213 | | |
155 | 214 | | |
| 215 | + | |
156 | 216 | | |
157 | 217 | | |
158 | 218 | | |
| |||
0 commit comments