Skip to content

Add a storage equivalent for JS #2165

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 2 commits into from
Sep 13, 2024
Merged

Conversation

WebReflection
Copy link
Contributor

Description

When discussing #2164 I've realized there is no easy way to directly communicate between JS and Python through persistent data (being json, files, or buffers) without needing to provide a sync exported function that would require a worker on the Python side to work as expected.

One idea here is to provide, as exported utility a part, also a way to read or write persistent data through the storage so that either JS or Python can somehow indirectly communicate through saved data.

This MR creates an extra artifact without affecting core size and I think we should be able to use storage to be able to even save SQLite buffers so that both worlds can later on read data and keep working on such data, being this JS related or Python related.

Changes

  • replicate our stdlib storage as JS utility (it's a Proxy due differences between Python and JS around intercepting operations)
  • test that these two can communicate given a proper timely way to save persistent data

Checklist

  • All tests pass locally
  • I have updated CHANGELOG.md
  • I have created documentation for this(if applicable)

@WebReflection WebReflection requested a review from ntoll September 13, 2024 09:05
Copy link
Member

@ntoll ntoll left a comment

Choose a reason for hiding this comment

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

Yes. This is a good call!

@WebReflection WebReflection merged commit 1ed7732 into pyscript:main Sep 13, 2024
2 checks passed
@Neon22
Copy link
Contributor

Neon22 commented Sep 13, 2024

I am not smart enough to work out how to use this from examining the commit.
Is there an example ?

@WebReflection
Copy link
Contributor Author

The integration test is an example but more examples will come once we get the SQLite story right (or other use cases)

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.

3 participants