Capture pipeline readiness diagnostics and failures
This commit is contained in:
@@ -22,6 +22,11 @@ type SmokeObservation struct {
|
||||
// RunSmokeChecks executes each selected access and structured generation check
|
||||
// once, stopping at the first unsuccessful required observation.
|
||||
func RunSmokeChecks(ctx context.Context, engine *promptkit.Engine, targets Targets, execution *promptkit.ExecutionTargetOverride, retries *int) ([]SmokeObservation, error) {
|
||||
return RunSmokeChecksObserved(ctx, engine, targets, execution, retries, nil)
|
||||
}
|
||||
|
||||
// RunSmokeChecksObserved delivers each observation before starting the next diagnostic.
|
||||
func RunSmokeChecksObserved(ctx context.Context, engine *promptkit.Engine, targets Targets, execution *promptkit.ExecutionTargetOverride, retries *int, observe func(SmokeObservation) error) ([]SmokeObservation, error) {
|
||||
if ctx == nil {
|
||||
return nil, errors.New("preflight context must not be nil")
|
||||
}
|
||||
@@ -29,11 +34,17 @@ func RunSmokeChecks(ctx context.Context, engine *promptkit.Engine, targets Targe
|
||||
return nil, err
|
||||
}
|
||||
var observations []SmokeObservation
|
||||
total := 2*len(targets.Access) + len(targets.Profiles)
|
||||
run := func(kind promptkit.SmokeTestKind, profile, backend string, bindings []BindingScope) error {
|
||||
report, err := engine.SmokeTest(ctx, promptkit.SmokeTestRequest{Kind: kind, ProfileID: profile, Execution: execution, TransientRetries: retries})
|
||||
observation := SmokeObservation{Kind: kind, ProfileID: profile, BackendID: backend, Bindings: bindings, Report: report}
|
||||
observation.Applicable, observation.Err = evaluateSmoke(kind, report, err)
|
||||
observations = append(observations, observation)
|
||||
if observe != nil {
|
||||
if observeErr := observe(observation); observeErr != nil && observation.Err == nil && len(observations) < total {
|
||||
return observeErr
|
||||
}
|
||||
}
|
||||
return observation.Err
|
||||
}
|
||||
for _, target := range targets.Access {
|
||||
|
||||
Reference in New Issue
Block a user