Verify mixed audio retries and transport
This commit is contained in:
@@ -238,6 +238,8 @@ sidecars are not accidentally promoted into manifest-selected audio.
|
|||||||
|
|
||||||
## Stage 6: Verify partial retry and byte-preserving transport
|
## Stage 6: Verify partial retry and byte-preserving transport
|
||||||
|
|
||||||
|
**Complete.** Mixed-format durable retry, changed-input reconciliation, S3 bytes, HTTP upload, and replay tests pass.
|
||||||
|
|
||||||
Read existing per-speaker checkpoint tests and WhisperX multipart/replay tests,
|
Read existing per-speaker checkpoint tests and WhisperX multipart/replay tests,
|
||||||
especially `TestTranscribeFailureCheckpointsEarlierSpeakersAndRetryRunsOnlyRemaining`
|
especially `TestTranscribeFailureCheckpointsEarlierSpeakersAndRetryRunsOnlyRemaining`
|
||||||
and `TestMultipartBodyReplayUsesIdenticalFraming`.
|
and `TestMultipartBodyReplayUsesIdenticalFraming`.
|
||||||
|
|||||||
@@ -40,8 +40,8 @@ func TestHTTPClientTransportReplaysAbandonedMultipartBody(t *testing.T) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
parts := parseMultipartParts(t, request.Header.Get("Content-Type"), replayedBytes)
|
parts := parseMultipartParts(t, request.Header.Get("Content-Type"), replayedBytes)
|
||||||
if len(parts) != 2 || parts[0].name != "file" || parts[0].filename != "audio.flac" || string(parts[0].data) != "audio-data" {
|
if len(parts) != 2 || parts[0].name != "file" || parts[0].filename != "audio.unfamiliar" || string(parts[0].data) != "audio-data" {
|
||||||
t.Fatalf("replayed file part = %#v, want exact audio.flac payload", parts)
|
t.Fatalf("replayed file part = %#v, want exact audio.unfamiliar payload", parts)
|
||||||
}
|
}
|
||||||
if parts[1].name != "language" || string(parts[1].data) != "en" {
|
if parts[1].name != "language" || string(parts[1].data) != "en" {
|
||||||
t.Fatalf("replayed language part = %#v, want language=en", parts[1])
|
t.Fatalf("replayed language part = %#v, want language=en", parts[1])
|
||||||
@@ -56,7 +56,7 @@ func TestHTTPClientTransportReplaysAbandonedMultipartBody(t *testing.T) {
|
|||||||
outPath := filepath.Join(t.TempDir(), "raw.json")
|
outPath := filepath.Join(t.TempDir(), "raw.json")
|
||||||
|
|
||||||
result, err := client.Transcribe(context.Background(), TranscribeRequest{
|
result, err := client.Transcribe(context.Background(), TranscribeRequest{
|
||||||
AudioPath: "audio.flac",
|
AudioPath: "audio.unfamiliar",
|
||||||
OutputRawTranscriptPath: outPath,
|
OutputRawTranscriptPath: outPath,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ func TestHTTPClientTranscribeSuccess(t *testing.T) {
|
|||||||
t.Fatalf("NewHTTPClientFromConfigValues() error = %v", err)
|
t.Fatalf("NewHTTPClientFromConfigValues() error = %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
audioPath := writeWhisperXTestFile(t, "audio.flac", "audio-data")
|
audioPath := writeWhisperXTestFile(t, "audio.mp3", "audio-data")
|
||||||
outPath := filepath.Join(t.TempDir(), "raw.json")
|
outPath := filepath.Join(t.TempDir(), "raw.json")
|
||||||
|
|
||||||
res, err := client.Transcribe(context.Background(), TranscribeRequest{
|
res, err := client.Transcribe(context.Background(), TranscribeRequest{
|
||||||
@@ -74,8 +74,8 @@ func TestHTTPClientTranscribeSuccess(t *testing.T) {
|
|||||||
if gotLanguage != "en" {
|
if gotLanguage != "en" {
|
||||||
t.Fatalf("language = %q, want en", gotLanguage)
|
t.Fatalf("language = %q, want en", gotLanguage)
|
||||||
}
|
}
|
||||||
if gotFileField != "audio.flac" {
|
if gotFileField != "audio.mp3" {
|
||||||
t.Fatalf("file field filename = %q, want audio.flac", gotFileField)
|
t.Fatalf("file field filename = %q, want audio.mp3", gotFileField)
|
||||||
}
|
}
|
||||||
if gotFileSize == 0 {
|
if gotFileSize == 0 {
|
||||||
t.Fatal("file size = 0, want >0")
|
t.Fatal("file size = 0, want >0")
|
||||||
|
|||||||
@@ -305,6 +305,8 @@ func TestPrepareStageS3AudioDownloadAndMaterialization(t *testing.T) {
|
|||||||
t.Fatalf("expected file %q: %v", p, err)
|
t.Fatalf("expected file %q: %v", p, err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
mustReadFileEquals(t, aliceWork, "alice")
|
||||||
|
mustReadFileEquals(t, bobWork, "bob")
|
||||||
if got := result.Metadata["audio_reused"]; got != 0 {
|
if got := result.Metadata["audio_reused"]; got != 0 {
|
||||||
t.Fatalf("audio_reused = %#v, want 0", got)
|
t.Fatalf("audio_reused = %#v, want 0", got)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -559,3 +559,89 @@ func TestTranscribeAudioDiscoveryValidatesSelectedInputs(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestMixedAudioPreparationRetryAndReconciliation(t *testing.T) {
|
||||||
|
env, m := setupTranscribeEnv(t, nil)
|
||||||
|
root := filepath.Dir(env.Config.SessionPath)
|
||||||
|
files := []string{"first/a.flac", "second/a.flac", "b.mp3", "c.flac", "z.unknown"}
|
||||||
|
for _, name := range files {
|
||||||
|
writeFile(t, filepath.Join(root, name), "bytes-"+name)
|
||||||
|
}
|
||||||
|
env.Config.Session.Inputs.AudioFiles = files
|
||||||
|
one := 1
|
||||||
|
env.Config.Pipeline.WhisperX.Concurrency = &one
|
||||||
|
if _, err := (prepareStage{}).Run(context.Background(), env, m); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
paths := sessionPathsForEnv(env, m.SessionID)
|
||||||
|
prepared, err := buildTranscribeJobs(m, paths)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
if len(prepared) != len(files) || prepared[0].audioPath == prepared[1].audioPath {
|
||||||
|
t.Fatalf("jobs %#v", prepared)
|
||||||
|
}
|
||||||
|
for _, input := range m.Inputs {
|
||||||
|
if input.Kind == "audio" {
|
||||||
|
data, err := os.ReadFile(input.Path)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
if !strings.HasPrefix(string(data), "bytes-") {
|
||||||
|
t.Fatalf("unexpected bytes for %s: %q", input.Path, data)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
backendErr := errors.New("unsupported or malformed audio")
|
||||||
|
env.WhisperX = &whisperx.FakeClient{TranscribeFn: func(_ context.Context, req whisperx.TranscribeRequest) (whisperx.TranscribeResult, error) {
|
||||||
|
if req.SpeakerID == "z" {
|
||||||
|
return whisperx.TranscribeResult{}, backendErr
|
||||||
|
}
|
||||||
|
if err := writeJSONFile(req.OutputRawTranscriptPath, map[string]any{"speaker": req.SpeakerID}); err != nil {
|
||||||
|
return whisperx.TranscribeResult{}, err
|
||||||
|
}
|
||||||
|
return whisperx.TranscribeResult{OutputRawTranscriptPath: req.OutputRawTranscriptPath}, nil
|
||||||
|
}}
|
||||||
|
if _, err := (transcribeStage{}).Run(context.Background(), env, m); !errors.Is(err, backendErr) {
|
||||||
|
t.Fatalf("backend failure: %v", err)
|
||||||
|
}
|
||||||
|
durable, err := env.ManifestStore.Load(context.Background(), paths.ManifestPath)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
if len(durable.Stages["transcribe"].TranscribeSpeakers) != 4 {
|
||||||
|
t.Fatalf("checkpoints: %#v", durable.Stages["transcribe"].TranscribeSpeakers)
|
||||||
|
}
|
||||||
|
retry := &whisperx.FakeClient{}
|
||||||
|
env.WhisperX = retry
|
||||||
|
if _, err := (transcribeStage{}).Run(context.Background(), env, durable); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
requests := retry.RequestsSnapshot()
|
||||||
|
if len(requests) != 1 || requests[0].SpeakerID != "z" {
|
||||||
|
t.Fatalf("retry requests: %#v", requests)
|
||||||
|
}
|
||||||
|
durable, err = env.ManifestStore.Load(context.Background(), paths.ManifestPath)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
var changed string
|
||||||
|
for _, job := range prepared {
|
||||||
|
if job.speakerID == "b" {
|
||||||
|
changed = job.audioPath
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if changed == "" {
|
||||||
|
t.Fatal("missing b speaker")
|
||||||
|
}
|
||||||
|
writeFile(t, changed, "changed audio")
|
||||||
|
retry = &whisperx.FakeClient{}
|
||||||
|
env.WhisperX = retry
|
||||||
|
if _, err := (transcribeStage{}).Run(context.Background(), env, durable); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
requests = retry.RequestsSnapshot()
|
||||||
|
if len(requests) != 1 || requests[0].SpeakerID != "b" {
|
||||||
|
t.Fatalf("changed requests: %#v", requests)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user