pileorder 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (81) hide show
  1. pileorder-0.1.0/.env.example +4 -0
  2. pileorder-0.1.0/.gitignore +31 -0
  3. pileorder-0.1.0/LICENSE +21 -0
  4. pileorder-0.1.0/PKG-INFO +190 -0
  5. pileorder-0.1.0/README.md +161 -0
  6. pileorder-0.1.0/docs/ARCHITECTURE.md +374 -0
  7. pileorder-0.1.0/examples/clothing/SOURCE.md +24 -0
  8. pileorder-0.1.0/examples/clothing/categories.txt +11 -0
  9. pileorder-0.1.0/examples/clothing/job.yaml +41 -0
  10. pileorder-0.1.0/examples/clothing/labels.csv +51 -0
  11. pileorder-0.1.0/examples/clothing/score.py +55 -0
  12. pileorder-0.1.0/pyproject.toml +58 -0
  13. pileorder-0.1.0/src/pileorder/__init__.py +3 -0
  14. pileorder-0.1.0/src/pileorder/adapters/__init__.py +5 -0
  15. pileorder-0.1.0/src/pileorder/adapters/images.py +94 -0
  16. pileorder-0.1.0/src/pileorder/adapters/registry.py +12 -0
  17. pileorder-0.1.0/src/pileorder/app.py +177 -0
  18. pileorder-0.1.0/src/pileorder/checks/__init__.py +10 -0
  19. pileorder-0.1.0/src/pileorder/checks/builtin.py +138 -0
  20. pileorder-0.1.0/src/pileorder/checks/registry.py +19 -0
  21. pileorder-0.1.0/src/pileorder/cli.py +206 -0
  22. pileorder-0.1.0/src/pileorder/data/__init__.py +0 -0
  23. pileorder-0.1.0/src/pileorder/data/prices.yaml +18 -0
  24. pileorder-0.1.0/src/pileorder/engine/__init__.py +18 -0
  25. pileorder-0.1.0/src/pileorder/engine/actions/__init__.py +11 -0
  26. pileorder-0.1.0/src/pileorder/engine/actions/call.py +37 -0
  27. pileorder-0.1.0/src/pileorder/engine/actions/ingest.py +86 -0
  28. pileorder-0.1.0/src/pileorder/engine/actions/prepare.py +68 -0
  29. pileorder-0.1.0/src/pileorder/engine/orchestrator.py +178 -0
  30. pileorder-0.1.0/src/pileorder/engine/planner.py +55 -0
  31. pileorder-0.1.0/src/pileorder/engine/prompt.py +41 -0
  32. pileorder-0.1.0/src/pileorder/engine/retry.py +44 -0
  33. pileorder-0.1.0/src/pileorder/engine/scanner.py +88 -0
  34. pileorder-0.1.0/src/pileorder/engine/validation.py +54 -0
  35. pileorder-0.1.0/src/pileorder/engine/worker.py +54 -0
  36. pileorder-0.1.0/src/pileorder/env.py +25 -0
  37. pileorder-0.1.0/src/pileorder/errors.py +59 -0
  38. pileorder-0.1.0/src/pileorder/export/__init__.py +16 -0
  39. pileorder-0.1.0/src/pileorder/export/files.py +85 -0
  40. pileorder-0.1.0/src/pileorder/export/rows.py +40 -0
  41. pileorder-0.1.0/src/pileorder/interfaces.py +85 -0
  42. pileorder-0.1.0/src/pileorder/job/__init__.py +6 -0
  43. pileorder-0.1.0/src/pileorder/job/compiler.py +194 -0
  44. pileorder-0.1.0/src/pileorder/job/loader.py +38 -0
  45. pileorder-0.1.0/src/pileorder/job/prices.py +41 -0
  46. pileorder-0.1.0/src/pileorder/job/raw_models.py +153 -0
  47. pileorder-0.1.0/src/pileorder/job/schema_builder.py +86 -0
  48. pileorder-0.1.0/src/pileorder/manifest/__init__.py +13 -0
  49. pileorder-0.1.0/src/pileorder/manifest/schema.sql +47 -0
  50. pileorder-0.1.0/src/pileorder/manifest/store.py +497 -0
  51. pileorder-0.1.0/src/pileorder/models/__init__.py +68 -0
  52. pileorder-0.1.0/src/pileorder/models/chunk.py +135 -0
  53. pileorder-0.1.0/src/pileorder/models/job.py +125 -0
  54. pileorder-0.1.0/src/pileorder/models/run.py +119 -0
  55. pileorder-0.1.0/src/pileorder/models/unit.py +67 -0
  56. pileorder-0.1.0/src/pileorder/plugins.py +83 -0
  57. pileorder-0.1.0/src/pileorder/providers/__init__.py +23 -0
  58. pileorder-0.1.0/src/pileorder/providers/dry_run.py +22 -0
  59. pileorder-0.1.0/src/pileorder/providers/fake.py +127 -0
  60. pileorder-0.1.0/src/pileorder/providers/openai_chat.py +152 -0
  61. pileorder-0.1.0/src/pileorder/providers/tokens.py +178 -0
  62. pileorder-0.1.0/src/pileorder/report/__init__.py +15 -0
  63. pileorder-0.1.0/src/pileorder/report/builder.py +72 -0
  64. pileorder-0.1.0/src/pileorder/report/cost.py +38 -0
  65. pileorder-0.1.0/src/pileorder/report/renderers/__init__.py +5 -0
  66. pileorder-0.1.0/src/pileorder/report/renderers/markdown.py +124 -0
  67. pileorder-0.1.0/tests/__init__.py +0 -0
  68. pileorder-0.1.0/tests/conftest.py +56 -0
  69. pileorder-0.1.0/tests/test_checks.py +93 -0
  70. pileorder-0.1.0/tests/test_cli.py +50 -0
  71. pileorder-0.1.0/tests/test_images_adapter.py +66 -0
  72. pileorder-0.1.0/tests/test_job_compiler.py +156 -0
  73. pileorder-0.1.0/tests/test_openai_provider.py +148 -0
  74. pileorder-0.1.0/tests/test_output.py +228 -0
  75. pileorder-0.1.0/tests/test_planner.py +73 -0
  76. pileorder-0.1.0/tests/test_run.py +277 -0
  77. pileorder-0.1.0/tests/test_scale.py +152 -0
  78. pileorder-0.1.0/tests/test_scanner.py +160 -0
  79. pileorder-0.1.0/tests/test_schema_builder.py +62 -0
  80. pileorder-0.1.0/tests/test_tokens.py +100 -0
  81. pileorder-0.1.0/uv.lock +725 -0
