WP-04: Concurrent Upload Pipeline #91
Labels
No Label
ai-changes-requested
ai-failed
ai-merged
ai-pr-opened
ai-reviewed
ai-reviewing
ai-reviewing
ai-working
bug
enhancement
evolution
performance
phase-0
phase-1a
phase-1b
phase-1c
phase-1d
security
tech-debt
todo
No project
No Assignees
2 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: cal/paper-dynasty-database#91
Loading…
Reference in New Issue
Block a user
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?
Description
Replace the sequential upload loop with semaphore-bounded
asyncio.gatherfor parallel card fetching, rendering, and S3 upload.Repo:
card-creationPhase: 0 (Render Pipeline Optimization)
Dependencies: WP-02 (persistent browser must be deployed for concurrent renders to work)
Complexity: M
Current State
pd_cards/core/upload.pyupload_cards_to_s3()(lines 109-333): sequentialfor x in all_players:loopfetch_card_imagetimeout hardcoded to 6s (line 28)upload_card_to_s3()uses synchronousboto3.put_object— blocks the event loopaiohttp.ClientSessionis reused (good)Implementation
async def process_card(player)coroutineasyncio.Semaphore(concurrency)guard (default concurrency=8)asyncio.gather(*[process_card(p) for p in all_players], return_exceptions=True)upload_card_to_s3()to thread pool viaasyncio.get_event_loop().run_in_executor(None, upload_card_to_s3, ...)fetch_card_imagetimeout from 6s to 10s--concurrencyCLI argument topd-cards uploadcommandFiles
pd_cards/core/upload.py— concurrent pipeline, timeout increasepd_cards/cli/upload.py(or wherever CLI args are defined) — add--concurrencyflagTests
--concurrency 1behaves like sequential (regression safety)Acceptance Criteria
fetch_card_imagetimeout is 10s--concurrencyflag available on CLIPlan reference:
docs/prd-evolution/PHASE0_PROJECT_PLAN.mdWP-04PR opened in
paper-dynasty-card-creation: cal/paper-dynasty-card-creation#25The implementation was already complete on
feature/render-pipeline-optimization. The PR surfaces it as a reviewable branch targetingmain.What was implemented:
pd_cards/core/upload.py:process_single_card()coroutine +asyncio.Semaphore(concurrency)+asyncio.gather(*tasks, return_exceptions=True)+loop.run_in_executorfor boto3 + timeout 6s → 10s + progress every 20 cardspd_cards/commands/upload.py:--concurrency / -jflag (default: 8)check_cards_and_upload.py: same pattern applied (WP-05)scripts/benchmark_render.sh+ baseline results (WP-00)Completed. Concurrent upload pipeline shipped in
card-creationrepo:979f308—feat: concurrent upload pipeline and benchmarks (Phase 0)ed1daa2—fix: use get_running_loop() instead of deprecated get_event_loop()8bddf31—feat: configurable API URL for local high-concurrency card renderingAll acceptance criteria met:
fetch_card_imagetimeout is 10s ✅--concurrencyflag available on CLI ✅--api-urlflag for local rendering at 32x concurrency ✅