Skip to content

Tweak cx get verbose output #263

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 26, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 39 additions & 37 deletions cli/cmd/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,8 @@ func describeAPI(name string, resourcesRes *schema.GetResourcesResponse, flagVer

out += titleStr("Model Input Signature")

out += describeModelInput(groupStatus, apiEndpoint)

if modelName, ok := yaml.ExtractAtSymbolText(api.Model); ok {
model := ctx.Models[modelName]
resIDs := strset.New()
Expand All @@ -489,51 +491,51 @@ func describeAPI(name string, resourcesRes *schema.GetResourcesResponse, flagVer
}
sort.Strings(samplePlaceholderFields)
samplesPlaceholderStr := `{ "samples": [ { ` + strings.Join(samplePlaceholderFields, ", ") + " } ] }"
out += "Payload: " + samplesPlaceholderStr + "\n"
} else {
if groupStatus.Available() == 0 {
out += "Waiting for API to be ready"
return out, nil
}
out += "\n\nPayload: " + samplesPlaceholderStr
}

modelInput, err := getModelInput(urls.Join(apiEndpoint, "signature"))
if err != nil {
out += "Waiting for API to be ready"
return out, nil
}
return out, nil
}

rows := make([][]interface{}, len(modelInput.Signature))
rowNum := 0
for inputName, featureSignature := range modelInput.Signature {
shapeStr := make([]string, len(featureSignature.Shape))
for idx, dim := range featureSignature.Shape {
if dim == 0 {
shapeStr[idx] = "?"
} else {
shapeStr[idx] = s.Int(dim)
}
}
rows[rowNum] = []interface{}{
inputName,
featureSignature.Type,
s.ObjFlatNoQuotes(shapeStr),
func describeModelInput(groupStatus *resource.APIGroupStatus, apiEndpoint string) string {
if groupStatus.Available() == 0 {
return "Waiting for API to be ready"
}

modelInput, err := getModelInput(urls.Join(apiEndpoint, "signature"))
if err != nil {
return "Waiting for API to be ready"
}

rows := make([][]interface{}, len(modelInput.Signature))
rowNum := 0
for inputName, featureSignature := range modelInput.Signature {
shapeStr := make([]string, len(featureSignature.Shape))
for idx, dim := range featureSignature.Shape {
if dim == 0 {
shapeStr[idx] = "?"
} else {
shapeStr[idx] = s.Int(dim)
}
rowNum++
}

t := table.Table{
Headers: []table.Header{
{Title: "FEATURE", MaxWidth: 32},
{Title: "TYPE", MaxWidth: 10},
{Title: "SHAPE", MaxWidth: 20},
},
Rows: rows,
rows[rowNum] = []interface{}{
inputName,
featureSignature.Type,
"(" + strings.Join(shapeStr, ", ") + ")",
}
rowNum++
}

out += table.MustFormat(t)
t := table.Table{
Headers: []table.Header{
{Title: "FEATURE", MaxWidth: 32},
{Title: "TYPE", MaxWidth: 10},
{Title: "SHAPE", MaxWidth: 20},
},
Rows: rows,
}

return out, nil
return table.MustFormat(t)
}

func getModelInput(infoAPIPath string) (*schema.ModelInput, error) {
Expand Down