Commit 590155c
authored
feat: Validate endpoint argument names before building (#95)
BREAKING CHANGE: Custom argument names for any endpoint are no longer
supported. All endpoint argument names and order must exactly match
standard.
#### Relevant issue or PR
- #84
#### Description of changes
We already validate whether endpoint signature have the correct number
of arguments in `sdk.api_parse`. In addition to suppressing unnecessary
traceback and improving the error message when this is violated, this PR
provides validation of the endpoint signature argument _names_ and order
before building. This guards against the possibility that arguments may
have been misordered leading to potential silent fails and guarantees
that natural dev assumptions on the endpoint signatures hold.
Note it is not possible to provide this with `tesseract-runtime check`
(or other endpoints) as the runtime does not have access to the sdk. I'm
comfortable with this as we can add runtime errors in a different way by
reviving #80. Alternatively, we move `api_parse` to `runtime` allowing
it to be accessed by `tesseract-runtime check`.
#### Missing argument error message
```
[-] Error validating tesseract_api.py: jacobian_vector_product must have 4 arguments: inputs, jvp_inputs, jvp_outputs, tangent_vector.
However, tesseract_api.py specifies 3 arguments: inputs, jvp_outputs, tangent_vector.
[x] Aborting
```
#### Wrong argument name error message
```
[-] Error validating tesseract_api.py: The second argument of jacobian_vector_product must be named jvp_inputs, but tesseract_api.py has named it jvp_input.
[x] Aborting
```
#### Testing done
- [x] Removed an input, error message as above
- [x] Misspelled an input, error message as above
- [x] CI passes
#### License
- [x] By submitting this pull request, I confirm that my contribution is
made under the terms of the [Apache 2.0
license](https://pasteurlabs.github.io/tesseract/LICENSE).
- [x] I sign the Developer Certificate of Origin below by adding my name
and email address to the `Signed-off-by` line.
<details>
<summary><b>Developer Certificate of Origin</b></summary>
```text
Developer Certificate of Origin
Version 1.1
Copyright (C) 2004, 2006 The Linux Foundation and its contributors.
Everyone is permitted to copy and distribute verbatim copies of this
license document, but changing it is not allowed.
Developer's Certificate of Origin 1.1
By making a contribution to this project, I certify that:
(a) The contribution was created in whole or in part by me and I
have the right to submit it under the open source license
indicated in the file; or
(b) The contribution is based upon previous work that, to the best
of my knowledge, is covered under an appropriate open source
license and I have the right under that license to submit that
work with modifications, whether created in whole or in part
by me, under the same open source license (unless I am
permitted to submit under a different license), as indicated
in the file; or
(c) The contribution was provided directly to me by some other
person who certified (a), (b) or (c) and I have not modified
it.
(d) I understand and agree that this project and the contribution
are public and that a record of the contribution (including all
personal information I submit with it, including my sign-off) is
maintained indefinitely and may be redistributed consistent with
this project or the open source license(s) involved.
```
</details>
Signed-off-by: Jonathan Brodrick <jonathan.brodrick@simulation.science>1 parent 2ebafd0 commit 590155c
File tree
6 files changed
+65
-20
lines changed- examples/vectoradd_torch
- tesseract_core/sdk
- templates/pytorch
- tests/runtime_tests
6 files changed
+65
-20
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
150 | 150 | | |
151 | 151 | | |
152 | 152 | | |
153 | | - | |
| 153 | + | |
154 | 154 | | |
155 | | - | |
156 | | - | |
| 155 | + | |
| 156 | + | |
157 | 157 | | |
158 | 158 | | |
159 | 159 | | |
160 | | - | |
| 160 | + | |
161 | 161 | | |
162 | 162 | | |
163 | 163 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| 24 | + | |
24 | 25 | | |
25 | 26 | | |
26 | 27 | | |
| 28 | + | |
| 29 | + | |
27 | 30 | | |
28 | | - | |
| 31 | + | |
29 | 32 | | |
30 | 33 | | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
| 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 | + | |
35 | 62 | | |
36 | 63 | | |
37 | 64 | | |
| |||
112 | 139 | | |
113 | 140 | | |
114 | 141 | | |
115 | | - | |
116 | | - | |
| 142 | + | |
| 143 | + | |
117 | 144 | | |
118 | 145 | | |
119 | 146 | | |
| |||
128 | 155 | | |
129 | 156 | | |
130 | 157 | | |
131 | | - | |
| 158 | + | |
132 | 159 | | |
133 | 160 | | |
134 | 161 | | |
| |||
190 | 217 | | |
191 | 218 | | |
192 | 219 | | |
193 | | - | |
194 | | - | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
195 | 237 | | |
196 | 238 | | |
197 | 239 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
| 36 | + | |
36 | 37 | | |
37 | 38 | | |
38 | 39 | | |
| |||
307 | 308 | | |
308 | 309 | | |
309 | 310 | | |
| 311 | + | |
| 312 | + | |
310 | 313 | | |
311 | 314 | | |
312 | 315 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
109 | 109 | | |
110 | 110 | | |
111 | 111 | | |
112 | | - | |
| 112 | + | |
113 | 113 | | |
114 | | - | |
115 | | - | |
| 114 | + | |
| 115 | + | |
116 | 116 | | |
117 | 117 | | |
118 | 118 | | |
119 | | - | |
| 119 | + | |
120 | 120 | | |
121 | 121 | | |
122 | 122 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
105 | 105 | | |
106 | 106 | | |
107 | 107 | | |
108 | | - | |
| 108 | + | |
109 | 109 | | |
110 | 110 | | |
111 | 111 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
179 | 179 | | |
180 | 180 | | |
181 | 181 | | |
182 | | - | |
| 182 | + | |
183 | 183 | | |
184 | 184 | | |
185 | 185 | | |
| |||
0 commit comments