Skip to content

Commit

Permalink
Implement Explanations in RPC (#131)
Browse files Browse the repository at this point in the history
## What is the goal of this PR?
We add Explanations, and the explain() query endpoint to the protocol. This enables all clients to retrieve all available explanations for a particular explainable concept map.

## What are the changes implemented in this PR?
* Implement `Explainable` and `Explainables` as part of `Answer` protocol
* Implement `Explanation` as part of `Logic` protocol
* Add `Explain.Req` and `Explain.Res` as part of the explain QueryManager endpoing
  • Loading branch information
flyingsilverfin authored Mar 30, 2021
1 parent 71b277a commit d0bdb87
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 2 deletions.
4 changes: 3 additions & 1 deletion common/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ proto_library(

proto_library(
name = "logic-proto",
srcs = ["logic.proto"]
srcs = ["logic.proto"],
deps = [":answer-proto"]
)

proto_library(
Expand All @@ -45,6 +46,7 @@ proto_library(
srcs = ["query.proto"],
deps = [
":answer-proto",
":logic-proto",
":options-proto",
],
)
Expand Down
17 changes: 16 additions & 1 deletion common/answer.proto
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,22 @@ package grakn.protocol;

message ConceptMap {
map<string, Concept> map = 1;
string pattern = 2;
Explainables explainables = 2;
}

message Explainables {
map<string, Explainable> relations = 1;
map<string, Explainable> attributes = 2;
map<string, Owned> ownerships = 3;

message Owned {
map<string, Explainable> owned = 1;
}
}

message Explainable {
string conjunction = 1;
int64 id = 2;
}

message ConceptMapGroup {
Expand Down
14 changes: 14 additions & 0 deletions common/logic.proto
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ syntax = "proto3";
option java_package = "grakn.protocol";
option java_outer_classname = "LogicProto";

import "common/answer.proto";


package grakn.protocol;

message LogicManager {
Expand Down Expand Up @@ -106,3 +109,14 @@ message Rule {
message Res {}
}
}

message Explanation {
Rule rule = 1;
map<string, VarList> var_mapping = 2;
ConceptMap condition = 3;
ConceptMap conclusion = 4;

message VarList {
repeated string vars = 1;
}
}
13 changes: 13 additions & 0 deletions common/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ option java_package = "grakn.protocol";
option java_outer_classname = "QueryProto";

import "common/answer.proto";
import "common/logic.proto";
import "common/options.proto";

package grakn.protocol;
Expand All @@ -39,6 +40,7 @@ message QueryManager {
Insert.Req insert_req = 106;
Delete.Req delete_req = 107;
Update.Req update_req = 108;
Explain.Req explain_req = 109;
}
}

Expand All @@ -58,6 +60,7 @@ message QueryManager {
MatchGroupAggregate.ResPart match_group_aggregate_res_part = 102;
Insert.ResPart insert_res_part = 103;
Update.ResPart update_res_part = 104;
Explain.ResPart explain_res_part = 105;
}
}

Expand Down Expand Up @@ -100,6 +103,16 @@ message QueryManager {
}
}

message Explain {
message Req {
int64 explainable_id = 1;
}

message ResPart {
repeated Explanation explanations = 1;
}
}

message Insert {
message Req {
string query = 1;
Expand Down

0 comments on commit d0bdb87

Please sign in to comment.