@@ -0,0 +1,4 @@
1
+ # Copy to .env and fill in. Never commit .env.
2
+ OPENAI_API_KEY=
3
+ # Optional: an OpenAI-compatible endpoint instead of api.openai.com (leave empty for OpenAI).
4
+ OPENAI_BASE_URL=
@@ -0,0 +1,31 @@
1
+ # Python
2
+ __pycache__/
3
+ *.py[cod]
4
+ *.egg-info/
5
+ build/
6
+ dist/
7
+ .venv/
8
+ .pytest_cache/
9
+ .ruff_cache/
10
+ .mypy_cache/
11
+
12
+ # Secrets
13
+ .env
14
+ .env.*
15
+ !.env.example
16
+
17
+ # Run state and outputs
18
+ .pileorder/
19
+ out/
20
+ *.sqlite
21
+ *.sqlite-journal
22
+ *.sqlite-wal
23
+ *.sqlite-shm
24
+
25
+ # Demo data is downloaded, not committed
26
+ examples/*/data/
27
+
28
+ # OS / editors
29
+ .DS_Store
30
+ .idea/
31
+ .vscode/
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Oleh Ponomarenko
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,190 @@
1
+ Metadata-Version: 2.5
2
+ Name: pileorder
3
+ Version: 0.1.0
4
+ Summary: Turn folders of images into structured, checked data with AI: sample run with a cost estimate, resumable batch runs, CSV / JSON export.
5
+ Project-URL: Homepage, https://github.com/01egP/pileorder
6
+ Project-URL: Source, https://github.com/01egP/pileorder
7
+ Project-URL: Issues, https://github.com/01egP/pileorder/issues
8
+ Project-URL: Architecture, https://github.com/01egP/pileorder/blob/main/docs/ARCHITECTURE.md
9
+ License-Expression: MIT
10
+ License-File: LICENSE
11
+ Keywords: batch-processing,cli,data-extraction,etl,image-classification,llm,openai,product-catalog,structured-output,vision
12
+ Classifier: Development Status :: 3 - Alpha
13
+ Classifier: Environment :: Console
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: Operating System :: OS Independent
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3 :: Only
18
+ Classifier: Programming Language :: Python :: 3.13
19
+ Classifier: Programming Language :: Python :: 3.14
20
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
21
+ Classifier: Topic :: Scientific/Engineering :: Image Recognition
22
+ Requires-Python: >=3.11
23
+ Requires-Dist: openai>=1.40
24
+ Requires-Dist: pillow>=10.3
25
+ Requires-Dist: pydantic>=2.7
26
+ Requires-Dist: pyyaml>=6.0
27
+ Requires-Dist: typer>=0.12
28
+ Description-Content-Type: text/markdown
29
+
30
+ # pileorder
31
+
32
+ Turn piles of images into structured, checked data with AI.
33
+
34
+ pileorder is a small command-line tool for one-off batch jobs: point it at a folder of product photos
35
+ (or other images), describe the fields you want in a YAML config — title, a category from your own list,
36
+ attributes, tags — and get back one checked row per image. Each job is a config, not new code.
37
+
38
+ > **Status: early development.** The pipeline is being built in stages; this README lists only what works
39
+ > today. See [docs/ARCHITECTURE.md](https://github.com/01egP/pileorder/blob/main/docs/ARCHITECTURE.md) for the design.
40
+
41
+ ## How it works
42
+
43
+ pileorder processes **units**: one thing goes in, one checked row comes out. Today a unit is one image file, and
44
+ the image can show anything — the config, not the code, decides which fields come back. A few shapes of jobs:
45
+
46
+ - product photo → title, category from your list, color, alt text;
47
+ - photo of a receipt → vendor, date, total;
48
+ - screenshot → the values shown on it.
49
+
50
+ The demo below is the one measured on real data; the other lines show what a config can ask for, not tested
51
+ results. PDF documents, spreadsheet rows and several photos per unit are planned as new kinds of units: the
52
+ engine works with units, not images, and each kind plugs in as an input adapter. `pileorder not-included` lists
53
+ what is not there yet.
54
+
55
+ ## Demo: 50 clothing photos → catalog rows
56
+
57
+ [`examples/clothing/`](https://github.com/01egP/pileorder/tree/main/examples/clothing) is a complete job: 50 photos of second-hand clothes from a
58
+ public-domain dataset ([source and license](https://github.com/01egP/pileorder/blob/main/examples/clothing/SOURCE.md)), a config asking for a title, a category
59
+ from a list of ten, whether the item is for kids, color, material, alt text and tags, and the dataset's own labels
60
+ to compare against.
61
+
62
+ Run on `gpt-6-luna` (`reasoning_effort: low`, 6 photos per request, 4 requests at a time), December 2026:
63
+
64
+ | | |
65
+ |---|---|
66
+ | Processed | 50 of 50, 0 failed, 1 sent to review |
67
+ | Tokens | 22,923 in / 3,304 out — about 460 in / 66 out per photo |
68
+ | Cost | $0.0039 for the 50 photos — **about $0.08 per 1,000 photos** at the model's list prices |
69
+ | Time | about 0.4 s per photo at 4 parallel requests (limited by the API key's rate limits, not by pileorder) |
70
+ | `category` vs the dataset's label | 46 / 50 |
71
+ | `for_kids` vs the dataset's label | 44 / 50 |
72
+
73
+ Of the four category mismatches, two are arguably the label's fault (a blazer labelled `Longsleeve`, a utility
74
+ jacket labelled `Shirt` — the model said `Outerwear`), one is a sundress-like item labelled `Skirt`, and one is a
75
+ pair of tights labelled `Pants`: the model found no category that fits, answered `Other`, and the row was marked
76
+ for review instead of being forced into a wrong category. Four of the six `for_kids` mismatches are items the
77
+ dataset calls adult that the model took for children's (among them shoes with a monster-truck print and pink plush
78
+ boots); two go the other way. `python examples/clothing/score.py` prints every mismatch.
79
+
80
+ A few result rows (`out/results.csv`, some columns left out):
81
+
82
+ | title | category | for_kids | color | tags | needs_review |
83
+ |---|---|---|---|---|---|
84
+ | Black and white graphic T-shirt | T-Shirt | false | Black and white | short sleeve; graphic; colorblock | false |
85
+ | Black two-button blazer | Outerwear | false | Black | blazer; two-button; notched lapels | false |
86
+ | Pink embroidered ankle boots | Shoes | true | pink | ankle boots; embroidered; ribbon ties | false |
87
+ | Navy footed tights | Other | false | navy | tights; footed | true — `category: no allowed value fits (escape value)` |
88
+
89
+ The dry-run estimate for this job was 23,429 input tokens before any call; the real runs used 22,923.
90
+
91
+ ## What works now
92
+
93
+ - **Job config in YAML**, validated up front with clear errors. Field types: `string`, `integer`, `number`,
94
+ `boolean`, `date`, `enum`, `list[string]`; enum values inline or from a file. The config compiles into one JSON
95
+ Schema for strict structured output.
96
+ - `pileorder scan` — finds images in a folder (recursive) and records them in a local SQLite manifest; skips
97
+ unreadable or oversized files with a reason; links duplicate files so each is processed once.
98
+ - `pileorder sample --n 30` — processes a random (seeded) sample and writes `report.md`: results, units that
99
+ need review and why, tokens, **measured cost per unit**, and the projected cost and time for the whole set.
100
+ Edit the config and sample again as often as needed.
101
+ - `pileorder run` — processes every pending unit, several per request, a few requests at a time. Units missing
102
+ from an answer or broken are retried in smaller requests; one unit that keeps failing fails alone. Stop it
103
+ any time and run it again: finished units are never sent twice, and the sample's results are reused.
104
+ - **Checks** on every answer: required fields, dates, values from your list (with the closest value suggested,
105
+ never silently replaced), word / item / length limits, regex. A unit that fails a check is kept and marked
106
+ `needs_review`.
107
+ - `pileorder export` — `results.csv` / `.json` / `.jsonl`, one row per unit with `needs_review` and the reasons.
108
+ - `pileorder status` — unit counts by status and what has been spent so far.
109
+ - `--dry-run` on `sample` / `run` — build the requests and estimate tokens and cost without an API key.
110
+ Images are counted with each model's documented scheme; an unknown model gets a rough, high estimate.
111
+ The sample measures the real numbers.
112
+
113
+ Models: OpenAI (vision + structured outputs), or any OpenAI-compatible endpoint via `OPENAI_BASE_URL`.
114
+ Default prices for common models are packaged with a date; set `model.price` in the config if yours is missing
115
+ or prices changed. They are a dated snapshot for estimates only — check the provider's pricing page before
116
+ quoting costs. pileorder is an independent project, not affiliated with or endorsed by OpenAI.
117
+
118
+ ## Reliability and scale
119
+
120
+ - The manifest (SQLite) is the only state: every stage can be stopped and re-run, and a crash loses only the
121
+ requests in flight.
122
+ - Tested without an API key against a fake model that drops, duplicates, mistypes and refuses answers: retries
123
+ reach only the missing units, and none is processed twice.
124
+ - Scale test (`uv run pytest -m slow`): 100,000 units through `scan → sample → run → export` with the fake model.
125
+ Time grows linearly with the number of units (the whole engine overhead is about 12 s per 100,000 on a laptop;
126
+ real runs are bound by the model API). Images in memory are capped by `concurrency × chunk_size`; what grows with
127
+ the pile is bookkeeping of unit ids, about 0.2 KB per unit. Export streams from the database.
128
+
129
+ ## Quick start
130
+
131
+ Try the demo (needs an OpenAI API key, or any OpenAI-compatible endpoint via `OPENAI_BASE_URL`; the whole demo
132
+ costs well under one cent):
133
+
134
+ Install the command-line tool (`pipx install pileorder` works too):
135
+
136
+ ```bash
137
+ uv tool install pileorder
138
+ ```
139
+
140
+ Then run the demo from a clone of this repository:
141
+
142
+ ```bash
143
+ git clone https://github.com/01egP/pileorder.git
144
+ cd pileorder/examples/clothing
145
+ export OPENAI_API_KEY=... # or put it in a .env file next to job.yaml
146
+ pileorder scan -c job.yaml
147
+ pileorder sample -c job.yaml --n 20 # read out/report.md
148
+ pileorder run -c job.yaml
149
+ pileorder export -c job.yaml # out/results.csv, out/results.json
150
+ python score.py # compare with the dataset's labels
151
+ ```
152
+
153
+ No key yet? `pileorder sample -c job.yaml --n 20 --dry-run` shows the requests' estimated tokens and cost.
154
+
155
+ For your own photos, a minimal `job.yaml`:
156
+
157
+ ```yaml
158
+ job: product-photos
159
+ input:
160
+ path: ./photos
161
+ model:
162
+ name: gpt-6-luna
163
+ reasoning_effort: low # optional; reasoning is billed as output tokens
164
+ instructions: Each image is one product photo from an online store.
165
+ fields:
166
+ - {name: title, type: string, required: true, max_words: 8}
167
+ - {name: category, type: enum, required: true, values_file: ./categories.txt}
168
+ - {name: color, type: string}
169
+ - {name: tags, type: "list[string]", max_items: 5}
170
+ ```
171
+
172
+ ## Not included yet
173
+
174
+ Run `pileorder not-included` for the current list (PDFs, spreadsheet rows, several photos per unit, a review
175
+ sheet, a database writer, an HTML report, Batch API mode).
176
+
177
+ ## Development
178
+
179
+ Requires [uv](https://docs.astral.sh/uv/).
180
+
181
+ ```bash
182
+ uv sync
183
+ uv run pytest # fast tests, no API key
184
+ uv run pytest -m slow # scale test, about a minute and a half
185
+ ```
186
+
187
+ ## License
188
+
189
+ MIT. The demo photos in `examples/clothing/photos/` are public domain (CC0), see
190
+ [SOURCE.md](https://github.com/01egP/pileorder/blob/main/examples/clothing/SOURCE.md).
@@ -0,0 +1,161 @@
1
+ # pileorder
2
+
3
+ Turn piles of images into structured, checked data with AI.
4
+
5
+ pileorder is a small command-line tool for one-off batch jobs: point it at a folder of product photos
6
+ (or other images), describe the fields you want in a YAML config — title, a category from your own list,
7
+ attributes, tags — and get back one checked row per image. Each job is a config, not new code.
8
+
9
+ > **Status: early development.** The pipeline is being built in stages; this README lists only what works
10
+ > today. See [docs/ARCHITECTURE.md](https://github.com/01egP/pileorder/blob/main/docs/ARCHITECTURE.md) for the design.
11
+
12
+ ## How it works
13
+
14
+ pileorder processes **units**: one thing goes in, one checked row comes out. Today a unit is one image file, and
15
+ the image can show anything — the config, not the code, decides which fields come back. A few shapes of jobs:
16
+
17
+ - product photo → title, category from your list, color, alt text;
18
+ - photo of a receipt → vendor, date, total;
19
+ - screenshot → the values shown on it.
20
+
21
+ The demo below is the one measured on real data; the other lines show what a config can ask for, not tested
22
+ results. PDF documents, spreadsheet rows and several photos per unit are planned as new kinds of units: the
23
+ engine works with units, not images, and each kind plugs in as an input adapter. `pileorder not-included` lists
24
+ what is not there yet.
25
+
26
+ ## Demo: 50 clothing photos → catalog rows
27
+
28
+ [`examples/clothing/`](https://github.com/01egP/pileorder/tree/main/examples/clothing) is a complete job: 50 photos of second-hand clothes from a
29
+ public-domain dataset ([source and license](https://github.com/01egP/pileorder/blob/main/examples/clothing/SOURCE.md)), a config asking for a title, a category
30
+ from a list of ten, whether the item is for kids, color, material, alt text and tags, and the dataset's own labels
31
+ to compare against.
32
+
33
+ Run on `gpt-6-luna` (`reasoning_effort: low`, 6 photos per request, 4 requests at a time), December 2026:
34
+
35
+ | | |
36
+ |---|---|
37
+ | Processed | 50 of 50, 0 failed, 1 sent to review |
38
+ | Tokens | 22,923 in / 3,304 out — about 460 in / 66 out per photo |
39
+ | Cost | $0.0039 for the 50 photos — **about $0.08 per 1,000 photos** at the model's list prices |
40
+ | Time | about 0.4 s per photo at 4 parallel requests (limited by the API key's rate limits, not by pileorder) |
41
+ | `category` vs the dataset's label | 46 / 50 |
42
+ | `for_kids` vs the dataset's label | 44 / 50 |
43
+
44
+ Of the four category mismatches, two are arguably the label's fault (a blazer labelled `Longsleeve`, a utility
45
+ jacket labelled `Shirt` — the model said `Outerwear`), one is a sundress-like item labelled `Skirt`, and one is a
46
+ pair of tights labelled `Pants`: the model found no category that fits, answered `Other`, and the row was marked
47
+ for review instead of being forced into a wrong category. Four of the six `for_kids` mismatches are items the
48
+ dataset calls adult that the model took for children's (among them shoes with a monster-truck print and pink plush
49
+ boots); two go the other way. `python examples/clothing/score.py` prints every mismatch.
50
+
51
+ A few result rows (`out/results.csv`, some columns left out):
52
+
53
+ | title | category | for_kids | color | tags | needs_review |
54
+ |---|---|---|---|---|---|
55
+ | Black and white graphic T-shirt | T-Shirt | false | Black and white | short sleeve; graphic; colorblock | false |
56
+ | Black two-button blazer | Outerwear | false | Black | blazer; two-button; notched lapels | false |
57
+ | Pink embroidered ankle boots | Shoes | true | pink | ankle boots; embroidered; ribbon ties | false |
58
+ | Navy footed tights | Other | false | navy | tights; footed | true — `category: no allowed value fits (escape value)` |
59
+
60
+ The dry-run estimate for this job was 23,429 input tokens before any call; the real runs used 22,923.
61
+
62
+ ## What works now
63
+
64
+ - **Job config in YAML**, validated up front with clear errors. Field types: `string`, `integer`, `number`,
65
+ `boolean`, `date`, `enum`, `list[string]`; enum values inline or from a file. The config compiles into one JSON
66
+ Schema for strict structured output.
67
+ - `pileorder scan` — finds images in a folder (recursive) and records them in a local SQLite manifest; skips
68
+ unreadable or oversized files with a reason; links duplicate files so each is processed once.
69
+ - `pileorder sample --n 30` — processes a random (seeded) sample and writes `report.md`: results, units that
70
+ need review and why, tokens, **measured cost per unit**, and the projected cost and time for the whole set.
71
+ Edit the config and sample again as often as needed.
72
+ - `pileorder run` — processes every pending unit, several per request, a few requests at a time. Units missing
73
+ from an answer or broken are retried in smaller requests; one unit that keeps failing fails alone. Stop it
74
+ any time and run it again: finished units are never sent twice, and the sample's results are reused.
75
+ - **Checks** on every answer: required fields, dates, values from your list (with the closest value suggested,
76
+ never silently replaced), word / item / length limits, regex. A unit that fails a check is kept and marked
77
+ `needs_review`.
78
+ - `pileorder export` — `results.csv` / `.json` / `.jsonl`, one row per unit with `needs_review` and the reasons.
79
+ - `pileorder status` — unit counts by status and what has been spent so far.
80
+ - `--dry-run` on `sample` / `run` — build the requests and estimate tokens and cost without an API key.
81
+ Images are counted with each model's documented scheme; an unknown model gets a rough, high estimate.
82
+ The sample measures the real numbers.
83
+
84
+ Models: OpenAI (vision + structured outputs), or any OpenAI-compatible endpoint via `OPENAI_BASE_URL`.
85
+ Default prices for common models are packaged with a date; set `model.price` in the config if yours is missing
86
+ or prices changed. They are a dated snapshot for estimates only — check the provider's pricing page before
87
+ quoting costs. pileorder is an independent project, not affiliated with or endorsed by OpenAI.
88
+
89
+ ## Reliability and scale
90
+
91
+ - The manifest (SQLite) is the only state: every stage can be stopped and re-run, and a crash loses only the
92
+ requests in flight.
93
+ - Tested without an API key against a fake model that drops, duplicates, mistypes and refuses answers: retries
94
+ reach only the missing units, and none is processed twice.
95
+ - Scale test (`uv run pytest -m slow`): 100,000 units through `scan → sample → run → export` with the fake model.
96
+ Time grows linearly with the number of units (the whole engine overhead is about 12 s per 100,000 on a laptop;
97
+ real runs are bound by the model API). Images in memory are capped by `concurrency × chunk_size`; what grows with
98
+ the pile is bookkeeping of unit ids, about 0.2 KB per unit. Export streams from the database.
99
+
100
+ ## Quick start
101
+
102
+ Try the demo (needs an OpenAI API key, or any OpenAI-compatible endpoint via `OPENAI_BASE_URL`; the whole demo
103
+ costs well under one cent):
104
+
105
+ Install the command-line tool (`pipx install pileorder` works too):
106
+
107
+ ```bash
108
+ uv tool install pileorder
109
+ ```
110
+
111
+ Then run the demo from a clone of this repository:
112
+
113
+ ```bash
114
+ git clone https://github.com/01egP/pileorder.git
115
+ cd pileorder/examples/clothing
116
+ export OPENAI_API_KEY=... # or put it in a .env file next to job.yaml
117
+ pileorder scan -c job.yaml
118
+ pileorder sample -c job.yaml --n 20 # read out/report.md
119
+ pileorder run -c job.yaml
120
+ pileorder export -c job.yaml # out/results.csv, out/results.json
121
+ python score.py # compare with the dataset's labels
122
+ ```
123
+
124
+ No key yet? `pileorder sample -c job.yaml --n 20 --dry-run` shows the requests' estimated tokens and cost.
125
+
126
+ For your own photos, a minimal `job.yaml`:
127
+
128
+ ```yaml
129
+ job: product-photos
130
+ input:
131
+ path: ./photos
132
+ model:
133
+ name: gpt-6-luna
134
+ reasoning_effort: low # optional; reasoning is billed as output tokens
135
+ instructions: Each image is one product photo from an online store.
136
+ fields:
137
+ - {name: title, type: string, required: true, max_words: 8}
138
+ - {name: category, type: enum, required: true, values_file: ./categories.txt}
139
+ - {name: color, type: string}
140
+ - {name: tags, type: "list[string]", max_items: 5}
141
+ ```
142
+
143
+ ## Not included yet
144
+
145
+ Run `pileorder not-included` for the current list (PDFs, spreadsheet rows, several photos per unit, a review
146
+ sheet, a database writer, an HTML report, Batch API mode).
147
+
148
+ ## Development
149
+
150
+ Requires [uv](https://docs.astral.sh/uv/).
151
+
152
+ ```bash
153
+ uv sync
154
+ uv run pytest # fast tests, no API key
155
+ uv run pytest -m slow # scale test, about a minute and a half
156
+ ```
157
+
158
+ ## License
159
+
160
+ MIT. The demo photos in `examples/clothing/photos/` are public domain (CC0), see
161
+ [SOURCE.md](https://github.com/01egP/pileorder/blob/main/examples/clothing/SOURCE.md).