From 99de8a774d976613a5bdc1757504dfc7f1c69ea6 Mon Sep 17 00:00:00 2001 From: Etienne Perot Date: Wed, 10 Jan 2024 11:58:58 -0800 Subject: [PATCH] `ollama` client library: Include command output in the error message. This helps debugging ollama-based tests. PiperOrigin-RevId: 597316714 --- test/gpu/ollama/ollama.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/test/gpu/ollama/ollama.go b/test/gpu/ollama/ollama.go index 55f9670fc..2ab32c125 100644 --- a/test/gpu/ollama/ollama.go +++ b/test/gpu/ollama/ollama.go @@ -124,7 +124,13 @@ func (llm *Ollama) request(ctx context.Context, endpoint string, data []byte) ([ Image: "basic/busybox", Links: []string{llm.container.MakeLink("llm")}, }, cmd...) - return []byte(out), err + if err != nil { + if out != "" { + return []byte(out), fmt.Errorf("command %q failed (%w): %v", strings.Join(cmd, " "), err, out) + } + return nil, fmt.Errorf("could not run command %q: %w", strings.Join(cmd, " "), err) + } + return []byte(out), nil } // jsonGet performs a JSON HTTP GET request.