MCPcopy
hub / github.com/determined-ai/determined / PprintCommand

Function PprintCommand

agent/pkg/cruntimes/crutils.go:72–99  ·  view source on GitHub ↗

PprintCommand provides pretty printing of the given command to trace & log outputs.

(
	ctx context.Context,
	command string,
	args []string,
	p events.Publisher[docker.Event],
	log *logrus.Entry,
)

Source from the content-addressed store, hash-verified

70
71// PprintCommand provides pretty printing of the given command to trace & log outputs.
72func PprintCommand(
73 ctx context.Context,
74 command string,
75 args []string,
76 p events.Publisher[docker.Event],
77 log *logrus.Entry,
78) error {
79 toPrint := command
80 for _, arg := range args {
81 if strings.HasPrefix(arg, "--") { // print each arg on a new line
82 toPrint += " \\\n"
83 toPrint += "\t"
84 toPrint += arg
85 } else {
86 toPrint += " "
87 toPrint += arg
88 }
89 }
90
91 log.Trace(toPrint)
92 if err := p.Publish(ctx, docker.NewLogEvent(
93 model.LogLevelDebug,
94 toPrint,
95 )); err != nil {
96 return err
97 }
98 return nil
99}
100
101// CanonicalizeImage returns the canonicalized image name.
102func CanonicalizeImage(image string) string {

Callers 1

PullImageFunction · 0.85

Calls 2

NewLogEventFunction · 0.92
PublishMethod · 0.65

Tested by

no test coverage detected