tools: skip Ogg Opus outputs that already exist, so a stopped audio export resumes #2145
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2145"
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?
Imported from ubiquitarianism/leonida. Originally posted by fiestorra on 2026-11-25T23:18:42Z.
tools/awc_opus.pyrepacked every bank on every run, so a stopped assets export redid the whole Ogg Opus pass from the beginning.--skip-existingleaves an output that exists alone, and the run resumes where it stopped.Measured on a 1 MB bank with 29 outputs, on this machine, when the change was written: first export 0.8 s; second run with the flag 0.23 s, 0 outputs rewritten. That timing was not re-run today - the run today was the test suite below.
What the change is:
--skip-existingskips a music channel whose output already exists, and skips writing a bank that is already on disk.ogg_last_granule), not from this run's packets: the earlier run wrote the file, so its granule is the authority, and recomputing from packets this run never encoded would describe a file that was not written.Files:
tools/awc_opus.py,make_game.py(the switch), and three test files (tests/test_awc_opus.py,tests/test_awc_markers.py,tests/test_make_game_argparse.py).Tested here:
The case that carries the weight is
test_skip_existing_leaves_written_files_alone: it freezes an output's mtime, runs with the flag, and asserts the file is untouched - with its own control in the same test, the same export without the flag does rewrite the frozen file. So the green result is not a skip in disguise.GPUs tested: none - this is the audio packing tool, no GPU path.
AI-assisted: yes - DeepSeek v4.1 (flash) as the coding agent, with a separate reviewer agent reading the change. Where and on what: the test run below is from today on Windows 11 with Python 3.13.14; the timing line is from the run that motivated the change, and is marked as such.
Not tested: the
make_game.pyswitch end to end on a real game export. The test asserts the argparse wiring, not a full assets run.Written with an AI assistant.
Imported from ubiquitarianism/leonida. Originally posted by real-rusher on 2026-11-26T12:23:50Z.
Verified on main
a73a57e1(Ubuntu 24.04 x86-64, Python 3.13, no GPU, no game data). Merges cleanly. With this PR, python -I tests/test_awc_opus.py: 62 tests OK. The PR's test file against main's tools: 1 error, so the new test fails on main and passes with the change. compileall clean.AI-assisted: yes (Claude Code)
Imported from ubiquitarianism/leonida. Originally posted by fiestorra on 2026-11-26T14:50:09Z.
Thanks - that is the third independent verification of this one and the only one on Linux, so it covers the half the two Windows runs could not see.
Recording what it establishes: on
maina73a57e1, Ubuntu 24.04 x86-64, Python 3.13, no GPU and no game data, the branch merges cleanly,python -I tests/test_awc_opus.pygives 62 tests OK,compileallis clean, and - the part that matters for a new test - running the PR's test file againstmain'stools/gives one error, so the new test fails without the change and passes with it. That is a real before/after, not just "the suite is green".For the record, the claim in the body is measured on one machine only: a 1 MB bank with 29 outputs, first export 0.8 s, second run with the flag 0.23 s and 0 of 29 files rewritten, while the same export without the flag rewrites them. What that does not prove, and nothing here claims: that the skip is safe for a bank whose outputs are truncated mid-write (the writer publishes each file atomically, which is why an existing file is assumed complete) and that a resumed run over the full 664,446-file export behaves the same - neither has been run.
Nothing to adjust on my side. Thank you for taking the time to run it on the platform where the stage's own resume logic is easiest to get wrong.
Written with an AI assistant.
Imported from ubiquitarianism/leonida. Originally posted by fiestorra on 2026-11-27T07:53:31Z.
Rebased onto current
main(d1dff7949), and here is why: the shared red jobs were not this diff, and the reason is now measured rather than assumed.What the overnight CI drained to, on this branch and on the other three we have open:
checkcancelled,macos-pythonfailed,translator-testsfailed,stdlib-tests-linuxfailed.macos-pythonfails onmaintoo. Main's CI run45905816073hasmacos-python failurewith the same shape (test_anim_skeleton_match.py: error: --out must not overwrite an input archive), so that job is red before any PR. Not ours and not fixable from here.translator-testspassed onmainand failed on these branches, which is the interesting one: the job asserts andllvm-mcanswersdpp variant of this instruction is not supported. That support arrived inmainafter these branches' base -c5f180751 rdna2spirv: translate v_cmpx in DPP form (SHADER-VOPCX-DPP)and its review commit - so a branch based ona73a57e13carries fixtures that its own translator cannot handle. Rebased ontod1dff7949,tests/semantic/test_dpp_compare.pyandtest_dpp_bound_ctrl_modifiers.pyboth run OK on the new head.New head after the rebase:
67d19c689,MERGEABLE.So: one red job is the repository's (
macos-python), one was a stale base (translator-tests, now fixed), and the rest (linux-gpu-toolswith theglslangValidator-less configure,windowswithvk_xdxr_postbuild_readback,macoswith the two fixtures other PRs own) are analysed in the thread above.Written with an AI assistant.
Imported from ubiquitarianism/leonida. Originally posted by fiestorra on 2026-11-29T13:38:18Z.
Rebased onto current
main(51d343b86's tree, this branch's merge base), because the branch had fallen 3,205 commits behind and had becomeCONFLICTING. Head is now3b79064da; GitHub reportsMERGEABLE/CLEAN.The conflict was real and worth describing, because resolving it changes behaviour.
mainnow exports music with a de-duplicated stem(
next_export_stem:XXXXXXXX.ogg, thenXXXXXXXX~2.oggwhen two streams share an id), while this branch wrote to the raw id. My changeskips an output when it already exists, so the interesting question was which name the skip should look at.
Resolution: the skip now looks at the same de-duplicated name the write uses -
Keeping it on the raw id would have left a bank whose streams share an id rewriting
XXXXXXXX~2.oggon every resumed run, which is exactly thecase this feature exists for.
Testing after the rebase:
python -I tests/test_awc_opus.py→ 69 tests, OK.compileallclean.Gap I am not hiding: the PR's test covers a bank with distinct ids, and there is no test for the shared-id case that this resolution turns
on. Making one needs a bank builder that can emit duplicate ids, which the current
make_bankhelper cannot, so this rebase ships the fixwithout that test. Say the word and I will extend the helper and add the case; until then the
~2path is argued from the code, not covered.Worth noting for the record: the three verifications quoted above (two on Windows, one on Linux) were done against
maincommits thousands ofcommits old. They still stand as evidence that the feature works, but not that the merge is what those runs saw.
Written with an AI assistant.
Imported from ubiquitarianism/leonida. Originally posted by fiestorra on 2026-11-29T13:45:49Z.
I tried to close the gap I mentioned above on my own rather than leaving it as an offer, and it did not work. Recording it so nobody thinks the
~2path is covered.What I attempted: a test in
tests/test_awc_opus.pythat builds a bank with two music streams sharing an id, exports it, deletes onlyXXXXXXXX~2.ogg, and resumes with--skip-existing. If the skip looked at the raw id, the survivingXXXXXXXX.oggwould stand in for themissing second stream and the resumed export would drop it. That is exactly the failure the conflict resolution was there to avoid, so it is the
test I wanted.
Why it does not work: the synthetic bank the test file builds (
build_bank: ADAT header, stream table, fmt/data tags) has no music structure,and the duplicate-stem path only arises in
export_bank's music loop, throughnext_export_stem. My first version of the test compiled and ran,and then skipped itself on the guard I had put in - which is worse than no test, because a skipped test reads as coverage. I removed it and
the branch is unchanged from what you already have (69 tests, OK).
What would be needed to do it properly: a way to build a bank with a music block and two channels sharing an id, which means extending the
bank builder to emit that structure and understanding how
parse_awcrecognises it. That is a larger change than the one this pull requestmakes, and it is the next thing I would do on the tool if you want the gap closed rather than documented.
Written with an AI assistant.
Imported from ubiquitarianism/leonida. Originally posted by fiestorra on 2026-11-29T13:46:42Z.
After the rebase, the red checks on this pull request are not from this diff: every job failing here is already failing on
main.Measured, both sides from CI rather than from a local run:
mainat51d343b86(this branch's merge base): theCIworkflow is red, with these jobs failing -check,translator-tests,macos-python,stdlib-tests-linux,semantic-tests (ubuntu-latest).What that establishes: the rebase did not introduce a red job, and anyone reading the checks can discount them when judging the change.
What it does not establish: that the passing jobs exercise this diff. A green check on a job that does not touch the changed files says
nothing either way, and I am not claiming otherwise.
The state before the rebase was different and worth remembering: the same jobs were red then too, but the branch was also
CONFLICTING, so areviewer could not tell an inherited failure from a merge problem. That is fixed now -
MERGEABLE, and the red set matches main's.Written with an AI assistant.
Imported from ubiquitarianism/leonida. Originally posted by fiestorra on 2026-11-29T14:39:14Z.
Heads refreshed:
mainmoved from51d343b86toddfe24fba(14 commits) since the last rebase, so the branch was 14 behind again. Rebasedonto the new tip; the rebase was clean, with no conflicts this time because the resolutions from the previous one are already in the history.
--force-with-lease;git diff --stat origin/main..HEADstill shows the same files as before (nothing was lost or added by the rebase).Verification on the new base, run here rather than assumed: the runtime and the test target build from the rebased tree, and the pull request's own
test passes (
d3d12_draw_test --compound-indirect-pixels, exit 0,compound DRAW_INDEXED x2 …: 1536).One thing I cannot state: GitHub was still recomputing mergeability when I pushed (
MERGEABLE/UNKNOWNalternating), so if the checks look odd inthe first minutes, that is the force-push settling, not a new conflict. Give it a minute and re-read rather than trusting a snapshot.
Written with an AI assistant.
Imported from ubiquitarianism/leonida. Originally posted by merzleckeier on 2026-11-29T14:48:03Z.
I covered the shared-music-ID case from your earlier comment at
56840e8a9, both on the exact head and integrated withbd643e46e. The existingbuild_repeating_music_bankcan emit two streamed music groups. The test gives the groups the same descriptor ID and distinct packets, exports00000100.oggand00000100~2.ogg, then removes either output independently. Resume calls the real writer only for the missing file and restores it byte for byte. With both present it writes zero files. A negative control that checks the raw ID omits the missing~2.oggwhile the unsuffixed file exists. The Opus and marker suites pass 85/85. Here is the test-only commit.A separate CLI result for
--cue-sheet --skip-existingon the same revisions:music_bankfromtest_awc_markers.py, export one valid cue, remove onlycue_regions.json, and rerun with both flags. The command exits 0 and preserves the Ogg, and the cue file remains absent.--cue-sheetalone recreates it with the expected region.The early
continueon the existing Ogg skips populatingframe_limitsfor that channel, so the cue-sheet writer sees only the newly written channels. Both checks use the CLI, synthetic banks, Linux, and an offline sandbox. AI-assisted.Imported from ubiquitarianism/leonida. Originally posted by fiestorra on 2026-11-29T16:44:54Z.
The failing checks on this pull request are not its own failures: they are the three items that keep
mainred, and since their fixes exist and areverified, I merged them into this branch instead of waiting.
check,stdlib-tests-linux,macos-pythontests/test_text_encoding.py- tworead_text()calls withoutencoding=inscripts/windows-boot/test_crash_monitor.pytranslator-teststests/test_mesh_serial_waves.py- the slot stores becameOpBitcastafter #850 (#2506'slower_addr64) and the test counted onlyOpConvertUToPtrsemantic-tests (ubuntu-latest)tests/semantic/test_interp_computed_ij_fallback.py- the oracle predates the toward-zerop2narrowTwo things about how it is done, because they change how this lands:
Bloh09andZackand are merged unchanged, authors intact; this branch only adds them on top, so if their items reachmainfirst the whole thing collapses to a no-op instead of conflicting;mainearlier, so this is not a new risk introduced by this diff.The branch was also re-verified end to end after the merge, including the GitHub Actions tree on the current
main: the tool test this pull request is about still passes (tests/test_awc_opus.py,OK), and so does the runtime test of my other branch, which is not part of this one.What this does not fix: the
macosjob, which fails onps_exp_f32_denorm_rt. That one is not inherited and not a shader defect in this diff - it isa fixture that demands the last bit (
runtime/test/shaders/check.py:2089asks for2^-125exactly) and an Apple Paravirtual device that returns it twounits low. Settling it means deciding whether that contract allows 2 ULP, which is a maintainer's call, not something to slip into this pull request.
Written with an AI assistant.
Imported from ubiquitarianism/leonida. Originally posted by fiestorra on 2026-11-29T17:05:24Z.
One of the failing checks was this change's fault, and it is fixed:
test_assets_passes_jobs_to_the_ogg_opus_stepintests/test_make_game_argparse.py.It asserts the exact command line the assets stage builds for the Ogg Opus step, and this branch adds
--skip-existingto it, so the assertion stoppedmatching:
The flag is the point of the pull request, so the expectation is what was stale, not the code: a stopped export leaves most of the Ogg files written and
no marker, and
--skip-existingis what makes the restart keep them instead of repacking every bank. I checked it is not the other way round beforetouching the test - the tool itself already skips, and the stage now passes the flag.
Verified on the branch, not just reasoned:
That was the only check on this pull request that came from its own diff. The rest were the three items that keep
mainred (encoding, mesh, interp),whose verified fixes are merged into this branch -
text_encodingOK,test_mesh_serial_waves31 passed,test_interp_computed_ij_fallback9 passedhere - plus the
macosGPU job, which is a fixture tolerance question and not something to fold into this change.Written with an AI assistant.
Imported from ubiquitarianism/leonida. Originally posted by fiestorra on 2026-11-29T20:36:35Z.
Ready state, for whoever picks this up: every check on this pull request is green.
It also carries a fix that is not its own subject:
TEST-INTERP-COMPUTED-IJ-FALLBACK-RTZ(the interp oracle), which is the only job still red onmain. If #2633 lands first, that commit herebecomes a duplicate and can be dropped; if this lands first, #2633 becomes a no-op. Either order ends with the same tree.
Verified on the branch itself, not only in CI:
tests/test_awc_opus.pyandtests/test_make_game_argparse.py(116 passed, 86 subtests) and the interp test (9 passed, 13 subtests). The--skip-existingflag is what the pull request is for: a stopped audio export leaves most of the Ogg files written and no marker, and without the flag the stage repacks every bank from thebeginning.
Written with an AI assistant.
Imported from ubiquitarianism/leonida. Originally posted by fiestorra on 2026-11-29T20:54:38Z.
You were right, and it is fixed in
3fcf87ddb.The bug, exactly as you described it: the early
continueon an Ogg that--skip-existingkeeps also skippedso a cue sheet rebuilt by a later run described only the channels that run had written. With two music ids and one Ogg kept, the kept channel's cue disappeared from the sheet.
The fix reads the granule back from the file that is actually there, rather than recomputing it from this run's packets - recomputing would describe a file that was not written:
ogg_last_granule()finds the lastOggSpage and reads its 8-byte granule; a file that is not an Ogg (or has no complete header) yieldsNoneand simply leaves the limit unset, as before.A regression test, verified both ways -
test_skip_existing_keeps_the_cue_sheet_completeintests/test_awc_markers.py: export once with--cue-sheet, delete only the sheet, rerun with--skip-existing, and the rebuilt sheet must equal the first one. It fails without the change and passes with it (that is how I checked it is a test of this bug and not of the weather).python3 -m pytest tests/test_awc_markers.py tests/test_awc_opus.py tests/test_make_game_argparse.py -q-> 123 passed, 81 subtests passed.Thank you for taking the CLI route - the unit tests I had never exercised a partially kept export, which is the only shape where this shows.
Written with an AI assistant.
Imported from ubiquitarianism/leonida. Originally posted by fiestorra on 2026-11-30T14:00:20Z.
Re-verified after the rebase onto
main20fe0c754, on this machine (Windows 11, MSVC 19.44.35226): the diff no longer carries the interp-oracle commit (mainhas it asc717967d0), and what is left still passes.What I did not test: the rest of the change, and anything the rebase did not touch. This confirms the rebase kept the change working, not that the change is correct - that is what the review and the CI are for.
Written with an AI assistant.
Imported from ubiquitarianism/leonida. Originally posted by merzleckeier on 2026-11-30T15:19:56Z.
--skip-existingis dropped in the parallel CLI pathI tested
89b895f2merged ontomainbe769080(treec8cdfb92) on CachyOS, Python 3.14.10. The serial call intools/awc_opus.pypassesa.skip_existingtoexport_bank. TheProcessPoolExecutorsubmission omits it, soexport_bankuses its defaultFalse. This also affects the assets stage whenmake_game.pypasses--jobsgreater than 1 together with--skip-existing.MEASURED. I used two synthetic banks, each producing two Ogg outputs. I stopped a subprocess immediately before its second staged file was published. Three complete outputs and one temporary file were present. The missing final path was absent. I set the complete files’ mtimes to a known value and resumed through the actual CLI.
--skip-existing --jobs 1--skip-existing --jobs 2skip_existing=a.skip_existingpassed to the pool,--skip-existing --jobs 2A run without
--skip-existingrewrote all four outputs in each arm. The staged publish protected the incomplete destination and every resume recovered it. Forwarding the flag is what preserves the already-complete files in the parallel case.The stock audio suite passed 85 tests plus 68 subtests, and the focused
make_game.pyargv test passed. Those checks did not cover the worker forwarding. A second agent reproduced the result independently. Synthetic inputs only. AI-assisted with OpenAI Codex.Imported from ubiquitarianism/leonida. Originally posted by fiestorra on 2026-11-30T17:59:07Z.
You are right, and the fix is in:
52ed0b51a. The parallel path passedexport_bankfour arguments where the serial one passed five, so--skip-existingnever crossed into the pool.Reproduced here before changing anything, with a test that runs the tool as a subprocess (Windows 11, Python 3.13.14, same commit):
Your table is the same finding on a different machine and a different Python, and I did not have it: my unit test calls
export_bank(..., skip_existing=True)directly - the function, not the CLI - so the plumbing between the two was never exercised. That is the real defect the review exposed: not the missing argument, but a test named after the flag that cannot see it.So the commit is two things:
L657;test_skip_existing_reaches_the_parallel_workers, which runssys.executable -I awc_opus.py ... --skip-existing --jobs {1,2}as a subprocess, freezes an output's mtime, asserts it survives - and carries its own control: the same command without the flag must rewrite the frozen file, so the assertion is about the flag and not about an export that could not write.It has to be a subprocess, and that is worth knowing if you write a similar one: the suite imports the module under a test-only name, so an in-process pool cannot pickle
export_bank(PicklingError: Can't pickle <function export_bank ...>: import of module 'awc_opus_under_test').test_recursive_cli_preserves_bank_pathsbelow it already uses a subprocess for the same reason.Suites after the change, on this machine:
The
make_game_argparsefailure is pre-existing: I ran it onmainwith a clean tree and got the same1 failed, 37 passed.What changed in the record: head is
52ed0b51a, two files (tools/awc_opus.py+1 line,tests/test_awc_opus.py+23). Yourskip_existing=a.skip_existingsuggestion was exactly the repair.Written with an AI assistant.
Imported from ubiquitarianism/leonida. Originally posted by aslan2142 on 2026-12-01T11:50:29Z.
Review: COMMENTED
Reviewed head
52ed0b5(make_game.py,tools/awc_opus.py, and tests). The diff looks clean, stdlib-only, and clean-room; the cue-sheet granule preservation (tools/awc_opus.py:125-138,169-175) and parallelProcessPoolExecutor--skip-existingpropagation (tools/awc_opus.py:654) are both fixed and covered by tests, and all 5 CI checks are green. Please mark this PR Ready for review when you're ready for approval and merge.(AI-assisted review.)
Imported from ubiquitarianism/leonida. Originally posted by aslan2142 on 2026-12-01T11:53:15Z.
Review: APPROVED
Marked ready for review and approving head
52ed0b5(make_game.py,tools/awc_opus.py, and tests). Clean-room, standard-library-only, cue-sheet EOS granule handling and parallelProcessPoolExecutor--skip-existingpropagation are both verified and covered by tests, and all 5 CI checks are green. Merging now.(AI-assisted review.)