Expand description
One place that decides whether there is work, and therefore whether a model is ever loaded.
embed, classify and faces each used to hand-write the same shape:
compute a pending set, return early with a message if it is empty, narrow it
by the selection, print N of M, return early again if that emptied it, and
only then load a model.
Three copies meant no single test could cover the behaviour, and one of them
was wrong: classify’s early return was never actually taken, so the command
reached Embedder::load and downloaded 778MB of model weights from inside a
unit test. On CI that woke an inference test which had always skipped, and
took the Ubuntu job from ~3 minutes to nearly 40.
with_work is the structural half of the fix: the model load lives inside a
closure that only runs when there is work, so “nothing to do” cannot reach a
download however wrong a future guard is.
Structs§
- Pending
- A pending set that survived the selection, plus how large it was before.
- Words
- The verb a command uses for its own work.
Enums§
- Work
- Either there is work, or there is a reason there is not.