Skip to content

Commit 95901b1

Browse files
committed
fix: address PR #32 review feedback
- Regenerate uv.lock (was stale: 0.5.7 vs 0.5.8 in pyproject.toml). Pin ruff to >=0.15.22,<0.16 to avoid 0.16 upgrade introducing 55 new pre-existing lint errors (RUF022/RUF059/I001/etc.); those fixes belong in a separate PR. - Add --base-channels to train_audio_diffusion.py and forward to the fallback BaselineAudioDecoder (was hardcoded to 64, inconsistent with the docs table and the decoder script). - Wrap subprocess in test_script_cli.py with pytest.fail for clean error output on import failure (was opaque CalledProcessError). - Add missing pytest import in test_script_cli.py. Entire-Checkpoint: 0c2d99a5ab77
1 parent 914ae04 commit 95901b1

4 files changed

Lines changed: 137 additions & 132 deletions

File tree

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ dependencies = [
1313
"numpy>=2.5.1",
1414
"pedalboard>=0.9.0",
1515
"pytest>=9.1.1",
16-
"ruff>=0.15.22",
16+
"ruff>=0.15.22,<0.16",
1717
"scipy>=1.14.0",
1818
"soundfile>=0.13.1",
1919
"structlog>=26.1.0",

scripts/train_audio_diffusion.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,13 @@ def main() -> None:
3434
parser.add_argument("--depth", type=int, default=4)
3535
parser.add_argument("--num-heads", type=int, default=4)
3636
parser.add_argument("--q", type=int, default=8)
37+
parser.add_argument(
38+
"--base-channels",
39+
type=int,
40+
default=64,
41+
help="Base channels for the fallback baseline decoder (only used when "
42+
"--decoder is not provided)",
43+
)
3744
parser.add_argument("--batch-size", type=int, default=4)
3845
parser.add_argument("--epochs", type=int, default=50)
3946
parser.add_argument("--lr", type=float, default=1e-4)
@@ -87,10 +94,13 @@ def extract_features(self, x):
8794
else:
8895
encoder = EnCodecEncoder()
8996

97+
# Fallback baseline decoder (only used when --decoder is not provided;
98+
# the DiT trains against the frozen encoder's latents, so this decoder
99+
# is just a placeholder for the AudioVAE wrapper).
90100
decoder = BaselineAudioDecoder(
91101
latent_channels=args.latent_channels,
92102
out_channels=1,
93-
base_channels=64,
103+
base_channels=args.base_channels,
94104
)
95105
if args.decoder and Path(args.decoder).exists():
96106
decoder.load_state_dict(torch.load(args.decoder, weights_only=False))

tests/test_script_cli.py

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,23 @@
1414
import sys
1515
from pathlib import Path
1616

17+
import pytest
18+
1719
SCRIPTS_DIR = Path(__file__).resolve().parent.parent / "scripts"
1820

1921

2022
def _help_output(script: str) -> str:
2123
"""Run a script with --help and return its stdout."""
22-
result = subprocess.run(
23-
[sys.executable, str(SCRIPTS_DIR / script), "--help"],
24-
capture_output=True,
25-
text=True,
26-
check=True,
27-
timeout=30,
28-
)
24+
try:
25+
result = subprocess.run(
26+
[sys.executable, str(SCRIPTS_DIR / script), "--help"],
27+
capture_output=True,
28+
text=True,
29+
check=True,
30+
timeout=30,
31+
)
32+
except subprocess.CalledProcessError as e:
33+
pytest.fail(f"{script} --help failed:\n{e.stderr}")
2934
return result.stdout
3035

3136

0 commit comments

Comments
 (0)