delivery-kid: snapshot draft diagnostics to wiki sub-page#86
Open
AudioSkyWalker wants to merge 1 commit into
Open
delivery-kid: snapshot draft diagnostics to wiki sub-page#86AudioSkyWalker wants to merge 1 commit into
AudioSkyWalker wants to merge 1 commit into
Conversation
…tics Mirrors the upload_log / finalize_log / preview_log persisted in draft.json to a wiki sub-page at every terminal-state transition, so the diagnostics history survives a delivery-kid storage rebuild. Reuses the Magent@magent BotPassword already provisioned for blue-railroad-import (via the same PICKIPEDIA_BOT_USER / PICKIPEDIA_BOT_PASSWORD env vars). Hook points (each fires asyncio.create_task to avoid blocking the route): - routes/content.py fail() — upload_failed - routes/content.py _submit_preview_transcode exception path — preview_status: failed before Coconut even ran - routes/content.py finalize_sse_generator finally — finalized + finalize_failed - routes/coconut.py _update_draft_preview — preview_status: ready + failed (after webhook) The new pickipedia_client no-ops cleanly when PICKIPEDIA_BOT_PASSWORD is unset, so dev environments without bot creds run fine; the cached mwclient.Site is guarded by a lock for concurrent webhook callers. Wiki-side rendering is in cryptograss/pickipedia#81 — its initDiagnostics falls back to fetching ReleaseDraft:{id}/diagnostics whenever the live /draft-content fetch returns 404.
5 tasks
4 tasks
Contributor
|
Superseded by #87. Rebased onto current The Pair with cryptograss/pickipedia#82 for the wiki-side rendering. Safe to close this one whenever you're back at a keyboard. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Mirrors each content draft's
upload_log/finalize_log/preview_logto aReleaseDraft:{id}/diagnosticswiki sub-page at every terminal-state transition, so the diagnostics history surfaced by cryptograss/pickipedia#81 survives a delivery-kid storage rebuild instead of going down withdraft.json.Reuses the
Magent@magentBotPassword already provisioned for the Blue Railroad import tool — no new bot account needed (per Justin's call on the PR thread). SamePICKIPEDIA_BOT_USER/PICKIPEDIA_BOT_PASSWORDenv vars Hunter container_startup.py already references.What's in here
pinning-service/app/services/pickipedia_client.py— new module.mwclient-based wiki write helper, lazy-init Site singleton (lock-guarded for concurrent webhook callers), no-ops cleanly when the password env var is unset (so dev environments without bot creds still run).asyncio.create_taskfire-and-forget so a wiki blip never blocks the route or masks the underlying upload outcome:routes/content.pyfail()→upload_failedroutes/content.py_submit_preview_transcodeexception path →preview_status: failedbefore Coconut even ranroutes/content.pyfinalize_sse_generatorfinally→finalized+finalize_failed(snapshots BEFORE the rmtree on success, sincestateis the only copy offinalize_logonce we wipedraft.json)routes/coconut.py_update_draft_preview→preview_status: ready+failed(after webhook resolves the Coconut job)requirements.txt— addmwclient>=0.10.1(same pin as blue-railroad-import)ansible/playbook.yml— surfacePICKIPEDIA_URL/PICKIPEDIA_BOT_USER/PICKIPEDIA_BOT_PASSWORDto the pinning-service container with sensible defaultstests/test_pickipedia_client.pycovering creds-missing short-circuit, login-failure handling, lazy-init caching, sub-page title format, unchanged-content no-op, save-exception swallow, and the dict-based variant for the Coconut webhook path. Existing 20 tests still pass (pytest tests/→ 34 passed).Test plan
PICKIPEDIA_BOT_PASSWORDset in the vault — upload a video that fails ffprobe, confirmReleaseDraft:{uuid}/diagnosticsgets created withstatus: upload_failed+ the upload_log JSONstatus: finalized+ the finalize_log even after the sourcedraft.jsonis rmtree'dpreview_status: ready/failedwithpreview_logpopulatedinitDiagnosticsfalls back to the snapshot and renders with the "(snapshot)" disclosure labelRelated