-
Notifications
You must be signed in to change notification settings - Fork 3
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: add delete all KG nodes example #164
Conversation
Codecov Report
@@ Coverage Diff @@
## master #164 +/- ##
==========================================
+ Coverage 67.27% 75.30% +8.02%
==========================================
Files 43 39 -4
Lines 2790 2316 -474
==========================================
- Hits 1877 1744 -133
+ Misses 842 515 -327
+ Partials 71 57 -14 see 4 files with indirect coverage changes 📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
Closing ENG-1939
10df5cb
to
3203ca0
Compare
examples/knowledge/cmd/delete.go
Outdated
resp, err := clientIngest.StreamRecords(records) | ||
if err != nil { | ||
fmt.Println(err.Error()) | ||
} | ||
for _, response := range resp { | ||
fmt.Println(jsonp.Format(response)) | ||
} |
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.
Why Knowledge example call Ingest?
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.
what I said yesterday:create a temporary example where both knowledge and ingest are called until the 2 packages are united with the merge of identity in knowledge graph
examples/knowledge/cmd/root.go
Outdated
jsonp = protojson.MarshalOptions{ | ||
cfgFile string | ||
client *knowledge.Client | ||
clientIngest *ingest.Client |
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.
Same as above. Why in examples for Knowledge we have Ingest client?
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.
for the moment, I cannot create a delete all with only knowledge or only ingest
knowledge/knowledge_read.go
Outdated
func (c *Client) NodesRecordsWithTypeNode( | ||
ctx context.Context, | ||
nodeType string, | ||
opts ...grpc.CallOption, | ||
) ([]*ingestpb.Record, error) { | ||
ctx = insertMetadata(ctx, c.xMetadata) | ||
path := fmt.Sprintf("(:%s)", nodeType) | ||
resp, err := c.client.IdentityKnowledge(ctx, &knowledgepb.IdentityKnowledgeRequest{ | ||
Path: path, | ||
Operation: knowledgepb.Operation_OPERATION_READ, | ||
}, opts...) | ||
if err != nil { | ||
return nil, err | ||
} | ||
nodes, err := parseMultipleNodesFromPaths(resp.GetPaths()) | ||
if err != nil { | ||
return nil, err | ||
} | ||
records := []*ingestpb.Record{} | ||
for _, node := range nodes { | ||
caser := cases.Title(language.English) | ||
record := &ingestpb.Record{ | ||
Id: GenerateRandomString(12), | ||
Operation: &ingestpb.Record_Delete{ | ||
Delete: &ingestpb.DeleteData{ | ||
Data: &ingestpb.DeleteData_Node{ | ||
Node: &ingestpb.NodeMatch{ | ||
ExternalId: node.ExternalId, | ||
Type: caser.String(node.Type), | ||
}, | ||
}, | ||
}, | ||
}, // lint:file-ignore U1000 Ignore report | ||
} | ||
records = append(records, record) | ||
} | ||
return records, nil | ||
} |
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.
Can you explain what is the purpose of this method? Why it is generating some random string? This sounds kind a weird. @maaland any inputs?
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.
the random is to generate an id for for record: they can be anything, their value is not used for anything else
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.
the purpose is to get all nodes of a certain type and transform them into records ready to be deleted
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.
after discussion with @maaland, I'm going to create a helper package
Closing ENG-1939
Closing ENG-1939
Closing ENG-1939