mirror of
https://github.com/kuhyx/testsAndMisc.git
synced 2026-11-11 22:14:01 +01:00
Split along the natural seam now that the file is fully covered:
_transcribe_probes.py 177 _try_import, the four dependency probes,
generate_sine_wav, prepare_model, test_cuda
transcribe_helpers.py 142 the eight _handle_* functions and main()
All 18 top-level definitions verified AST-identical to HEAD, and an AST
scan confirms neither module references a name it does not bind.
transcribe.sh is untouched - it invokes tools/transcribe_helpers.py by
path, and that path still exists with the same name and executable bit.
The CLI tests' patch targets did not move either, because main() dispatches
to names imported into its own namespace.
Verified by running every subcommand and reading the exit status directly,
since those codes are the contract transcribe.sh branches on:
python-version 0, check-faster-whisper 7, check-ctranslate2 1,
check-diarization 0, deps-installed 0; generate-wav writes the same
96044-byte WAV as before the split. 41 tests pass at 100% line and branch
on both modules; 243 pass in the directory. Over-cap files 35 -> 34.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011w2Pj4Ek3ZNMQVYcFHgXDY
67 lines
4.2 KiB
JSON
67 lines
4.2 KiB
JSON
{
|
|
"intent": "Split the 289-line transcribe_helpers.py into a probes/operations module and a CLI dispatch module, both under the 250-line cap, moving every definition verbatim.",
|
|
"scope": [
|
|
"transcribe_helpers.py 289 -> 142 (CLI dispatch and main)",
|
|
"New: _transcribe_probes.py 177 (dependency probes, sine WAV, model prep, CUDA probe)",
|
|
"Re-pointed the module under test in three test files",
|
|
"Non-goal: any behaviour change, including the unreachable dispatch guard"
|
|
],
|
|
"changes": [
|
|
"Extracted _try_import, the four dependency probes, generate_sine_wav, prepare_model and test_cuda into _transcribe_probes.py; transcribe_helpers.py keeps the eight _handle_* functions and main().",
|
|
"transcribe_helpers.py imports the probe functions by name, so the eight names main() dispatches to still resolve in its own namespace - which is why the CLI tests' patch targets did not have to move.",
|
|
"The three probe-level test modules now import _transcribe_probes, the module whose namespace resolves those functions after the split. No re-export barrel was added.",
|
|
"transcribe.sh is untouched: it invokes tools/transcribe_helpers.py by path, and that path still exists with the same name and executable bit.",
|
|
"_transcribe_probes.py was given the executable bit to match the repo convention for a file carrying a shebang."
|
|
],
|
|
"verification": [
|
|
{
|
|
"command": "python3 verify_split.py HEAD .../transcribe_helpers.py <both modules>",
|
|
"result": "pass",
|
|
"evidence": "IDENTICAL: all 18 top-level definitions moved verbatim, normalised through ast.dump(ast.parse(ast.unparse(node))). Re-run after ruff's autofix, and still identical."
|
|
},
|
|
{
|
|
"command": "AST scan for names used but not bound in each module",
|
|
"result": "pass",
|
|
"evidence": "Both modules report no unbound names, so no symbol was left behind by the extraction."
|
|
},
|
|
{
|
|
"command": "pytest linux_configuration/tests/test_transcribe_*.py --cov=transcribe_helpers --cov=_transcribe_probes --cov-branch",
|
|
"result": "pass",
|
|
"evidence": "41 passed - the same count as before the split. _transcribe_probes.py: 77 statements, 10 branches, 100%. transcribe_helpers.py: 46 statements, 16 branches, 100%."
|
|
},
|
|
{
|
|
"command": "python3 transcribe_helpers.py <each of the five no-argument commands>, checking $? directly",
|
|
"result": "pass",
|
|
"evidence": "python-version exit 0 printing 3.14; check-faster-whisper exit 7; check-ctranslate2 exit 1; check-diarization exit 0 with the warning; deps-installed exit 0. These codes are the contract transcribe.sh branches on, and they are unchanged by the split."
|
|
},
|
|
{
|
|
"command": "python3 transcribe_helpers.py generate-wav --file <scratch>/tone2.wav",
|
|
"result": "pass",
|
|
"evidence": "Wrote 96044 bytes, byte-for-byte the same size as the pre-split run."
|
|
},
|
|
{
|
|
"command": "bash -n transcribe.sh && ls -l tools/transcribe_helpers.py",
|
|
"result": "pass",
|
|
"evidence": "Syntax OK, and the path transcribe.sh references still exists with the executable bit. The caller needed no change."
|
|
},
|
|
{
|
|
"command": "pytest linux_configuration/tests/ -q",
|
|
"result": "pass",
|
|
"evidence": "243 passed, unchanged from before the split."
|
|
},
|
|
{
|
|
"command": "bash ~/utils/scripts/check_file_length.sh --all",
|
|
"result": "pass",
|
|
"evidence": "34 files over cap, down from 35. The two modules are 177 and 142 lines."
|
|
}
|
|
],
|
|
"risks": [
|
|
"transcribe.sh runs the module inside a dedicated venv this session cannot exercise, since the ML wheels are not installed here. Mitigated: the bare-name sibling import that a split could break is proved by running every CLI subcommand directly, and the venv only changes which interpreter resolves the same two files in the same directory.",
|
|
"A future command added to argparse's choices but not to the dispatch dict would silently do nothing. Pre-existing, now covered by a test that documents it."
|
|
],
|
|
"rollback": [
|
|
"git revert the commit; transcribe_helpers.py returns to its 289-line form and _transcribe_probes.py disappears.",
|
|
"After rollback, confirm python3 transcribe_helpers.py check-faster-whisper still exits 7 and pytest linux_configuration/tests/ reports 243 passed."
|
|
]
|
|
}
|