Skip to content

awc_shorts: create per-bank folders only on export and surface scan errors - #2900

Open
Kosmabb8 wants to merge 3 commits into
ItsNotRexed:mainfrom
Kosmabb8:fix/awc-shorts-lazy-dirs-and-scan
Open

Kosmabb8 wants to merge 3 commits into
ItsNotRexed:mainfrom
Kosmabb8:fix/awc-shorts-lazy-dirs-and-scan

Conversation

@Kosmabb8

@Kosmabb8 Kosmabb8 commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Coordination claim: #2716 (comment)

Banks with no selected clips, or malformed banks skipped by the exporter, currently leave empty per-bank directories. An unreadable source subdirectory is also silently omitted by os.walk, allowing shorts.csv to be replaced by an incomplete catalog. Create the bank directory immediately before its first selected export and propagate directory scan errors before touching the catalog.

Updated against main 6f58bd2. The export-loop conflict is resolved while retaining main's selected-channel collection and export_stems naming for repeated stream IDs, destination-folder collision checks and process-worker cap. Runtime filesystem failures continue to exit 1, matching unreadable-bank errors; CLI argument/path checks exit 2.

Validation on Windows 11, portable CPython 3.12.10, CPU only:

  • Negative control: main's awc_shorts.py with the merged tests fails exactly four checks (nonmatching bank, unreadable directory, serial/pool malformed-bank folders).
  • python -I tests/test_awc_shorts.py -q: 16 tests, 15 passed, 1 existing case-sensitive-filesystem skip.
  • python -I tests/test_awc_opus.py -q: 56 passed.
  • python -I tests/test_pool_workers.py -q: 11 passed.
  • python -I tests/test_csv_line_endings.py -q: 2 passed.
  • python -m compileall -q make_game.py tools tests: passed.
  • python -I scripts/check_no_game_data.py tools/awc_shorts.py tests/test_awc_shorts.py: passed.
  • git diff 6f58bd2 --check: passed.

Repository-wide guard limitations, also present in the pinned main: test_text_write_line_endings.py fails on missing newline arguments in tools/leonida_tui.py and tools/wave_diff.py; test_tool_stdout_encoding.py reports eight existing entry points without stdout replacement handling. Those guard tests and all reported sources are byte-identical to main; this PR changes only awc_shorts.py and its test file.

Synthetic AWC fixtures only; no game files, GPU or driver validation. AI-assisted with Codex.

@tupacfan04

Copy link
Copy Markdown
Contributor

