Name | pyjs-code-runner JSON |
Version |
3.0.0
JSON |
| download |
home_page | None |
Summary | A driver to run wasm code from an emscripten-forge coda env like normal python code |
upload_time | 2024-06-13 08:54:27 |
maintainer | None |
docs_url | None |
author | None |
requires_python | None |
license | Copyright (c) 2022 Dr. Thorsten Beier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
keywords |
pyjs_code_runner
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# pyjs-code-runner
[![CI](https://github.com/emscripten-forge/pyjs-code-runner/actions/workflows/main.yaml/badge.svg)](https://github.com/emscripten-forge/pyjs-code-runner/actions/workflows/main.yaml)
A driver to run python code in a wasm environment, almost like running vanilla python code.
## Motivation
Debugging, experimenting and testing python code from a dedicated conda environment
in browser environment is a complex process with a lot of (complicated) steps.
* create the environment for emscripten
* pack the environemtn
## Installation
Currently `pyjs-code-runner` is not available on PyPI. To install it, clone the repository and install it with `pip`:
We first recommend to create a new conda environment for `pyjs-code-runner`:
```bash
mamba create -n pyjs-code-runner -c conda-forge python
mamba activate pyjs-code-runner
```
Then install `pyjs-code-runner`:
```bash
git clone https://github.com/emscripten-forge/pyjs-code-runner
cd pyjs-code-runner
python -m pip install -e .
```
Then install the browser for use with Playwright:
```bash
playwright install
```
You will then need another conda environment for the code you want to run in the browser. Here we specify the `emscripten-forge` channel and the `emscripten-32` platform:
```bash
mamba create -n my_env -c https://repo.mamba.pm/emscripten-forge -c https://repo.mamba.pm/conda-forge --platform=emscripten-32 python numpy pyjs
```
You might want to add more dependencies to this environment, depending on the code you would like to run.
## Usage
Here we assume a file `main.py` located at `~/foo/bar/main.py` with the following content:
```py
import numpy as np
print("Hello from pyjs-code-runner")
print("numpy version:", np.__version__)
```
You can then run this code in the browser with the following command:
```bash
# run in browser-main-thread backend
pyjs_code_runner run script \
browser-main \
--conda-env ~/micromamba/envs/my_env `# the emscripten-forge env` \
`# in which to run the code` \
\
--mount ~/foo/bar:/home/web_user/fubar `# Mount path to virtual filesytem` \
`# <HOST_MACHINE_PATH>:<TARGET_PATH>` \
\
--script main.py `# Path of the script to run` \
`# (in virtual filesystem)` \
\
--work-dir /home/web_user/fubar `# Work directory ` \
`#in the virtual fileystem` \
\
--async-main `# should a top-level async` \
`# function named main be called` \
--headless
```
The `--headless` flag will run the browser in headless mode. If you want to see the browser open on your machine, you can remove this flag.
When you run this command you swill be able to see the output of the code in the terminal that looks like the following:
```bash
Failed to load resource: the server responded with a status of 404 (File not found)
fetching python package from ./python-3.10.2-h_hash_26_cpython.tar.gz
fetching pkg numpy from ./numpy-1.24.2-py310h6d2fff6_0.tar.gz
fetching pkg pip from ./pip-23.1-pyhd8ed1ab_0.tar.gz
fetching pkg setuptools from ./setuptools-63.4.2-py310h8bed8af_0.tar.gz
fetching pkg wheel from ./wheel-0.40.0-pyhd8ed1ab_0.tar.gz
fetching pkg pyparsing from ./pyparsing-3.0.9-pyhd8ed1ab_0.tar.gz
fetching pkg pyjs from ./pyjs-1.0.0-hc96583f_0.tar.gz
fetching pkg emscripten-abi from ./emscripten-abi-3.1.27-hb0f4dca_5.tar.gz
extract /package_tarballs/setuptools-63.4.2-py310h8bed8af_0.tar.gz (304 bytes)
extract /package_tarballs/wheel-0.40.0-pyhd8ed1ab_0.tar.gz (51524 bytes)
extract /package_tarballs/pyparsing-3.0.9-pyhd8ed1ab_0.tar.gz (90256 bytes)
extract /package_tarballs/pyjs-1.0.0-hc96583f_0.tar.gz (283 bytes)
extract /package_tarballs/emscripten-abi-3.1.27-hb0f4dca_5.tar.gz (302 bytes)
extract /package_tarballs/pip-23.1-pyhd8ed1ab_0.tar.gz (1319563 bytes)
extract /package_tarballs/python-3.10.2-h_hash_26_cpython.tar.gz (2279530 bytes)
extract /package_tarballs/numpy-1.24.2-py310h6d2fff6_0.tar.gz (3594626 bytes)
Hello from pyjs-code-runner
numpy version: 1.24.2
```
There are other ways to run the code, for example in a worker thread:
```bash
# run in browser-worker-thread backend
# in a headless fashion
pyjs_code_runner run script \
browser-worker \
--conda-env ~/micromamba/envs/my_env \
--mount ~/foo/bar:/home/web_user/fubar \
--script main.py \
--work-dir /tests \
--async-main \
--headless
```
Raw data
{
"_id": null,
"home_page": null,
"name": "pyjs-code-runner",
"maintainer": null,
"docs_url": null,
"requires_python": null,
"maintainer_email": null,
"keywords": "pyjs_code_runner",
"author": null,
"author_email": "Thorsten Beier <derthorstenbeier@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/04/9a/0fdb6cf66c2790695b42275704d383059bdec4336dc87525c62f01a9df52/pyjs_code_runner-3.0.0.tar.gz",
"platform": null,
"description": "# pyjs-code-runner\n\n[![CI](https://github.com/emscripten-forge/pyjs-code-runner/actions/workflows/main.yaml/badge.svg)](https://github.com/emscripten-forge/pyjs-code-runner/actions/workflows/main.yaml)\n\nA driver to run python code in a wasm environment, almost like running vanilla python code.\n\n## Motivation\n\nDebugging, experimenting and testing python code from a dedicated conda environment\nin browser environment is a complex process with a lot of (complicated) steps.\n\n* create the environment for emscripten\n* pack the environemtn\n\n## Installation\n\nCurrently `pyjs-code-runner` is not available on PyPI. To install it, clone the repository and install it with `pip`:\n\nWe first recommend to create a new conda environment for `pyjs-code-runner`:\n\n```bash\nmamba create -n pyjs-code-runner -c conda-forge python\nmamba activate pyjs-code-runner\n```\n\nThen install `pyjs-code-runner`:\n\n```bash\ngit clone https://github.com/emscripten-forge/pyjs-code-runner\ncd pyjs-code-runner\npython -m pip install -e .\n```\n\nThen install the browser for use with Playwright:\n\n```bash\nplaywright install\n```\n\nYou will then need another conda environment for the code you want to run in the browser. Here we specify the `emscripten-forge` channel and the `emscripten-32` platform:\n\n```bash\nmamba create -n my_env -c https://repo.mamba.pm/emscripten-forge -c https://repo.mamba.pm/conda-forge --platform=emscripten-32 python numpy pyjs\n```\n\nYou might want to add more dependencies to this environment, depending on the code you would like to run.\n\n## Usage\n\nHere we assume a file `main.py` located at `~/foo/bar/main.py` with the following content:\n\n```py\nimport numpy as np\n\nprint(\"Hello from pyjs-code-runner\")\nprint(\"numpy version:\", np.__version__)\n```\n\nYou can then run this code in the browser with the following command:\n\n```bash\n# run in browser-main-thread backend\npyjs_code_runner run script \\\n browser-main \\\n --conda-env ~/micromamba/envs/my_env `# the emscripten-forge env` \\\n `# in which to run the code` \\\n \\\n --mount ~/foo/bar:/home/web_user/fubar `# Mount path to virtual filesytem` \\\n `# <HOST_MACHINE_PATH>:<TARGET_PATH>` \\\n \\\n --script main.py `# Path of the script to run` \\\n `# (in virtual filesystem)` \\\n \\\n --work-dir /home/web_user/fubar `# Work directory ` \\\n `#in the virtual fileystem` \\\n \\\n --async-main `# should a top-level async` \\\n `# function named main be called` \\\n --headless\n\n```\n\nThe `--headless` flag will run the browser in headless mode. If you want to see the browser open on your machine, you can remove this flag.\n\nWhen you run this command you swill be able to see the output of the code in the terminal that looks like the following:\n\n```bash\nFailed to load resource: the server responded with a status of 404 (File not found)\nfetching python package from ./python-3.10.2-h_hash_26_cpython.tar.gz\nfetching pkg numpy from ./numpy-1.24.2-py310h6d2fff6_0.tar.gz\nfetching pkg pip from ./pip-23.1-pyhd8ed1ab_0.tar.gz\nfetching pkg setuptools from ./setuptools-63.4.2-py310h8bed8af_0.tar.gz\nfetching pkg wheel from ./wheel-0.40.0-pyhd8ed1ab_0.tar.gz\nfetching pkg pyparsing from ./pyparsing-3.0.9-pyhd8ed1ab_0.tar.gz\nfetching pkg pyjs from ./pyjs-1.0.0-hc96583f_0.tar.gz\nfetching pkg emscripten-abi from ./emscripten-abi-3.1.27-hb0f4dca_5.tar.gz\nextract /package_tarballs/setuptools-63.4.2-py310h8bed8af_0.tar.gz (304 bytes)\nextract /package_tarballs/wheel-0.40.0-pyhd8ed1ab_0.tar.gz (51524 bytes)\nextract /package_tarballs/pyparsing-3.0.9-pyhd8ed1ab_0.tar.gz (90256 bytes)\nextract /package_tarballs/pyjs-1.0.0-hc96583f_0.tar.gz (283 bytes)\nextract /package_tarballs/emscripten-abi-3.1.27-hb0f4dca_5.tar.gz (302 bytes)\nextract /package_tarballs/pip-23.1-pyhd8ed1ab_0.tar.gz (1319563 bytes)\nextract /package_tarballs/python-3.10.2-h_hash_26_cpython.tar.gz (2279530 bytes)\nextract /package_tarballs/numpy-1.24.2-py310h6d2fff6_0.tar.gz (3594626 bytes)\nHello from pyjs-code-runner\nnumpy version: 1.24.2\n```\n\nThere are other ways to run the code, for example in a worker thread:\n\n```bash\n# run in browser-worker-thread backend\n# in a headless fashion\npyjs_code_runner run script \\\n browser-worker \\\n --conda-env ~/micromamba/envs/my_env \\\n --mount ~/foo/bar:/home/web_user/fubar \\\n --script main.py \\\n --work-dir /tests \\\n --async-main \\\n --headless\n```",
"bugtrack_url": null,
"license": "Copyright (c) 2022 Dr. Thorsten Beier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \u201cSoftware\u201d), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED \u201cAS IS\u201d, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.",
"summary": "A driver to run wasm code from an emscripten-forge coda env like normal python code",
"version": "3.0.0",
"project_urls": {
"Homepage": "https://github.com/emscripten-forge/pyjs-code-runner"
},
"split_keywords": [
"pyjs_code_runner"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "2026aaa422871c99e1272cbaccb4d6f7170a7323a2cf5d25bebace7c16badd1f",
"md5": "2eed0f367a64c1b00cdccb3f6a566319",
"sha256": "1a85fc04a26a011c92014b8b9c106188a66c4c8bf05b2f94047a009da19c20f4"
},
"downloads": -1,
"filename": "pyjs_code_runner-3.0.0-py2.py3-none-any.whl",
"has_sig": false,
"md5_digest": "2eed0f367a64c1b00cdccb3f6a566319",
"packagetype": "bdist_wheel",
"python_version": "py2.py3",
"requires_python": null,
"size": 21344,
"upload_time": "2024-06-13T08:54:25",
"upload_time_iso_8601": "2024-06-13T08:54:25.677161Z",
"url": "https://files.pythonhosted.org/packages/20/26/aaa422871c99e1272cbaccb4d6f7170a7323a2cf5d25bebace7c16badd1f/pyjs_code_runner-3.0.0-py2.py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "049a0fdb6cf66c2790695b42275704d383059bdec4336dc87525c62f01a9df52",
"md5": "ff690bdc4dac1631a08e7543b0198d0d",
"sha256": "0430e0d9eab8f580b510d673ea43411efcf7d72e8a50a98f5c6e5dd25a0f5847"
},
"downloads": -1,
"filename": "pyjs_code_runner-3.0.0.tar.gz",
"has_sig": false,
"md5_digest": "ff690bdc4dac1631a08e7543b0198d0d",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 15065,
"upload_time": "2024-06-13T08:54:27",
"upload_time_iso_8601": "2024-06-13T08:54:27.317708Z",
"url": "https://files.pythonhosted.org/packages/04/9a/0fdb6cf66c2790695b42275704d383059bdec4336dc87525c62f01a9df52/pyjs_code_runner-3.0.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-06-13 08:54:27",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "emscripten-forge",
"github_project": "pyjs-code-runner",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "pyjs-code-runner"
}