Coder Social home page Coder Social logo

jupyterlite / xeus Goto Github PK

View Code? Open in Web Editor NEW
20.0 5.0 11.0 743 KB

JupyterLite loader for Xeus kernels

Home Page: https://jupyterlite-xeus.readthedocs.io

License: BSD 3-Clause "New" or "Revised" License

JavaScript 3.09% Python 60.10% TypeScript 36.45% CSS 0.36%
jupyterlite webassembly xeus

xeus's Introduction

JupyterLite Xeus

Github Actions Status

JupyterLite loader for Xeus kernels

Requirements

  • JupyterLab >= 4.0.0

Install

To install the extension, execute:

pip install jupyterlite_xeus

Usage

From environment.yml

xeus-python kernel

To load a xeus-python kernel with a custom environment, create an environment.yml file with xeus-python and the desired dependencies. Here is an example with numpy as a additional dependency:

name: xeus-lite-wasm
channels:
  - https://repo.mamba.pm/emscripten-forge
  - conda-forge
dependencies:
  - xeus-python
  - numpy

To build JupyterLite, run the following command where environment.yml is the path to the file you just created

jupyter lite build --XeusAddon.environment_file=some_path/to/environment.yml

xeus-lua / xeus-sqlite / xeus-<mylang>

To load a xeus-lua or xeus-sqlite kernel you can do the same as above, just with

dependencies:
  - xeus-lua

or

dependencies:
  - xeus-sqlite

Note that xeus-sqlite and xeus-lua do not support additional dependencies yet. To build JupyterLite, run again:

jupyter lite build --XeusAddon.environment_file=environment.yml

Multiple kernels

To create a deployment with multiple kernels, you can simply add them to the environment.yml file:

name: xeus-lite-wasm
channels:
  - https://repo.mamba.pm/emscripten-forge
  - conda-forge
dependencies:
  - xeus-python
  - xeus-lua
  - xeus-sqlite
  - numpy

From local environment / prefix

When developing a xeus-kernel, it is very useful to be able to test it in JupyterLite without having to publish the kernel to emscripten-forge. Therefore, you can also use a local environment / prefix to build JupyterLite with a custom kernel.

Create a local environment / prefix

This workflow usually starts with creating a local conda environment / prefix for the emscripten-wasm32 platform with all the dependencies required to build your kernel (here we install dependencies for xeus-python).

micromamba create -n xeus-python-dev \
    --platform=emscripten-wasm32 \
    -c https://repo.mamba.pm/emscripten-forge \
    -c conda-forge \
    --yes \
    "python>=3.11" pybind11 nlohmann_json pybind11_json numpy pytest \
    bzip2 sqlite zlib libffi xtl pyjs \
    xeus xeus-lite

Build the kernel

This depends on your kernel, but it will look something like this:

# path to your emscripten emsdk
source $EMSDK_DIR/emsdk_env.sh

WASM_ENV_NAME=xeus-python-dev
WASM_ENV_PREFIX=$MAMBA_ROOT_PREFIX/envs/$WASM_ENV_NAME

# let cmake know where the env is
export PREFIX=$WASM_ENV_PREFIX
export CMAKE_PREFIX_PATH=$PREFIX
export CMAKE_SYSTEM_PREFIX_PATH=$PREFIX

cd /path/to/your/kernel/src
mkdir build_wasm
cd build_wasm
emcmake cmake \
    -DCMAKE_BUILD_TYPE=Release \
    -DCMAKE_FIND_ROOT_PATH_MODE_PACKAGE=ON \
    -DCMAKE_INSTALL_PREFIX=$PREFIX \
    ..
emmake make -j8 install

Build the JupyterLite site

You will need to create a new environment with the dependencies to build the JupyterLite site.

# create new environment
micromamba create -n xeus-lite-host \
    jupyterlite-core

# activate the environment
micromamba activate xeus-lite-host

# install jupyterlite_xeus via pip
python -m pip install jupyterlite-xeus

When running jupyter lite build, we pass the prefix option and point it to the local environment / prefix we just created:

jupyter lite build --XeusAddon.prefix=$WASM_ENV_PREFIX

Mounting additional files

To copy additional files and directories into the virtual filesystem of the xeus-lite kernels you can use the --XeusAddon.mount option. Each mount is specified as a pair of paths separated by a colon :. The first path is the path to the file or directory on the host machine, the second path is the path to the file or directory in the virtual filesystem of the kernel.

jupyter lite build \
    --XeusAddon.environment_file=environment.yml \
    --XeusAddon.mounts=/some/path/on/host_machine:/some/path/in/virtual/filesystem

Contributing

Development install from a conda / mamba environment

Create the conda environment with conda/mamba/micromamba (replace micromamba with conda or mamba according to your preference):

micromamba create -f environment-dev.yml -n xeus-lite-dev

Activate the environment:

micromamba activate xeus-lite-dev
python -m pip install -e .   -v --no-build-isolation

Packaging the extension

See RELEASE.

xeus's People

Contributors

derthorsten avatar isabelparedes avatar jtpio avatar katotetsuro avatar martinrenou avatar vipul-cariappa avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

xeus's Issues

Load SVG icons for kernels

There are some kernels providing an SVG icon as part of their kernel spec. We should make use of it when available.

