Skip to content

Commit

Permalink
Send job logs to pod logs
Browse files Browse the repository at this point in the history
  • Loading branch information
RobGeada committed Nov 11, 2024
1 parent a652c60 commit f06c428
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions controllers/lmes/driver/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,20 @@ func (dc *driverComm) notifyShutdownWait() {
dc.connection <- 1
}

type FormattedWriter struct{}

func (f FormattedWriter) Write(p []byte) (n int, err error) {
// format lm-eval output to stdout
line := string(p)
res, err := fmt.Print(line)

// carriage returns do not correctly display, so replace with newlines
if strings.ContainsAny(line, "\r") && !strings.ContainsAny(line, "\n") {
fmt.Print("\n")
}
return res, err
}

func (d *driverImpl) exec() error {
// create Unitxt task recipes
if err := d.createTaskRecipes(); err != nil {
Expand Down Expand Up @@ -316,8 +330,8 @@ func (d *driverImpl) exec() error {

// have a pipe to check the output and report progress
// lm-eval's outputs are in the stderr
pr, pw := io.Pipe()
mwriter := io.MultiWriter(stderr, pw)
pr, _ := io.Pipe()
mwriter := io.MultiWriter(stderr, FormattedWriter{})
scanner := bufio.NewScanner(pr)

executor := exec.Command(d.Option.Args[0], args...)
Expand Down

0 comments on commit f06c428

Please sign in to comment.