Skip to content

Retrievable explanations, Restrict explanations to ConceptMaps #20

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

Merged
merged 3 commits into from
Oct 29, 2019

Conversation

flyingsilverfin
Copy link
Member

@flyingsilverfin flyingsilverfin commented Oct 28, 2019

What is the goal of this PR?

Explanations can exceed the gRPC message size limits. This change allows retrieving explanations separately from the ConceptMap answers themselves, allowing us to break the deep nesting and long messages contained in a single answer.

The paradigm for retriving an explanation is now as follows:
A ConceptMap always contains a pattern and a boolean flag hasExplanation. If the ConceptMap has an explanation, a call can be made using message type Explanation.Req, returning a list of ConceptMap that correspond to to a single layer of the explanation tree.

Unused Explanation messages have been removed from answers other than ConceptMap.

What are the changes implemented in this PR?

  • ConceptMap contains conceptMap, pattern and hasExplanation
  • A new RPC endpoint can be performed by clients using type Explanation.Req, returning Explanation.Res
  • Explanation removed from answers other than ConceptMap

@haikalpribadi haikalpribadi merged commit 143b06e into typedb:master Oct 29, 2019
@flyingsilverfin flyingsilverfin deleted the retrieve-explanation branch October 29, 2019 11:27
flyingsilverfin added a commit to typedb/typedb that referenced this pull request Nov 1, 2019
## What is the goal of this PR?
Large explanations can break gRPC message limits, specifically nesting depth when returning deep explanation trees. With this change, each layer of the explanation tree can be retrieved from the server separately. This reflects the changes in the protocol here: typedb/typedb-protocol#20. 

We retain the storage of Explanation trees on the Server, and expose a new RPC message with corresponding handler on the server to retrieve particular layers of the tree using the query pattern provided by the client. The query pattern is used to access the query cache directly.

Additionally, `pattern` in `ConceptMap`s now contain the IDs indicated in the actual concept map as well.

Finishes #4605, and #4545 

## What are the changes implemented in this PR?
* `Pattern` has been moved from `Explanation` to `ConceptMap`
* `Answer` interface is empty and requires further refactoring
* Propagate `Pattern` throughout reasoner conclusions
* Reconstruct `Explanation` objects from the query cache when the user requests an explanation a concept map
* Update some tests
* Solve previously unnoticed explanation bug: when re-querying the same query, the explanation is shallow (ie. a `LookupExplanation`) rather than the full reasoner tree
flyingsilverfin added a commit to typedb/typedb-driver that referenced this pull request Nov 5, 2019
## What is the goal of this PR?
Matching protocol changes in typedb/typedb-protocol#20, we now iteratively retrieve layers of the `Explanation` tree of a `ConceptMap` answer. `ConceptMap.explanation()` does a round trip to the Grakn server and retrieves a list of `ConceptMap` that explain how the given concept map was obtained. We also restrict `Explanation` to only be obtainable from `ConceptMap`, given that we have not implemented `Explanation` on delete, count, etc. queries.

## What are the changes implemented in this PR?
* Implement typedb/typedb-protocol#20
* `ConceptMap` contains a `queryPattern` -- this is empty if reasoner is not triggered, and the new method `hasExplanation()` will return `false`
* When `hasExplanation()` is true, it is possible to send the ConceptMap back to the server via `Transaction` to obtain an `Explanation` object
* `Explanation` object only contains a list of `ConceptMap`
* Refactor tests and add an Explanation test
@lolski lolski added this to the 1.0.3 milestone Nov 22, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants