Decompose: Make EmbroideryPipeline.process() async with progress reporting #34
Labels
No labels
blocked:children
blocked:depends-101
blocked:depends-103
blocked:depends-104
blocked:needs-attention
blocked:needs-decision
blocked:no-changes
blocked:preflight
bug
chore
feature-request
in-progress
lint-cleanup
needs-decompose
performance
quality
quickfix
security/medium
triage-approved
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Mark/easystitch#34
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
EmbroideryPipeline.process() is sync + CPU-bound — needs async/executor semantics
Context
EmbroideryPipeline.process()is fully synchronous and CPU-bound. Forthe upcoming HTTP service (issue #31), this is a scaling problem: a
single request blocks the worker thread for 200ms–2s+.
Goal
Add async + progress-callback semantics so the HTTP service can:
Decomposition
The original ticket offered two options (A:
run_in_executor-only, B:progress_cb+run_in_executor). The right answer is "both" (option Cin the new framing), but the choice has consequences for the API surface
and needs to be locked before any code is written.
P1: Design decision — pick the concurrency primitive
Goal: Lock the design before code. Two sub-decisions:
run_in_executor(offload to thread pool,no progress events) vs
progress_cbparameter onprocess()(allowsyield-between-stages progress reporting, requires
process()to berefactored to call the callback).
strings? Structured dicts with stage name + percentage? SSE event
format if going through FastAPI?
Files:
docs/design/async-pipeline.mdwith the decision, the rejectedalternatives, and the API contract.
Acceptance:
the two sub-decisions.
process_asyncorprocess(progress_cb=...), what the callback receives, when itfires, how cancellation works).
depends on it).
Why first: the API shape of P2/P3 follows from this. Doing P2/P3
without a locked decision risks rework.
P2: Implement the chosen primitive
Implement the design from P1. Whichever path is chosen, this is the
substance of the change.
Files:
src/main_pipeline.py(refactorprocess()to support thechosen API)
src/main_pipeline_async.py(if the choice was a separateasync wrapper instead of refactoring
process())src/service/handlers/digitize.py(issue #31 P2 handlerconsumes the new API)
Acceptance:
serial time per request (parallelism is real, not serialized).
is interrupted (or the result is discarded) within 1 second.
Depends on: P1 (decision).
P3: Progress callback wiring
If P1 chose
progress_cb, implement the per-stage progressnotifications. If P1 chose
run_in_executor-only, this phase isunnecessary (mark as N/A in the issue tracker).
Files:
src/main_pipeline.py(addprogress_cbparameter, callbetween stages)
src/service/handlers/digitize.py(forward progress eventsto SSE response)
tests/test_progress_callback.py(asserts callback firesfor each stage, with correct stage names)
Acceptance:
process(progress_cb=cb)invokescbonce per stagetransition with
{stage, status, duration_ms?}.can render as a progress bar.
raster_to_vector,semantic_annotation,dom_resolution,physical_optimization,format_emission.Depends on: P1 (decision), P2 (chosen primitive).
Out of scope
covered by issue #43 (concurrency contract). This ticket is about
the API shape, not the operational parameters.
progress_cbis for stage-level progress, not pixel-levelprogress within a stage. That would require deeper refactoring
per stage.
EmbroideryPipeline.process() is sync + CPU-bound; needs async or executor semantics for the HTTP layerto Decompose: Make EmbroideryPipeline.process() async with progress reportingThis issue has been decomposed into the following sub-issues:
progress_cb, implement the per-stage progress notifications. If P1Each sub-issue has been labeled with
triage-approvedand is ready for queue routing.