aboutsummaryrefslogtreecommitdiff
path: root/lib/project/tests/test_ai.py
diff options
context:
space:
mode:
Diffstat (limited to 'lib/project/tests/test_ai.py')
-rw-r--r--lib/project/tests/test_ai.py24
1 files changed, 12 insertions, 12 deletions
diff --git a/lib/project/tests/test_ai.py b/lib/project/tests/test_ai.py
index e8c5872..8d08e5f 100644
--- a/lib/project/tests/test_ai.py
+++ b/lib/project/tests/test_ai.py
@@ -14,7 +14,7 @@ import numpy as np
import pytest
import soundfile as sf
-from voiceforge import ai, ai_worker, setup
+from producer import ai, ai_worker, setup
MODEL_BYTES = 7986207
@@ -108,7 +108,7 @@ def test_subprocess_heartbeat_does_not_block_on_silence_or_closed_output(close_o
def test_subprocess_parses_split_byte_progress_records():
events = []
- record = "VOICEFORGE_PROGRESS " + json.dumps(["Download (bytes)", 123, 456]) + "\n"
+ record = "PRODUCER_PROGRESS " + json.dumps(["Download (bytes)", 123, 456]) + "\n"
code = f"import os,time; os.write(1,{record[:12].encode()!r}); time.sleep(.3); os.write(1,{record[12:].encode()!r})"
setup.run_process([sys.executable, "-c", code], "Download", lambda *event: events.append(event))
assert events[-1] == ("Download (bytes)", 123, 456)
@@ -203,14 +203,14 @@ def _ready_environment(root, flavor="cpu"):
environment = root / f"ai-df-0.5.6-torch-2.5.1-{flavor}-py311-v1"
(environment / "bin").mkdir(parents=True)
(environment / "bin/python").write_text("#!/bin/sh\n")
- (environment / ".voiceforge-ready").touch()
+ (environment / ".producer-ready").touch()
return environment
def test_ready_environment_skips_the_check_worker(tmp_path, monkeypatch):
root = tmp_path / "prefix"
environment = _ready_environment(root)
- monkeypatch.setenv("VOICEFORGE_HOME", str(root))
+ monkeypatch.setenv("PRODUCER_HOME", str(root))
monkeypatch.setattr(ai.os, "confstr", lambda *_: "glibc 2.39")
executed = []
monkeypatch.setattr(ai, "run_process", lambda args, *rest, **kwargs: executed.append(args))
@@ -222,7 +222,7 @@ def test_ready_environment_skips_the_check_worker(tmp_path, monkeypatch):
def test_setup_verifies_even_a_ready_environment(tmp_path, monkeypatch):
root = tmp_path / "prefix"
_ready_environment(root)
- monkeypatch.setenv("VOICEFORGE_HOME", str(root))
+ monkeypatch.setenv("PRODUCER_HOME", str(root))
monkeypatch.setattr(ai.os, "confstr", lambda *_: "glibc 2.39")
executed = []
monkeypatch.setattr(ai, "run_process", lambda args, *rest, **kwargs: executed.append(args))
@@ -238,7 +238,7 @@ def test_broken_environment_is_rebuilt_and_self_tested(tmp_path, monkeypatch):
(environment / "bin/python").symlink_to("/nonexistent/python3.11")
leftover = environment / "leftover.txt"
leftover.write_text("from the previous location")
- monkeypatch.setenv("VOICEFORGE_HOME", str(root))
+ monkeypatch.setenv("PRODUCER_HOME", str(root))
monkeypatch.setattr(ai.os, "confstr", lambda *_: "glibc 2.39")
stages, commands = [], []
@@ -247,7 +247,7 @@ def test_broken_environment_is_rebuilt_and_self_tested(tmp_path, monkeypatch):
stages.append(stage)
if stage == "Checking DeepFilterNet3":
environment.mkdir(parents=True, exist_ok=True)
- (environment / ".voiceforge-ready").touch()
+ (environment / ".producer-ready").touch()
monkeypatch.setattr(ai, "run_process", fake_run)
monkeypatch.setattr(ai, "ensure_uv", lambda progress=None: "uv")
@@ -256,7 +256,7 @@ def test_broken_environment_is_rebuilt_and_self_tested(tmp_path, monkeypatch):
assert stages == ["Preparing AI Python 3.11", "Installing PyTorch (cpu)",
"Installing DeepFilterNet3", "Checking DeepFilterNet3"]
assert commands[0][-1] == str(environment)
- assert (environment / ".voiceforge-ready").is_file()
+ assert (environment / ".producer-ready").is_file()
def test_copied_environment_is_rebuilt_not_trusted(tmp_path, monkeypatch):
@@ -268,7 +268,7 @@ def test_copied_environment_is_rebuilt_not_trusted(tmp_path, monkeypatch):
original = _ready_environment(tmp_path / "other")
(environment / "bin/python").unlink()
(environment / "bin/python").symlink_to(original / "bin/python")
- monkeypatch.setenv("VOICEFORGE_HOME", str(root))
+ monkeypatch.setenv("PRODUCER_HOME", str(root))
monkeypatch.setattr(ai.os, "confstr", lambda *_: "glibc 2.39")
stages = []
@@ -276,7 +276,7 @@ def test_copied_environment_is_rebuilt_not_trusted(tmp_path, monkeypatch):
stages.append(stage)
if stage == "Checking DeepFilterNet3":
environment.mkdir(parents=True, exist_ok=True)
- (environment / ".voiceforge-ready").touch()
+ (environment / ".producer-ready").touch()
monkeypatch.setattr(ai, "run_process", fake_run)
monkeypatch.setattr(ai, "ensure_uv", lambda progress=None: "uv")
@@ -351,7 +351,7 @@ def test_mocked_worker_exact_length_mix_and_bounded_windows(tmp_path, wav, mocke
assert calls == []
assert max(calls, default=0) <= 674400
assert progress.call_args.args == ("Denoising (cpu)", frames, frames)
- assert not list(tmp_path.glob(".voiceforge-ai-*"))
+ assert not list(tmp_path.glob(".producer-ai-*"))
def test_worker_failure_preserves_existing_target(tmp_path, wav, mocked_worker):
@@ -363,4 +363,4 @@ def test_worker_failure_preserves_existing_target(tmp_path, wav, mocked_worker):
with pytest.raises(RuntimeError, match="inference failed"):
run(source, target, 0.85)
assert target.read_bytes() == b"existing output"
- assert not list(tmp_path.glob(".voiceforge-ai-*"))
+ assert not list(tmp_path.glob(".producer-ai-*"))