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

Implement wasi-keyvalue #2486

Closed
wants to merge 1 commit into from
Closed

Conversation

itowlson
Copy link
Contributor

@itowlson itowlson commented May 3, 2024

An exploratory PR for exploring, apropos of #2447.

@itowlson
Copy link
Contributor Author

itowlson commented May 3, 2024

I had to add the wasi-keyvalue import to the old world to get the runtime test to compile. I assume in practice that's not what we'd aim to do though, we'd instead create a new world version and expose it only through that?

@itowlson
Copy link
Contributor Author

itowlson commented May 5, 2024

Do folks have any insights on how to move this forward? It seems to work but I am not quite sure what do about the worlds stuff:

  1. Should this create a rev of the Spin world?
  2. The runtime tests appear use an old world: is there plumbing to let them use a current world?

@itowlson itowlson linked an issue May 6, 2024 that may be closed by this pull request
@itowlson itowlson requested review from dicej and lann May 9, 2024 00:17
@itowlson
Copy link
Contributor Author

@dicej @lann There is a request to move this forward for the impending release or the one after. Are you the right folks to review, or should I pester someone else?

@dicej
Copy link
Contributor

dicej commented Jun 10, 2024

Yup, I can take a look tomorrow morning.

@dicej
Copy link
Contributor

dicej commented Jun 10, 2024

@kate-goldenring might also be interested, given her recent work on the specification.

async fn open(
&mut self,
identifier: String,
) -> anyhow::Result<Result<Resource<wasi_keyvalue::store::Bucket>, wasi_keyvalue::store::Error>>
Copy link
Collaborator

Choose a reason for hiding this comment

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

You can use the trappable_error_type option to make the signatures here a bit easier to work with. See the llm implementation for an example use.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks @rylev. I gave this a try and am not sure how I feel about. I've left it in a separate commit and would value your thoughts...

) -> anyhow::Result<Result<wasi_keyvalue::store::KeyResponse, wasi_keyvalue::store::Error>>
{
if cursor.unwrap_or_default() != 0 {
anyhow::bail!("list_keys: cursor not supported");
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is the plan to eventually support the cursor?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

"Plan" is a strong word but, yes, it would be desirable to do on back-ends that support it. For this initial implementation I stuck to using the existing KV implementation which unfortunately do not support cursors.

wit/world.wit Outdated
@@ -16,6 +16,7 @@ world http-trigger-rc20231018 {
world platform {
include wasi:cli/[email protected];
import wasi:http/[email protected];
import wasi:keyvalue/[email protected];
Copy link
Collaborator

Choose a reason for hiding this comment

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

We definitely need to decide how we want to handle introducing new imports. This will break any Spin runtime that does not have wasi:keyvalue support.

Copy link
Collaborator

Choose a reason for hiding this comment

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

It seems like we should be bumping the WIT package version here right? This is still a little scary as we haven't even done it with WASI 0.2.1 yet...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, this was one of my questions: #2486 (comment). Do we need a separate conversation about how to do this?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we need a separate conversation about how to do this?

Probably? I'm not sure that anyone knows how best to handle this yet.

Copy link
Contributor

@dicej dicej left a comment

Choose a reason for hiding this comment

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

LGTM overall -- thanks for doing this!

I expect we'll need to implement cursors before we can really claim to support wasi:keyvalue/store, and that may be the most interesting part of this project given the variety of backends we now support (SQLite, Redis, and Azure).

wit/world.wit Outdated
@@ -30,6 +31,7 @@ world platform {
world platform-rc20231018 {
include wasi:cli/[email protected];
import wasi:http/[email protected];
import wasi:keyvalue/[email protected];
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd recommend not adding anything new to platform-rc20231018 -- it's only really here for backwards compatibility. In hindsight, I think we probably shouldn't have added mqtt either.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree! The trouble is that the tests all (currently) use this world, so if we want tests for wasi-keyvalue then we will need to rev the test world, and I'm not sure of the implications of that. #2486 (comment)

Copy link
Contributor

@kate-goldenring kate-goldenring left a comment

Choose a reason for hiding this comment

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

LGTM. @itowlson should we mark this as ready to review?

wit/deps/keyvalue-2024-05-03/world.wit Show resolved Hide resolved
@itowlson
Copy link
Contributor Author

@kate-goldenring I was planning to leave it as draft until we have a decision on WIT versioning. I can mark ready for review and label "do not merge" if that would be better?

@kate-goldenring
Copy link
Contributor

I was planning to leave it as draft until we have a decision on WIT versioning. I can mark ready for review and label "do not merge" if that would be better?

@itowlson leaving as is is fine. Thanks for clarifying the decision criteria.

@radu-matei
Copy link
Member

Just to validate an assumption I had reading this PR: this PR adds support for the WASI KV proposal — specifically, it allows guests to use the proposal to interact with stores — and stores are still managed through the manifest key_value_stores field. Is that accurate?

Thanks!

@itowlson
Copy link
Contributor Author

@radu-matei Yes. The KV stores are the exact same KV stores as you would get if you used the Spin APIs, specified and configured in exactly the same way.

@radu-matei
Copy link
Member

radu-matei commented Aug 20, 2024

Is the intention to update this PR and have WASI KV be part of the Spin world?

I am not sure what the decision criteria for WIT versioning (which I understand is blocking this PR) is.

@itowlson
Copy link
Contributor Author

@radu-matei That is the intention, but we don't yet know how to version the Spin world (at least I don't, and from previous comments this seems to be a general problem, unless the community has figured something out since June).

@itowlson itowlson force-pushed the wasi-keyvalue branch 3 times, most recently from 514500a to 14b0cc1 Compare October 16, 2024 03:25
@itowlson itowlson changed the title Exploration: wasi-keyvalue Implement wasi-keyvalue Oct 16, 2024
@itowlson
Copy link
Contributor Author

Rebased onto world3 (#2887). @devigned if you are working on this then please note the proposed new world and new file layout. (The last commit is how wasi-keyvalue fits in - the earlier commits are tracking the world3 proposal.) Also please note that these are not yet final...!

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.

Support wasi-keyvalue
6 participants