-
Notifications
You must be signed in to change notification settings - Fork 0
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
feat: VEC-185 allow index definitions in yaml as input and output #8
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #8 +/- ##
=======================================
Coverage ? 79.55%
=======================================
Files ? 34
Lines ? 1996
Branches ? 0
=======================================
Hits ? 1588
Misses ? 344
Partials ? 64 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM just a single nit
cmd/indexCreate.go
Outdated
if err != io.EOF { | ||
logger.Error("failed to unmarshal index definitions", slog.Any("error", err)) | ||
return err | ||
} | ||
|
||
logger.Debug("read index definitions from stdin", slog.Any("data", data)) | ||
|
||
// Unmarshal YAML data | ||
intermediate := map[string]interface{}{} | ||
err = yaml.Unmarshal([]byte(data), &intermediate) | ||
if err != nil { | ||
logger.Error("failed to unmarshal index definitions", slog.Any("error", err)) | ||
return err | ||
} | ||
|
||
jsonBytes, err := json.Marshal(intermediate) | ||
if err != nil { | ||
logger.Error("failed to marshal index definitions", slog.Any("error", err)) | ||
return err | ||
} | ||
|
||
logger.Debug("marshalled index definitions", slog.Any("data", string(jsonBytes))) | ||
|
||
stdinIndexDefinitions = &protos.IndexDefinitionList{} | ||
|
||
err = protojson.Unmarshal(jsonBytes, stdinIndexDefinitions) | ||
if err != nil { | ||
logger.Error("failed to unmarshal index definitions", slog.Any("error", err)) | ||
return err | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: I think these log lines should include what kind of marshaling/unmarshaling that failed so it's easier to tell which step failed from the logs.
The following 3 cmds will now work:
asvec index list --yaml > indexDef.yaml
cat indexDef.yaml | asvec index create
asvec index create --file indexDef.yaml