Skip to content
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

Closed
wants to merge 3 commits into from
Closed

Conversation

cowan-macady
Copy link
Contributor

Closing ENG-1939

@cowan-macady cowan-macady requested a review from a team as a code owner October 26, 2023 14:42
@cowan-macady cowan-macady requested a review from arxeiss October 26, 2023 14:42
@codecov
Copy link

codecov bot commented Oct 26, 2023

Codecov Report

Merging #164 (5654efe) into master (5ee2989) will increase coverage by 8.02%.
The diff coverage is n/a.

@@            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

Comment on lines 43 to 49
resp, err := clientIngest.StreamRecords(records)
if err != nil {
fmt.Println(err.Error())
}
for _, response := range resp {
fmt.Println(jsonp.Format(response))
}
Copy link
Contributor

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?

Copy link
Contributor Author

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

jsonp = protojson.MarshalOptions{
cfgFile string
client *knowledge.Client
clientIngest *ingest.Client
Copy link
Contributor

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?

Copy link
Contributor Author

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

Comment on lines 274 to 311
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
}
Copy link
Contributor

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?

Copy link
Contributor Author

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

Copy link
Contributor Author

@cowan-macady cowan-macady Oct 27, 2023

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

Copy link
Contributor Author

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

@arxeiss arxeiss deleted the delete-node-in-kg branch February 9, 2024 12:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants