Commit 03613a0
authored
feat(cli): add --pretty-headings flag (#36)
### Relevant issue or PR
Closes #22.
### Description of changes
Add a `--pretty-headings/--no-pretty-headings` flag to the CLI, such
that formatting on the parameter names in the Web UI can be toggled on
and off.
This is useful in instances where Tesseracts have parameter names which
differ only in case.
In the process, `_parse_tesseract_oas()` was refactored, so the
formatting logic for input fields is easier to separate from the
recursive logic of traversing the OAS tree. This was done by extracted
formatting logic in a function called `_format_field()`.
### Testing done
Manual testing.
Example:
`tesseract_api.py`:
```python
from pydantic import BaseModel, Field
class InputSchema(BaseModel):
dummy_input: str = Field(description="Meaningless input", default="Dummy")
this_is_a_long_one: str = Field(description="Pretty long", default="Oh my")
THIS_IS_A_LONG_ONE: str = Field(description="Also long", default="Oh gosh")
This_Is_A_Long_One: str = Field(description="Long, too", default="Oh darn")
class OutputSchema(BaseModel):
dummy_output: str = Field(description="Meaningless output")
wizard: str = Field(description="Magic", default="kadabra")
Wizard: str = Field(description="Runes and stuff", default="presto!")
def apply(inputs: InputSchema) -> OutputSchema:
"""Run for 4 seconds before returning dummy output."""
return OutputSchema(
dummy_output="This is meaningless"
)
```
#### Pretty headings on (default)
```bash
tesseract-streamlit --pretty-headings "http://localhost:50262" app.py # this is default
streamlit run app.py
```
<img width="584" height="860" alt="image"
src="https://github.com/user-attachments/assets/c077c010-e3ff-477c-a845-03502686e0a7"
/>
#### Pretty headings off
```bash
tesseract-streamlit --no-pretty-headings "http://localhost:50262" app.py
streamlit run app.py
```
<img width="590" height="859" alt="image"
src="https://github.com/user-attachments/assets/e8e19bbc-6ac2-4184-87e7-9e28678064ae"
/>1 parent 1af8e67 commit 03613a0
File tree
3 files changed
+84
-32
lines changed- tesseract_streamlit
- tests
3 files changed
+84
-32
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
51 | 61 | | |
52 | 62 | | |
53 | 63 | | |
| |||
70 | 80 | | |
71 | 81 | | |
72 | 82 | | |
73 | | - | |
| 83 | + | |
74 | 84 | | |
75 | 85 | | |
76 | 86 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
275 | 275 | | |
276 | 276 | | |
277 | 277 | | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
278 | 328 | | |
279 | 329 | | |
280 | 330 | | |
281 | 331 | | |
| 332 | + | |
282 | 333 | | |
283 | 334 | | |
284 | 335 | | |
| |||
299 | 350 | | |
300 | 351 | | |
301 | 352 | | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
302 | 357 | | |
303 | 358 | | |
304 | 359 | | |
| |||
309 | 364 | | |
310 | 365 | | |
311 | 366 | | |
312 | | - | |
313 | | - | |
314 | | - | |
315 | | - | |
316 | | - | |
317 | | - | |
318 | | - | |
319 | | - | |
320 | | - | |
321 | | - | |
322 | | - | |
323 | | - | |
324 | | - | |
325 | | - | |
326 | | - | |
327 | | - | |
328 | | - | |
329 | | - | |
330 | | - | |
331 | | - | |
332 | | - | |
333 | | - | |
334 | | - | |
335 | | - | |
336 | | - | |
337 | | - | |
| 367 | + | |
338 | 368 | | |
| 369 | + | |
| 370 | + | |
339 | 371 | | |
340 | | - | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
341 | 375 | | |
342 | 376 | | |
343 | 377 | | |
| |||
403 | 437 | | |
404 | 438 | | |
405 | 439 | | |
406 | | - | |
| 440 | + | |
407 | 441 | | |
408 | 442 | | |
409 | 443 | | |
| |||
413 | 447 | | |
414 | 448 | | |
415 | 449 | | |
| 450 | + | |
| 451 | + | |
416 | 452 | | |
417 | 453 | | |
418 | 454 | | |
| |||
429 | 465 | | |
430 | 466 | | |
431 | 467 | | |
432 | | - | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
433 | 471 | | |
434 | 472 | | |
435 | 473 | | |
| |||
466 | 504 | | |
467 | 505 | | |
468 | 506 | | |
| 507 | + | |
469 | 508 | | |
470 | 509 | | |
471 | 510 | | |
| |||
477 | 516 | | |
478 | 517 | | |
479 | 518 | | |
| 519 | + | |
480 | 520 | | |
481 | 521 | | |
482 | 522 | | |
483 | 523 | | |
484 | 524 | | |
485 | 525 | | |
486 | 526 | | |
487 | | - | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
488 | 530 | | |
489 | 531 | | |
490 | 532 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
0 commit comments