todos to make jupyterlite/xeus the default (ie steps to deprectate jupyterlite/xeus-<lang>-kernels

What is needed to replace jupyterlite/xeus--kernels (in particular jupyterlite/xeus-python-kernel):

  • at least some documentation on how to use this (#8)
    • usage with kernels installed from emscripten-forge
    • usage with kernels installed from local PREFIX
    • usage with additional directories mounted
  • expose empack filtering configuration as a parameter (like xeus-python-kernel) (#12)
  • make tests pass #14
  • add / port tests jupyterlite/xeus-python-kernel (#7)
  • release on PyPI / release on conda-forge (does this need to be also on npm?) (#15)

Probably needed:

  • documentation on readthedocs #17

how to get sspyrs module included

Would it be possible to get the module sspyrs working, or a replacement ?
If I put it or its requirement requests-ntlm in the "environment.yml", the build fails.

... yet "requets" seems to be there

# requests works in  jupyterlite/xeus-python-demo !
import requests
from datetime import date, timedelta, datetime

today = date.today()
yesterday = today - timedelta(days=10)
country =  "germany"
endpoint = f"https://api.covid19api.com/country/{country}/status/confirmed"
params = {"from": str(yesterday), "to": str(today)}
print(params)
endpoint_via_browser = f"https://api.covid19api.com/country/germany/status/confirmed?from=2022-12-06&to=2022-12-22"

response = requests.get(endpoint, params=params).json()
total_confirmed = 0
for day in response:
    date_python = datetime.fromisoformat(day.get("Date", 0)[:-1] + '+00:00')
    print(date_python.strftime('%Y-%m-%d'), f'{day.get("Cases", 0):_.0f}')
    cases = day.get("Cases", 0)
    total_confirmed += cases

print(f"Total Confirmed Covid-19 cases in {country}: {total_confirmed:_.0f}")

image

Support for package data

Description

I have a Python package which includes package data, to be accessed
through importlib.resources. However, within jupyterlite, importlib.resources
fails do find the data.

Reproduce

  1. Clone https://github.com/jupyterlite/xeus-python-demo

  2. Add these dependencies to environment.yml

      - pip
      - pip:
        - "git+https://gitlab.dsi.universite-paris-saclay.fr/nicolas.thiery/Laby.git"
    
  3. Build JupyterLite

    mamba env create --force -f build-environment.yml
    conda activate build-env
    cp README.md content
    jupyter lite build --contents content --output-dir dist
    
  4. Check the log, and notice the copying of the package data when building the wheel:

    creating build/bdist.linux-x86_64/wheel/laby/resources/tiles_png
    copying build/lib/laby/resources/tiles_png/nweb.png -> build/bdist.linux-x86_64/wheel/laby/resources/tiles_png
    ...
    
  5. Browse dist/extensions/@jupyterlite/xeus-python-kernel/static/laby_python-0.0.5-pip.tar.gz

    Expected behavior: the archive contain the package data.
    Got: the package contains only the Python code

  6. Run JupyterLite and from a python kernel run:

    tiles_dir = importlib.resources.files("laby").joinpath("resources", "tiles_png")
    list(tiles_dir.glob("*"))
    

    Expected behavior: a list of files including 'nweb.png`.
    Got: the empty list

Context

  • JupyterLite version: 0.1.2
  • Operating System and version: Ubuntu 22.04
  • Browser and version: Firefox/chromium

Update the JupyterLite main documentation to mention this new package

Problem

In https://jupyterlite.readthedocs.io/en/stable/howto/xeus-python/preinstalled_packages.html, there is a link pointing to https://github.com/jupyterlite/xeus-python-kernel.

image

For reference this piece of documentation was added to the main JupyterLite documentation for visibility and discoverability of the Xeus Python kernel.

Suggested Improvement

We should update the JupyterLite main documentation to point to this new repo.

This can wait until jupyterlite-xeus is considered ready for general use.

UnicodeEncodeError on open()

Description

This may not be the problem with jupyterlite-xeus,
If I try to open a file with a path that contains Unicode characters, such as open('あ'), I get a UnicodeEncodeError.

Reproduce

  1. Go to https://jupyterlite-xeus.readthedocs.io/en/latest/
  2. execute open('あ')
  3. UnicodeEncodeError: 'ascii' codec can't encode character '\u3042' in position 14: ordinal not in range(128)

Context

import locale
locale.getencoding()
> 'ASCII'

Unlike pyodide, the result of locale.getencoding() is 'ASCII', so if I could set the locale somewhere, it would solve the problem.

Is the locale in empack or conda env affecting it?

Unexpected behavior using `ipympl` called from `sympy_plot_backends`, same code works as expected using `pyodide` kernel

Description

With sympy_plot_backends I create an interactive plot that shows the graph of a parameter dependent function. With a slider it is possible to change the parameter value. After changing the slider value, the plot should be updated. In sympy_plot_backends interactive matplotlib is used.

With pyodide-kernel for jupyterlite this feature is working as expected. With xeus-python there is a glitch: After changing the slider value, the graph is not directly updated. As soon as I click into the drawing pane, the graph gets updated.

Reproduce

Execute the following code in a notebook:

import sympy
%matplotlib widget
import spb

x = sympy.Symbol('x', real=True)
a = sympy.Symbol('a', real=True)

f = sympy.cos(x)/(x**2 + 1)

spb.plot(
    f.subs(x, x-a),
    params = {
        a: (0, -5, 5)
    }
)
  • Now change the slider value for a from the default 0.0 to something nonzero.
  • Observe that the plot does not change.
  • Click into the plot.
  • Observe that now the plot has been updated as expected.

Expected behavior

The plot should update without clicking into the plot pane. With pyodide kernel it is working as expected.

Context

Xeus Python Environment file:

name: xeus-python-kernel

channels:
  - https://repo.mamba.pm/emscripten-forge
  - conda-forge

dependencies:
  - ipympl
  - matplotlib
  - numpy
  - sympy
  - sympy_plot_backends
  • JupyterLite version: 0.2.1
  • Operating System and version: OS X
  • Browser and version: Chrome 120.0.6099.71 and Safari 17.2 (19617.1.17.11.9)

Kernel binaries missing

Originally opened by @Alberto199810 in voici-demo voila-dashboards/voici-demo#23

Hello guys, I'm working on GitLab, and I'm using your library to deploy the Jupyter Notebook on GL Pages. The Pipeline end in success, and everything seems fine, apart from the fact that when I try to launch the page, it is stuck at the "Running" phase.

It seemed to me that the Kernel was not starting, and indeed in the deploy pipeline I've found this row:
"""
{...}/python3.10/site-packages/jupyterlite_xeus/add_on.py: UserWarning: kernel binaries not found for xpython-raw
"""

And then again same thing:

"""
{...}/python3.10/site-packages/jupyterlite_xeus/add_on.py: UserWarning: kernel binaries not found for xpython
"""

So, my feeling is that apparently it is not recognizing the kernel. Any idea in how to solve this?

add parameter to Worker Constructor?

Within the worker.ts we import the kernel specific js file (here it is still xeus_lua.js)
https://github.com/jupyterlite/xeus-kernel/blob/ded2690d2a0a706dfa3b7dc2608cf41a5a57429e/src/worker.ts#L3
The question is, can we pass the actual import to the constructor here https://github.com/jupyterlite/xeus-kernel/blob/ded2690d2a0a706dfa3b7dc2608cf41a5a57429e/src/xeus_server_kernel.ts#L20
or do we need to send the import statement as a message to the worker?

I would like to avoid sending the actual import path (like xeus_lua.js / xeus_wren.js) to the worker via message and would prefer if that could be done at construction time of the worker, if possible.

@jtpio any suggestions =)

Automatically add the `emscripten-forge` channel if it is missing?

Problem

Currently the default channels are only added if there is no environment file:

# open the env yaml file if it's provided
if env_file.exists():
with open(env_file, "r") as file:
yaml_content = yaml.safe_load(file)
env_name = yaml_content.get("name", "xeus-env")
env_prefix = root_prefix / "envs" / env_name
self.prefix = str(env_prefix)
create_conda_env_from_env_file(root_prefix, yaml_content, env_file.parent)
else:
create_conda_env_from_specs(
env_name=env_name,
root_prefix=root_prefix,
specs=["xeus-python"],
channels=["https://repo.mamba.pm/emscripten-forge", "conda-forge"],
)

Proposed Solution

Maybe the add-on should check if the user-provided environment.yml includes https://repo.mamba.pm/emscripten-forge in the list of channels, and add it automatically otherwise?

Additional context

This could help improving compatibility with existing environment.yml files without having to create a copy of the file with https://repo.mamba.pm/emscripten-forge in it.

And also for use cases such as repo2jupyterlite: jupyterlite/repo2jupyterlite#19

Show a warning if there is no kernel installed

If there is no kernel installed, the extension fails with:

   File "/home/runner/micromamba/envs/build-env/lib/python3.12/pathlib.py", line 1056, in iterdir
    for name in os.listdir(self):
                ^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmp2ay0_eyo/env/envs/xeus-env/share/jupyter/kernels'

It would be nice to have a nice user-friendly message instead.

%load doesn't work as hoped on https

Trying to get this to work

%load  https://raw.githubusercontent.com/MicrosoftDocs/mslearn-introduction-to-machine-learning/main/graphing.py 

I get an error:

/tmp/xeus-python-kernel/envs/xeus-python-kernel/lib/python3.10/urllib/request.py in unknown_open(self, req)
   1417     def unknown_open(self, req):
   1418         type = req.type
-> 1419         raise URLError('unknown url type: %s' % type)
   1420 
   1421 def parse_keqv_list(l):

URLError: <urlopen error unknown url type: https>

is it a limitation ? is there a simple workaround ? (via javascript alternative ?)

Add an option to disable the logs in the dev tools console

Problem

Currently there are quite a few messages in the dev tools console when starting a kernel:

image

These messages can add a bit of noise and some deployments might want to silent them.

Proposed Solution

  • Provide an option to disable the logs
  • Show the logs by default or not?

Additional context

Testing with:

  • jupyterlite-xeus-python 0.9.0
  • empack 3.0.0

mounts as lists where better..

I believe mounts as a List where better than comma-separated strings.

with lists I could do the following for three relatively long mounts

jupyter lite build  \
        --XeusAddon.prefix=$XEUS_PYTHON_WASM_ENV_PREFIX 
        --XeusAddon.mounts="$WASM_ENV_PREFIX/lib/python3.11/site-packages/nxtgm:/lib/python3.11/site-packages/nxtgm"
        --XeusAddon.mounts="$WASM_ENV_PREFIX/lib/nxtgm/__extra__/:/lib/"
        --XeusAddon.mounts="$WASM_ENV_PREFIX/lib/nxtgm/plugins:/lib/nxtgm/plugins"

With the comma separated this looks like the follwoing (horrible)

jupyter lite build  \
        --XeusAddon.prefix=$XEUS_PYTHON_WASM_ENV_PREFIX 
        --XeusAddon.mounts="$WASM_ENV_PREFIX/lib/python3.11/site-packages/nxtgm:/lib/python3.11/site-packages/nxtgm,XeusAddon.mounts="$WASM_ENV_PREFIX/lib/nxtgm/__extra__/:/lib/,$WASM_ENV_PREFIX/lib/nxtgm/plugins:/lib/nxtgm/plugins"

So to make this somewhat sane with the comma-separated list I have to introduce some variables
and call it with the variables.

MOUNT_PYTHON_PKG="$WASM_ENV_PREFIX/lib/python3.11/site-packages/nxtgm:/lib/python3.11/site-packages/nxtgm"
MOUNT_LIBNXTGM="$WASM_ENV_PREFIX/lib/nxtgm/__extra__/:/lib/"
MOUNT_NXTGM_PLUGINS="$WASM_ENV_PREFIX/lib/nxtgm/plugins:/lib/nxtgm/plugins"

# jupyterlite
jupyter lite build \
        --XeusAddon.prefix=$XEUS_PYTHON_WASM_ENV_PREFIX \
        --XeusAddon.mounts=$MOUNT_PYTHON_PKG,$MOUNT_LIBNXTGM,$MOUNT_NXTGM_PLUGINS

I suggest using a list of strings, and each entry can be comma-separated.
That way we get the best of both worlds

Please add more detail and examples in installing a local Python package

In https://xeus-python-kernel.readthedocs.io/en/latest/configuration.html, it says that: "You can also install a local Python package, this is very practical if you want to embed a jupyterlite deployment in your Package documentation, allowing to test the very latest dev version:

name: xeus-python-kernel
channels:
  - https://repo.mamba.pm/emscripten-forge
  - conda-forge
dependencies:
  - pip:
      - .."

If I want to install a wheel named "a.wheel", it seems the following YAML works

dependencies:
  - pip:
      - "./a.wheel"

To install wheels of a folder named b, it seems the following YAML does not work.

dependencies:
  - pip:
      - "./b/*.wheel"

I am wondering what is the right way to do so.

make tests pass / fix integration tests

  • Integration tests (testing it shows kernels with icons properly in the lite UI)
  • Unit tests (testing it correctly generates the expected output in the build directory)

xhr is called synchronously

Description

getJson helper is using XMLHttpRequest synchronously, which is deprecated and does not work well with service worker. Is there any technical season to avoid async call here or can we convert this function to use fetch?

xeus/src/index.ts

Lines 15 to 20 in 6504866

function getJson(url: string) {
const json_url = URLExt.join(PageConfig.getBaseUrl(), url);
const xhr = new XMLHttpRequest();
xhr.open('GET', json_url, false);
xhr.send(null);

Huge navbar in the documentation

Problem

Currently the navbar in the documentation takes two lines, and the layout looks off:

image

Suggested Improvement

It would be nice to make it look better, maybe with a config option if available, by changing the names of the sections, or by tweaking the CSS.

Support for https in `urllib`

Description

urllib can't handle https URLs in XPython kernel.

A similar issue was reported for Pyodide kernel (jupyterlite/jupyterlite#413), but the proposed solution is Pyodide specific.

Reproduce

Using xeus-python-kernel, try to execute a cell:

import pandas as pd
pd.read_csv('https://raw.githubusercontent.com/jupyterlite/jupyterlite/main/examples/data/iris.csv')

You will get the error: <urlopen error unknown url type: https>

Detailed error report shows the exception is raised inside the urllib module.

Expected behavior

The referenced CSV file should be loaded into a data frame.

Context

  • JupyterLite version: latest
  • Operating System and version: Win 10
  • Browser and version: Chrome, latest
  • jupyter_lite_config.json:
{
  "XeusPythonEnv": {
    "packages": ["openpyxl","pandas","matplotlib","openssl","pyopenssl"]
  },
  "LiteBuildConfig": {
    "contents": ["_contents"]
  }
}
Error traceback
---------------------------------------------------------------------------
URLError                                  Traceback (most recent call last)
Input In [3], in ()
----> 1 pd.read_csv('https://raw.githubusercontent.com/jupyterlite/jupyterlite/main/examples/data/iris.csv')

File /lib/python3.10/site-packages/pandas/util/_decorators.py:311, in deprecate_nonkeyword_arguments..decorate..wrapper(*args, **kwargs)
305 if len(args) > num_allow_args:
306 warnings.warn(
307 msg.format(arguments=arguments),
308 FutureWarning,
309 stacklevel=stacklevel,
310 )
--> 311 return func(*args, **kwargs)

File /lib/python3.10/site-packages/pandas/io/parsers/readers.py:680, in read_csv(filepath_or_buffer, sep, delimiter, header, names, index_col, usecols, squeeze, prefix, mangle_dupe_cols, dtype, engine, converters, true_values, false_values, skipinitialspace, skiprows, skipfooter, nrows, na_values, keep_default_na, na_filter, verbose, skip_blank_lines, parse_dates, infer_datetime_format, keep_date_col, date_parser, dayfirst, cache_dates, iterator, chunksize, compression, thousands, decimal, lineterminator, quotechar, quoting, doublequote, escapechar, comment, encoding, encoding_errors, dialect, error_bad_lines, warn_bad_lines, on_bad_lines, delim_whitespace, low_memory, memory_map, float_precision, storage_options)
665 kwds_defaults = _refine_defaults_read(
666 dialect,
667 delimiter,
(...)
676 defaults={"delimiter": ","},
677 )
678 kwds.update(kwds_defaults)
--> 680 return _read(filepath_or_buffer, kwds)

File /lib/python3.10/site-packages/pandas/io/parsers/readers.py:575, in _read(filepath_or_buffer, kwds)
572 _validate_names(kwds.get("names", None))
574 # Create the parser.
--> 575 parser = TextFileReader(filepath_or_buffer, **kwds)
577 if chunksize or iterator:
578 return parser

File /lib/python3.10/site-packages/pandas/io/parsers/readers.py:933, in TextFileReader.init(self, f, engine, **kwds)
930 self.options["has_index_names"] = kwds["has_index_names"]
932 self.handles: IOHandles | None = None
--> 933 self._engine = self._make_engine(f, self.engine)

File /lib/python3.10/site-packages/pandas/io/parsers/readers.py:1217, in TextFileReader._make_engine(self, f, engine)
1213 mode = "rb"
1214 # error: No overload variant of "get_handle" matches argument types
1215 # "Union[str, PathLike[str], ReadCsvBuffer[bytes], ReadCsvBuffer[str]]"
1216 # , "str", "bool", "Any", "Any", "Any", "Any", "Any"
-> 1217 self.handles = get_handle( # type: ignore[call-overload]
1218 f,
1219 mode,
1220 encoding=self.options.get("encoding", None),
1221 compression=self.options.get("compression", None),
1222 memory_map=self.options.get("memory_map", False),
1223 is_text=is_text,
1224 errors=self.options.get("encoding_errors", "strict"),
1225 storage_options=self.options.get("storage_options", None),
1226 )
1227 assert self.handles is not None
1228 f = self.handles.handle

File /lib/python3.10/site-packages/pandas/io/common.py:670, in get_handle(path_or_buf, mode, encoding, compression, memory_map, is_text, errors, storage_options)
667 codecs.lookup_error(errors)
669 # open URLs
--> 670 ioargs = _get_filepath_or_buffer(
671 path_or_buf,
672 encoding=encoding,
673 compression=compression,
674 mode=mode,
675 storage_options=storage_options,
676 )
678 handle = ioargs.filepath_or_buffer
679 handles: list[BaseBuffer]

File /lib/python3.10/site-packages/pandas/io/common.py:339, in _get_filepath_or_buffer(filepath_or_buffer, encoding, compression, mode, storage_options)
337 # assuming storage_options is to be interpreted as headers
338 req_info = urllib.request.Request(filepath_or_buffer, headers=storage_options)
--> 339 with urlopen(req_info) as req:
340 content_encoding = req.headers.get("Content-Encoding", None)
341 if content_encoding == "gzip":
342 # Override compression based on Content-Encoding header

File /lib/python3.10/site-packages/pandas/io/common.py:239, in urlopen(*args, **kwargs)
233 """
234 Lazy-import wrapper for stdlib urlopen, as that imports a big chunk of
235 the stdlib.
236 """
237 import urllib.request
--> 239 return urllib.request.urlopen(*args, **kwargs)

File /lib/python3.10/urllib/request.py:216, in urlopen(url, data, timeout, cafile, capath, cadefault, context)
214 else:
215 opener = _opener
--> 216 return opener.open(url, data, timeout)

File /lib/python3.10/urllib/request.py:519, in OpenerDirector.open(self, fullurl, data, timeout)
516 req = meth(req)
518 sys.audit('urllib.Request', req.full_url, req.data, req.headers, req.get_method())
--> 519 response = self._open(req, data)
521 # post-process response
522 meth_name = protocol+"_response"

File /lib/python3.10/urllib/request.py:541, in OpenerDirector._open(self, req, data)
538 if result:
539 return result
--> 541 return self._call_chain(self.handle_open, 'unknown',
542 'unknown_open', req)

File /lib/python3.10/urllib/request.py:496, in OpenerDirector._call_chain(self, chain, kind, meth_name, *args)
494 for handler in handlers:
495 func = getattr(handler, meth_name)
--> 496 result = func(*args)
497 if result is not None:
498 return result

File /lib/python3.10/urllib/request.py:1419, in UnknownHandler.unknown_open(self, req)
1417 def unknown_open(self, req):
1418 type = req.type
-> 1419 raise URLError('unknown url type: %s' % type)

URLError: <urlopen error unknown url type: https>

Add scripts to build the documentation

Problem

Currently there is no easy way to build the documentation locally.

Suggested Improvement

  • Add scripts to build the documentation. For example similar to:

https://github.com/voila-dashboards/voila/blob/5aa861dc153215c66d8ccdff040f4ac868d7af3a/pyproject.toml#L145-L151

[tool.hatch.envs.docs]
features = ["docs"]

[tool.hatch.envs.docs.scripts]
build = "sphinx-build -W -b html docs docs/build/html"
watch = "sphinx-autobuild -W -b html docs docs/build/html --host 0.0.0.0"
serve = "python -m http.server --directory docs/build/html"
  • Add a section to the contributing guide about contributing to the documentation

xeus python does not load logo.

Description

a pip installed jupyterlite-xeus does not yield a xeus-python with a proper logo.
Xeus python is installed with micromamba and and xeus-lite is build with the prefix option.
This is very likely related to #36

Console says:
logo-svg.svg:1 Failed to load resource: the server responded with a status of 404 (File not found)

Fetch and http request

A follow up on jupyterlite/pyodide-kernel#96

Description

I tried xeus because adding additional pkgs seems far easier then in pyodide. But I ran into issues with network requests.

Reproduce

Using fetch seems to work in principle but gave me this error:

import js
import json

json.loads(await (await js.fetch("http://localhost:8000/jupyter/lab/jupyter-lite.json")).text())
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
File /lib/python3.11/site-packages/IPython/__init__.py:44, in patch_asyncio.<locals>.asyncio_call(self, coro)
     41     task.add_done_callback(done_cb)
     43 raw_js_py_callback = pyjs.JsValue(py_callback)
---> 44 js_py_callback = raw_js_py_callback['__usafe_void_val_val__'].bind(raw_js_py_callback)
     45 js_promise = pyjs.js.Promise.new(js_py_callback)
     47 pyjs.js.globalThis.toplevel_promise = js_promise

AttributeError: has no attribute/key __usafe_void_val_val__

Then I tried httpx which seems to require openssl (I added it to my environment.yml). This made the kernel unusable with the condole error: LinkError: WebAssembly.instantiate(): Import #92 module="env" function="time": imported function does not match the expected type. Complete output below.

I can confirm that requests lib works but I could not test it with https so far.

Context

  • JupyterLite version: 0.2.3
  • Operating System and version: debian bookworm
  • Browser and version: Chrome, Version 122.0.6261.111 (Official Build) (64-bit)
Browser Output

870.1260b274e8c70c250b274e8c70c25c3c4:2
Uncaught (in promise) LinkError: WebAssembly.instantiate(): Import #92 module="env" function="time": imported function does not match the expected type
  | deserialize | @ | 870.1260b274e8c70c25…0b274e8c70c25c3c4:2 -- | -- | -- | --   | S | @ | 870.1260b274e8c70c25…0b274e8c70c25c3c4:2   | Promise.then (async) |   |     | apply | @ | 870.1260b274e8c70c25…0b274e8c70c25c3c4:2   | h | @ | 413.df2804f5ae3431aa…804f5ae3431aa4c17:1   | create | @ | 413.df2804f5ae3431aa…804f5ae3431aa4c17:1   | startNew | @ | kernels.js:123   | startNew | @ | sessions.js:105   | (anonymous) | @ | index.js:366   | route | @ | router.js:85   | await in route (async) |   |     | fetch | @

ia-expanded="true" tabindex="-1" style="box-sizing: border-box; min-width: 0px; min-height: 0px; flex: 0 0 auto;">
870.1260b274e8c70c250b274e8c70c25c3c4:2
Uncaught (in promise) LinkError: WebAssembly.instantiate(): Import #92 module="env" function="time": imported function does not match the expected type



deserialize@870.1260b274e8c70c250b274e8c70c25c3c4:2
S@870.1260b274e8c70c250b274e8c70c25c3c4:2
Promise.then (async)
apply@870.1260b274e8c70c250b274e8c70c25c3c4:2
h@413.df2804f5ae3431aa804f5ae3431aa4c17:1
create@413.df2804f5ae3431aa804f5ae3431aa4c17:1
startNew@kernels.js:123
startNew@sessions.js:105
(anonymous)@index.js:366
route@router.js:85
await in route (async)
fetch@

empack_config file filter does not seem to be working

Description

The file filter specified in XeusAddon.empack_config is not used.

https://github.com/jupyterlite/xeus/blob/main/jupyterlite_xeus/add_on.py#L263-L287

Reproduce

jupyter lite build --XeusAddon.empack_config=empack_config.yml

Context

It might be better handled as follows

https://github.com/jupyterlite/xeus-python-kernel/blob/main/jupyterlite_xeus_python/build.py#L321

pack_env(
      env_prefix=self.prefix,
      relocate_prefix="/",
      outdir=out_path,
      use_cache=True,
      **pack_kwargs,
)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.