Skip to content

Better handling of metadata #7

Description

@solvicode

The metadata handling in the Go SDK is not great:

func deviationDetector(params *orca.ExecutionParams) (orca.Result, error) {
	var p_h float64 = Config.PriorOnReset
	var p_h_e float64 = Config.PriorOnReset

	var currentWindow = params.Window
	var metadata = make(map[string]any, len(NewDatapoint.MetadataFields))
	for _, field := range NewDatapoint.MetadataFields {
		val, ok := currentWindow.Metadata[field.Name]
		if !ok {
			return nil, fmt.Errorf("expected field %v", field.Name)
		}
		metadata[field.Name] = val
	}
	currentVector, ok := metadata[VECTOR_FIELD_NAME]
	if !ok {
		return nil, fmt.Errorf("could not retreived the current vector. looking for %v", VECTOR_FIELD_NAME)
	}

	vLowPrec, ok := currentVector.(structpb.ListValue)
...

I don't want to have to manually parse out the struct PB values. I should expect the fields to be there... Perhaps we can do this validation behind the scenes in the SDK?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions