Harden prepare and transcribe transitions
This commit is contained in:
@@ -112,6 +112,7 @@ func (transcribeStage) Run(ctx context.Context, env *Env, m *manifest.Manifest)
|
||||
jobCh = make(chan job)
|
||||
mu sync.Mutex
|
||||
firstErr error
|
||||
completed int
|
||||
perFile = map[string]map[string]any{}
|
||||
outputRef = map[string]artifacts.Ref{}
|
||||
)
|
||||
@@ -175,6 +176,7 @@ func (transcribeStage) Run(ctx context.Context, env *Env, m *manifest.Manifest)
|
||||
SessionID: sessionID,
|
||||
AbsolutePath: j.outPath,
|
||||
}
|
||||
completed++
|
||||
mu.Unlock()
|
||||
}
|
||||
}
|
||||
@@ -184,12 +186,14 @@ func (transcribeStage) Run(ctx context.Context, env *Env, m *manifest.Manifest)
|
||||
go worker()
|
||||
}
|
||||
|
||||
dispatched := 0
|
||||
dispatch:
|
||||
for _, j := range jobs {
|
||||
select {
|
||||
case <-stageCtx.Done():
|
||||
break dispatch
|
||||
case jobCh <- j:
|
||||
dispatched++
|
||||
}
|
||||
}
|
||||
close(jobCh)
|
||||
@@ -198,6 +202,12 @@ dispatch:
|
||||
if firstErr != nil {
|
||||
return nil, firstErr
|
||||
}
|
||||
if err := ctx.Err(); err != nil {
|
||||
return nil, fmt.Errorf("transcribe: canceled after dispatching %d of %d audio jobs and completing %d: %w", dispatched, len(jobs), completed, err)
|
||||
}
|
||||
if completed != len(jobs) {
|
||||
return nil, fmt.Errorf("transcribe: completed %d of %d planned audio jobs after dispatching %d", completed, len(jobs), dispatched)
|
||||
}
|
||||
|
||||
speakers := make([]string, 0, len(perFile))
|
||||
for speaker := range perFile {
|
||||
|
||||
Reference in New Issue
Block a user