MCPcopy
hub / github.com/cortexlabs/cortex / taskAPITable

Function taskAPITable

cli/cmd/lib_task_apis.go:85–138  ·  view source on GitHub ↗
(taskAPI schema.APIResponse)

Source from the content-addressed store, hash-verified

83}
84
85func taskAPITable(taskAPI schema.APIResponse) string {
86 jobRows := make([][]interface{}, 0, len(taskAPI.TaskJobStatuses))
87
88 out := ""
89 if len(taskAPI.TaskJobStatuses) == 0 {
90 out = console.Bold("no submitted task jobs\n")
91 } else {
92 for _, job := range taskAPI.TaskJobStatuses {
93 jobEndTime := time.Now()
94 if job.EndTime != nil {
95 jobEndTime = *job.EndTime
96 }
97
98 duration := jobEndTime.Sub(job.StartTime).Truncate(time.Second).String()
99
100 jobRows = append(jobRows, []interface{}{
101 job.ID,
102 job.Status.Message(),
103 job.StartTime.Format(_timeFormat),
104 duration,
105 })
106 }
107
108 t := table.Table{
109 Headers: []table.Header{
110 {Title: "task job id"},
111 {Title: "status"},
112 {Title: "start time"},
113 {Title: "duration"},
114 },
115 Rows: jobRows,
116 }
117
118 out += t.MustFormat()
119 }
120
121 if taskAPI.DashboardURL != nil && *taskAPI.DashboardURL != "" {
122 out += "\n" + console.Bold("metrics dashboard: ") + *taskAPI.DashboardURL + "\n"
123 }
124
125 if taskAPI.Endpoint != nil {
126 out += "\n" + console.Bold("endpoint: ") + *taskAPI.Endpoint + "\n"
127 }
128
129 out += "\n" + apiHistoryTable(taskAPI.APIVersions)
130
131 if !_flagVerbose {
132 return out
133 }
134
135 out += titleStr("task api configuration") + taskAPI.Spec.UserStr()
136
137 return out
138}
139
140func getTaskJob(env cliconfig.Environment, apiName string, jobID string) (string, error) {
141 resp, err := cluster.GetTaskJob(MustGetOperatorConfig(env.Name), apiName, jobID)

Callers 1

getAPIFunction · 0.85

Calls 9

MustFormatMethod · 0.95
BoldFunction · 0.92
apiHistoryTableFunction · 0.85
titleStrFunction · 0.85
SubMethod · 0.80
MessageMethod · 0.80
StringMethod · 0.45
FormatMethod · 0.45
UserStrMethod · 0.45

Tested by

no test coverage detected