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

Investigate setting Pyodide HTTP headers via a service worker #903

Open
tuzz opened this issue Jan 24, 2024 · 2 comments · May be fixed by #904
Open

Investigate setting Pyodide HTTP headers via a service worker #903

tuzz opened this issue Jan 24, 2024 · 2 comments · May be fixed by #904
Assignees

Comments

@tuzz
Copy link
Contributor

tuzz commented Jan 24, 2024

More context: https://raspberrypifoundation.slack.com/archives/C02JBAA2NFP/p1705670224318489

Currently, we are setting some HTTP headers on CloudFlare. We should investigate whether it's possible to set these using a service worker instead to keep application-specific behaviour outside of CloudFlare and within the editor-ui project. We should also look into the approach for the embedded editor, which will be on a different site where we don't necessary control the CloudFlare HTTP headers.

https://dev.to/stefnotch/enabling-coop-coep-without-touching-the-server-2d3n

@tuzz tuzz self-assigned this Jan 24, 2024
Copy link
Contributor

create-issue-branch bot added a commit that referenced this issue Jan 24, 2024
tuzz added a commit that referenced this issue Feb 13, 2024
This pull request adds experimental support for running Python programs
using Pyodide. The code is based on the
[python-execution-prototypes](https://github.com/RaspberryPiFoundation/python-execution-prototypes)
and the [technical
analysis](https://docs.google.com/document/d/1mpKliJaqYYkPJR1hGLZxUDhNFOwgBm69nc70iiVj_3I/edit#heading=h.3orc9tdzyy4b)
document. The related GitHub issue is
#891.

The PyodideRunner.jsx can be used instead of the current
PythonRunner.jsx (Skulpt) by provided a `?pyodide=true` parameter in the
URL as shown in the screenshot below:

<img width="1439" alt="Screenshot 2024-01-30 at 11 39 01"
src="https://github.com/RaspberryPiFoundation/editor-ui/assets/892251/a0185ec3-aaf5-40d4-a5e8-e9973fb1c98f">

### Notes

The PyodideRunner supports the following features:
- Execution of Python programs
- Importing of [most
of](https://pyodide.org/en/stable/usage/wasm-constraints.html) Python's
standard library
- Importing of [many
common](https://pyodide.org/en/stable/usage/packages-in-pyodide.html)
Python packages
- Importing of pure Python packages from PyPi
- Stopping execution
- Sending standard input to Python programs
- Closing the standard input stream by pressing `Ctrl-d`
- Visualising turtle graphics using the [modified turtle
package](https://github.com/RaspberryPiFoundation/turtle)
- Visualising pygal charts using the [modified pygal
package](https://github.com/RaspberryPiFoundation/pygal.js)

Due to time constraints, the following tasks remain outstanding:

- Visualising sense_hat graphics using the [modified sense_hat
package](https://github.com/RaspberryPiFoundation/sense_hat)
- There is a work-in-progress pull request
[here](#913)
- Apply HTTP headers in a service worker (see
#903)
- Note that `crossorigin` will need to be added to cross-domain
resources once the HTTP headers are added
- Add unit/integration tests that run real Python programs through the
PyodideRunner.jsx
- Manual testing for backwards compatibility of existing Python
programs, projects and the WebComponent
- Implementing the p5 package to work with Pyodide
- See
https://github.com/RaspberryPiFoundation/python-execution-prototypes/issues/1
- Implementing a dedicated SQL editor for use in the Ada CS project
- Note that Pyodide supports importing `sqlite3` so we can add a UI
wrapper around it

---------

Co-authored-by: Scott Adams <[email protected]>
@loiswells97 loiswells97 assigned loiswells97 and sra405 and unassigned tuzz Mar 8, 2024
@sra405
Copy link
Contributor

sra405 commented Mar 21, 2024

check in incognito

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 a pull request may close this issue.

3 participants