Code read of e2f64ae6 (I didn't run it). Looks right. The bank folder is now only created when a short channel is actually written, so banks with nothing to export leave no empty folders, and the repeated makedirs(exist_ok=True) is cheap. os.walk silently skips unreadable directories by default, so the onerror that re-raises turns that into a reported scan failure. A small consistency point: the scan failure returns 1 while the missing-source case right above returns 2, so you may want both "input problem" exits to use the same code.

AI-assisted review (Claude Code).

@Kosmabb8

Copy link
Copy Markdown
Contributor Author

Thanks @tupacfan04 — awc_shorts.py uses exit 2 for CLI argument/path-existence checks and exit 1 for runtime filesystem OSErrors (including an unreadable .awc file via io_failed, cannot create <out>, and cannot write <catalog>), so returning 1 for a directory-scan OSError matches the unreadable-bank file path. AI-assisted.

@Kam471 Kam471 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified on the PR head: python -I tests/test_awc_shorts.py -> 14/14 pass. On origin/main 4 tests fail: the two new cases plus both truncated-bank variants, and the bad/ directory is left behind. Scan-only with an injected PermissionError exits 1 with one actionable line, creates no output directory and preserves the previous shorts.csv. Both heads merge cleanly into latest main.

Policy note: one unreadable subdirectory now aborts the whole scan; that is documented and tested. Synthetic byte data only; no game data or absolute paths. Approve.

@Marukooh

Copy link
Copy Markdown
Contributor

Tested e2f64ae6 on CachyOS Linux, Python 3.14. tests/test_awc_shorts.py: 14 passed, 6 subtests passed.

The base fails four synthetic export checks. The head avoids empty report directories and passes the CLI cases through both worker modes.

AI-assisted, synthetic inputs only.

@JRamos1993

Copy link
Copy Markdown
Contributor

Ran this on main 1628210 (Windows 11, Python 3.14). It merges cleanly.

  • Tests: tests/test_awc_shorts.py 14 OK; test_csv_line_endings, test_text_write_line_endings and test_tool_stdout_encoding OK. With main's awc_shorts.py, the same 4 tests fail.
  • A real, unmocked scan error: I put a junction to C:\System Volume Information inside the source tree.
    • main exits 0 and replaces shorts.csv with a header-only catalog.
    • This PR exits 1 with [WinError 5] Access is denied and leaves shorts.csv as it was.

AI-assisted (Claude Code).

@Kosmabb8

Copy link
Copy Markdown
Contributor Author

Repaired the upstream conflict in f0ab0bc, now pushed. The merge preserves current selected-channel/export_stems naming for duplicate stream IDs, destination collision checks and the worker cap, together with this PR's lazy output folders and scan-error handling. Negative control against main failed exactly four relevant cases; AWC shorts16 (15passed/1filesystemskip), Opus56, poolworkers11 and CSV2 checks pass on Windows CPython3.12.10. Compilation, no-game-data and scoped diff checks pass. Two repository-wide guards have unrelated existing failures, documented in the body; those sources are unchanged by this PR. Latest main86d1c862 does not change the AWC source/test files and git merge-tree is clean. AI-assisted; synthetic inputs only, no GPU or game files.

@Kosmabb8

Kosmabb8 commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor Author

Audited and verified current PR head f0ab0bcd7 (merged with main 6f58bd2c5, MERGEABLE, touching only tools/awc_shorts.py and tests/test_awc_shorts.py). All upstream tools/awc_shorts.py updates (duplicate export folder rejection #6775, duplicate short audio channel stems, Windows 61-worker cap, streamed chunk validation, and --help usage line) are preserved alongside lazy per-bank directory creation and os.walk scan-error propagation.

Validation on f0ab0bcd7 (Windows 11, portable Python 3.12.10, python -I, synthetic banks only):

  • tests/test_awc_shorts.py -v: 16 ran (15 OK, 1 skipped on case-insensitive NTFS).

AI-assisted (Antigravity).

@Kosmabb8

Copy link
Copy Markdown
Contributor Author

Merged current main (4078faaa4) in b3e51838d to resolve the conflict introduced by #6664 (55ba30c2a) and #6647 (7541333a0):

Verification (Windows 11, portable Python 3.12.10, python -I, synthetic AWC banks only, no GPU/game files):

  • tests/test_awc_shorts.py -v: 17 ran (16 OK, 1 skipped on case-insensitive NTFS)
  • tests/test_awc_opus.py: 61/61 OK
  • tests/test_pool_workers.py: 11/11 OK
  • tests/test_csv_line_endings.py: 2/2 OK
  • tests/test_resource_hygiene.py: 2/2 OK
  • py_compile tools/awc_shorts.py tests/test_awc_shorts.py: exit 0

AI-assisted (Antigravity).

@NiHuShu

NiHuShu commented Nov 23, 2026

Copy link
Copy Markdown

The case-sensitive filesystem check that skipped on NTFS passes on native CachyOS x86-64 (CPython 3.14.10). With separate synthetic clip.awc and clip.AWC inputs, both --jobs 1 and --jobs 2 returned 2, named both inputs and preserved the existing catalog bytes. This passed on both revisions.

I ran python -I tests/test_awc_shorts.py with the head test file in each worktree. On upstream merge parent 4078faaa4e39684a839f23757d0a7c38773763f7, 14 passed and 3 failed: the non-matching bank and the serial and pool truncated-bank cases left empty directories. On b3e51838d5cbc87b41fc61345fd1dd1ca3640bcb, all 17 passed. Zero skips on either revision.

AI-assisted. CPU only; GPU not used. Synthetic fixtures only.

@skorex

skorex commented Nov 23, 2026

Copy link
Copy Markdown

Tested b3e5183 on Linux (WSL), Python 3.13: pass.

Ran: python3 -I tests/test_awc_shorts.py (17 tests, pass), python3 -I tests/test_awc_opus.py and tests/test_pool_workers.py (pass), python3 -m compileall -q make_game.py tools tests (clean), python3 -I scripts/check_no_game_data.py on both files (clean). With this PR's test file on origin/main, three tests fail as expected: the new non-matching-bank test and the serial/pool truncated-bank tests (the new listdir == ["good", "shorts.csv"] assertion), so the lazy os.makedirs is what makes them pass.
Not run: Windows.

One note for the maintainer, not a defect: since the merge of main at 4078faa, the scan-error half of the description is already on main (_banks passes onerror=scan_failed and main returns 2 on a listing error). test_unreadable_subdirectory_fails_and_preserves_catalog passes on origin/main too, so it is a regression guard here; the functional change in this PR is moving os.makedirs(od, exist_ok=True) into the export loop. The PR body could say so.

AI-assisted review (Claude Code).

@isfcrctfs isfcrctfs left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Read b3e51838 on Linux (CPython 3.12.16): the change is correct.

os.makedirs(od, exist_ok=True) moving into the selected-channel loop means a bank that contributes no clips creates no directory, and tests/test_awc_shorts.py is 17/17 here (no skips). I also checked the tests can fail: with only the makedirs line reverted to base 4078faaa, test_non_matching_bank_does_not_create_empty_folder and test_truncated_bank_skipped_serial fail on the added listdir assertion. test_unreadable_subdirectory_fails_and_preserves_catalog passes on the base as well, as expected since #6664 already landed onerror=scan_failed there, so it is a regression guard rather than part of the remaining fix.

No in-repo consumer assumes the bank folder exists (export_bank is only called by this tool and its tests), and docs/awc_shorts.md says nothing about empty folders, so no doc change is needed.

AI-assisted.

@ne1i

ne1i commented Nov 23, 2026

Copy link
Copy Markdown

Tested b3e51838 on Linux, CPython 3.14, CPU only, synthetic inputs, merged onto main dde82f27: pass

  • python -I tests/test_awc_shorts.py: Ran 17 tests, OK. With only tools/awc_shorts.py reverted to main: FAILED (failures=3), so the new assertions exercise the change.
  • compileall and scripts/check_no_game_data.py on the changed files: clean.

Independent check (not the author). Run by an AI agent (DeepSeek V4.1 Flash) and re-run by the orchestrating session (Claude Code) before posting; claimed in #8047.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants