| 1 |
Data Processing Commands |
| 2 |
======================== |
| 3 |
|
| 4 |
Data processing commands that demonstrate **dataclass parameter flattening**. |
| 5 |
|
| 6 |
When using ``@Parameter(name="*")`` on a dataclass, all its fields become |
| 7 |
individual CLI options. This page shows how this appears in documentation. |
| 8 |
|
| 9 |
Data Commands |
| 10 |
------------- |
| 11 |
|
| 12 |
.. cyclopts:: complex_app:app |
| 13 |
:heading-level: 3 |
| 14 |
:recursive: |
| 15 |
:commands: data |
| 16 |
|
| 17 |
Understanding Dataclass Flattening |
| 18 |
---------------------------------- |
| 19 |
|
| 20 |
The ``process`` command accepts two dataclass parameters: |
| 21 |
|
| 22 |
* ``ProcessingConfig`` - Controls batch size, workers, quality, device, etc. |
| 23 |
* ``PathConfig`` - Controls input/output directories |
| 24 |
|
| 25 |
Instead of requiring complex nested syntax, these become flat CLI options:: |
| 26 |
|
| 27 |
$ complex-cli data process file1.txt file2.txt \ |
| 28 |
--batch-size 64 \ |
| 29 |
--num-workers auto \ |
| 30 |
--quality-level high \ |
| 31 |
--input-dir ./input \ |
| 32 |
--output-dir ./output |
| 33 |
|
| 34 |
Nested Dataclasses |
| 35 |
------------------ |
| 36 |
|
| 37 |
The ``pipeline`` command demonstrates **nested dataclass flattening** where |
| 38 |
``PipelineConfig`` contains both ``PathConfig`` and ``ProcessingConfig``. |