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

EI-2742 - Introduce updated SparqlQuery RPC (for FKG) #36

Merged
merged 1 commit into from
Mar 25, 2024
Merged

Conversation

vtermanis
Copy link
Member

@vtermanis vtermanis commented Feb 26, 2024

  • ⚠️ Do not merge until squashed & commit renamed (to reflect new request naming)
  • Local-scope SparqlQuery can be performed with FKGQuery local-scope Same as before now
  • This will stay as a draft until EI-2743 has been implemented

@@ -82,29 +80,6 @@ enum SparqlResultType {
RDF_NTRIPLES = 5;
}

// SparqlQueryRequest describes a SPARQL query.
message SparqlQueryRequest {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note to reviewers: This is not re-used/modified since ExplorerQuery still uses it.

// belongs. The result is returned as a sequence of chunks. Note that:
// - Result chunks MIGHT arrive out of order and it is the client's responsibility to re-assemble them.
// - This RPC is currently in alpha!
rpc FKGQuery(FKGQueryRequest) returns (stream FKGQueryResponse) {}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do think of just keeping the SparqlQuery naming?
Seems like FKGQuery just muddies the water.
The doc string can indicate the enhanced abilities, but its still just sending a sparql query?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure - I hadn't realised we were happy with keeping exactly the same name 👍

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// belongs. The result is returned as a sequence of chunks. Note that:
// - Result chunks MIGHT arrive out of order and it is the client's responsibility to re-assemble them.
// - This RPC is currently in alpha!
rpc FKGQuery(FKGQueryRequest) returns (stream FKGQueryResponse) {}
Copy link
Member

@smartrics smartrics Feb 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need the FKG prefix in all the items?
Can't we assume this is "the" only API we'll ever need?
If we need specialisations, then the name of the specialisation can be added

Also does Query imply only the ability to read only?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Query is read-only (just like before SparqlQuery & SparqlUpdate) - but see above - I'll change it back to SparqlQuery

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

24d01b6
(Note that I'll change the commit message at the end. Probably easier to look at the whole diff rather than my fixup)

rpc SparqlQuery(SparqlQueryRequest) returns (stream SparqlQueryResponse) {}
// FKGQuery performs a SPARQL 1.1 query against the Federated Knowledge Graph of the Iotics network to which this host
// belongs. The result is returned as a sequence of chunks. Note that:
// - Result chunks MIGHT arrive out of order and it is the client's responsibility to re-assemble them.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why the out of order?
it all chunks are guaranteed to be produced, why can't they be reordered by the server?

Copy link
Member Author

@vtermanis vtermanis Feb 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because we don't really want to buffer an arbitrary amount of data, in memory, on the server

Scope scope = 2;

// SPARQL query request payload
Payload payload = 3;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need the payload?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes we need it to be consistent with everything else in the API


// The desired result content type. Note that choosing an invalid result type for the type of query will result in
// an error status reported in the response. (See SparqlResultType for valid content-query type combinations.)
SparqlResultType resultContentType = 1;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you document the behaviour if resultContentType isn't specified

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure - I'll add the default

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

24d01b6 (basically it'll be the default enum value since the field cannot be "empty")

bool last = 2;

// Content type of the result.
SparqlResultType contentType = 3;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you need this? or will it be == to the valye in the request

Copy link
Member Author

@vtermanis vtermanis Feb 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it will be equal.
This is so that the receiver of responses doesn't need to know about the request necessarily. (We have the same approach in the original SparqlQuery and other fields such as - headers with client references)


// Query result chunk, encoded according to actualType.
// Note that:
// - The maximum size of each chunk is host-specific.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how does one find what the value is?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no way yet but we could (later) expose a host high-level conf page. It could be part of an admin API, etc. For now it is visible via the AWS console

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK - so it should be possible to document the current value here in the API?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could hint at a default but I think "hard coding" it here in the docs means we cannot change it.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@StephanieBracaloni
Copy link
Contributor

Local-scope SparqlQuery can be performed with FKGQuery local-scope

Local-scope SparqlQuery will be removed in the end

@StephanieBracaloni
Copy link
Contributor

It looks good in principle. It is consistent with what we have in the API in general and the chunking approach is consistent with what we were doing for Sparql query (minus the multi-host reply).

I would vote for a more generic name like "SparqlQuery".
👍

@vtermanis
Copy link
Member Author

Local-scope SparqlQuery will be removed in the end

If you mean the old SparqlQuery+local will be replaced - sure.
But if you mean there will be no way to query just the local host .. why wouldn't this be a useful feature? (Or am I missing the point here - we still have scope?)

@vtermanis vtermanis changed the title EI-2742 - Introduce FKGQuery RPC, remove SparqlQuery EI-2742 - Introduce updated SparqlQuery RPC (for FKG) Feb 27, 2024
@StephanieBracaloni
Copy link
Contributor

Local-scope SparqlQuery will be removed in the end

If you mean the old SparqlQuery+local will be replaced - sure. But if you mean there will be no way to query just the local host .. why wouldn't this be a useful feature? (Or am I missing the point here - we still have scope?)

This just means the existing SparqlQuery will be removed.

@vtermanis vtermanis marked this pull request as ready for review March 7, 2024 19:23
message Payload {

// Position of a chunk in result for a given request. The first chunk has a sequence number of 0.
uint64 seqNum = 1;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question (CC @StephanieBracaloni ): Do we want to keep this compatible in terms of field indexes by starting with 2 here? (hostId was 1 before)?
That way existing SPARQL requests made should still work and hostId would be ignored.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The field indexes do not matter (ie. it is ok if it starts from 2).
However, we don't want to/don't have to keep things compatible since we have announced a breaking change (even if only internal since sparql query is not used publicly yet) and the response format will also break the compatibility.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The field indexes do not matter

the response format will also break the compatibility

.. this is the only difference? (I don't understand what you mean but never mind.)

Anyway - if we're OK to break - let's keep start at index 1, as you would if it were brand new 👍

- Local-scope SparqlQuery can be performed with FKGQuery local-scope
@vtermanis vtermanis merged commit 8c959fe into main Mar 25, 2024
1 check passed
@vtermanis vtermanis deleted the ei-2742 branch March 25, 2024 08:26
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.

4 participants