|
| 1 | +# Examples |
| 2 | + |
| 3 | +These examples are organized as a recommended learning path rather than a flat list. |
| 4 | + |
| 5 | +## Recommended Reading Order |
| 6 | + |
| 7 | +1. `annotated_schema.py` |
| 8 | + - Start here if you want to learn the declaration style first. |
| 9 | + - Shows the modern `Annotated[..., Field(...), ExcelMeta(...)]` pattern. |
| 10 | +2. `employee_import_workflow.py` |
| 11 | + - Read this next if you want to understand the core import story. |
| 12 | + - Shows template generation, workbook upload, import execution, and result reporting. |
| 13 | +3. `create_or_update_import.py` |
| 14 | + - Read this after the basic import flow. |
| 15 | + - Shows `ImporterConfig.for_create_or_update(...)` with `is_data_exist`, `creator`, and `updater`. |
| 16 | +4. `export_workflow.py` |
| 17 | + - Read this once the import flow is clear. |
| 18 | + - Shows artifact generation, export uploads, and a custom storage-backed export task. |
| 19 | +5. `custom_storage.py` |
| 20 | + - Read this when you want to implement your own `ExcelStorage`. |
| 21 | + - Keeps the example minimal and focused on the protocol boundary. |
| 22 | +6. `date_and_range_fields.py` |
| 23 | + - Read this if you want to understand workbook-friendly date, date range, number range, and money fields. |
| 24 | +7. `selection_fields.py` |
| 25 | + - Read this if your domain uses approval forms, assignments, ownership trees, or selection-heavy templates. |
| 26 | +8. `minio_storage.py` |
| 27 | + - Read this if you need the built-in Minio path in the current 2.x line. |
| 28 | + - This reflects the current 2.x compatibility-based Minio path rather than a future 3.x-only storage story. |
| 29 | +9. `fastapi_upload.py` |
| 30 | + - Read this last as an integration sketch. |
| 31 | + - It is useful once the import and storage examples already make sense. |
| 32 | + |
| 33 | +## By Goal |
| 34 | + |
| 35 | +- Learn the declaration style: |
| 36 | + - `annotated_schema.py` |
| 37 | +- Learn the core import flow: |
| 38 | + - `employee_import_workflow.py` |
| 39 | + - `create_or_update_import.py` |
| 40 | +- Learn export and storage integration: |
| 41 | + - `export_workflow.py` |
| 42 | + - `custom_storage.py` |
| 43 | + - `minio_storage.py` |
| 44 | +- Learn field families: |
| 45 | + - `date_and_range_fields.py` |
| 46 | + - `selection_fields.py` |
| 47 | +- Learn web integration: |
| 48 | + - `fastapi_upload.py` |
| 49 | + |
| 50 | +## Storage and Backend Integration |
| 51 | + |
| 52 | +- `custom_storage.py` |
| 53 | + - Shows a minimal custom `ExcelStorage` implementation for export uploads. |
| 54 | +- `export_workflow.py` |
| 55 | + - Shows a realistic export flow with artifact generation and upload. |
| 56 | +- `minio_storage.py` |
| 57 | + - Shows the built-in Minio-backed storage path currently available in the 2.x line. |
| 58 | +- `fastapi_upload.py` |
| 59 | + - Shows a FastAPI integration sketch for template download and workbook import. |
| 60 | + |
| 61 | +## How To Run |
| 62 | + |
| 63 | +Run examples from the repository root: |
| 64 | + |
| 65 | +```bash |
| 66 | +uv run python examples/annotated_schema.py |
| 67 | +uv run python examples/employee_import_workflow.py |
| 68 | +uv run python examples/create_or_update_import.py |
| 69 | +uv run python examples/date_and_range_fields.py |
| 70 | +uv run python examples/selection_fields.py |
| 71 | +uv run python examples/custom_storage.py |
| 72 | +uv run python examples/export_workflow.py |
| 73 | +uv run python examples/minio_storage.py |
| 74 | +``` |
| 75 | + |
| 76 | +If you want to try the FastAPI sketch, install FastAPI first and then run your |
| 77 | +preferred ASGI server against `examples.fastapi_upload:app`. |
| 78 | + |
| 79 | +## Notes |
| 80 | + |
| 81 | +- The examples intentionally use in-memory storage so they stay self-contained. |
| 82 | +- They are meant to show the recommended public API shape for the stable 2.x |
| 83 | + line. |
| 84 | +- If you want a production backend, prefer `storage=...` with |
| 85 | + `MinioStorageGateway` or your own `ExcelStorage` implementation. |
| 86 | +- The built-in `minio_storage.py` example reflects the current 2.x Minio path, |
| 87 | + which still uses the compatibility configuration fields under the hood. |
| 88 | +- The smoke tests in `tests/integration/test_examples_smoke.py` cover the main |
| 89 | + example entry points directly. |
0 commit comments