Repository navigation
Commit e3ee8fa
committed
Make save and save_pte_program raise when a write fails
`ExecutorchProgramManager.save` caught any error from the write, logged it and returned normally.
`save_pte_program` did the same for the `.pte` and the `.ptd` files, and then returned the path of a
file that might be empty or cut short. A caller had no way to notice, short of reading the log.
Now both let the error reach the caller. `save` still logs the path when it succeeds.
`save_pte_program` now writes the `.pte` through `save` instead of repeating its code, so both
paths behave the same way.
Behavior change for callers:
- `save` and `save_pte_program` raise on a failed write, where they used to log and return.
- `save_pte_program` needs an object with `save`, as its type hint already says
(`ExecutorchProgramManager`). The legacy `ExecutorchProgram` that the deprecated
`exir.capture(...).to_edge().to_executorch()` path returns has no `save`, so passing it now
raises `AttributeError` instead of writing the file. Such code can call the legacy object's own
`write_to_file` instead.
Test plan: `exir/program/test/test_program.py`. New tests check that `save` raises when the write
fails, and that `save_pte_program` writes the `.pte` and `.ptd` files, returns the path, and raises
when either write fails. Both fail on the code before this change.1 parent 3d17551 commit e3ee8fa
4 files changed
Lines changed: 45 additions & 15 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2070 | 2070 | | |
2071 | 2071 | | |
2072 | 2072 | | |
2073 | | - | |
2074 | | - | |
2075 | | - | |
2076 | | - | |
2077 | | - | |
2078 | | - | |
| 2073 | + | |
| 2074 | + | |
| 2075 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| 27 | + | |
27 | 28 | | |
28 | 29 | | |
29 | 30 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
| 11 | + | |
10 | 12 | | |
11 | 13 | | |
| 14 | + | |
12 | 15 | | |
13 | 16 | | |
14 | 17 | | |
| 18 | + | |
15 | 19 | | |
16 | 20 | | |
17 | 21 | | |
| |||
31 | 35 | | |
32 | 36 | | |
33 | 37 | | |
| 38 | + | |
34 | 39 | | |
35 | 40 | | |
36 | 41 | | |
| |||
1226 | 1231 | | |
1227 | 1232 | | |
1228 | 1233 | | |
| 1234 | + | |
| 1235 | + | |
| 1236 | + | |
| 1237 | + | |
| 1238 | + | |
| 1239 | + | |
| 1240 | + | |
| 1241 | + | |
| 1242 | + | |
| 1243 | + | |
| 1244 | + | |
| 1245 | + | |
| 1246 | + | |
| 1247 | + | |
| 1248 | + | |
| 1249 | + | |
| 1250 | + | |
| 1251 | + | |
| 1252 | + | |
| 1253 | + | |
| 1254 | + | |
| 1255 | + | |
| 1256 | + | |
| 1257 | + | |
| 1258 | + | |
| 1259 | + | |
| 1260 | + | |
| 1261 | + | |
| 1262 | + | |
| 1263 | + | |
| 1264 | + | |
| 1265 | + | |
| 1266 | + | |
| 1267 | + | |
1229 | 1268 | | |
1230 | 1269 | | |
1231 | 1270 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
141 | 141 | | |
142 | 142 | | |
143 | 143 | | |
144 | | - | |
145 | | - | |
146 | | - | |
147 | | - | |
148 | | - | |
149 | | - | |
150 | | - | |
151 | | - | |
152 | | - | |
| 144 | + | |
| 145 | + | |
153 | 146 | | |
154 | 147 | | |
0 commit comments