Coder Social home page Coder Social logo

PyOdide test failure about datasette HOT 7 CLOSED

simonw avatar simonw commented on July 4, 2024
PyOdide test failure

from datasette.

Comments (7)

simonw avatar simonw commented on July 4, 2024

Full stacktrace:

Error: Page.evaluate: PythonError: Traceback (most recent call last):
  File "/lib/python3.10/asyncio/futures.py", line 201, in result
    raise self._exception
  File "/lib/python3.10/asyncio/tasks.py", line 232, in __step
    result = coro.send(None)
  File "/lib/python3.10/site-packages/_pyodide/_base.py", line 500, in eval_code_async
    await CodeRunner(
  File "/lib/python3.10/site-packages/_pyodide/_base.py", line 353, in run_async
    await coroutine
  File "<exec>", line 8, in <module>
  File "/lib/python3.10/site-packages/datasette/app.py", line 39, in <module>
    from .views.base import ureg
  File "/lib/python3.10/site-packages/datasette/views/base.py", line 11, in <module>
    import pint
  File "/lib/python3.10/site-packages/pint/__init__.py", line 18, in <module>
    from .delegates.formatter._format_helpers import formatter
  File "/lib/python3.10/site-packages/pint/delegates/__init__.py", line 12, in <module>
    from . import txt_defparser
  File "/lib/python3.10/site-packages/pint/delegates/txt_defparser/__init__.py", line 12, in <module>
    from .defparser import DefParser
  File "/lib/python3.10/site-packages/pint/delegates/txt_defparser/defparser.py", line 9, in <module>
    from ..base_defparser import ParserConfig
  File "/lib/python3.10/site-packages/pint/delegates/base_defparser.py", line 24, in <module>
    from pint.facets.plain.definitions import NotNumeric
  File "/lib/python3.10/site-packages/pint/facets/__init__.py", line 72, in <module>
    from .context import ContextRegistry, GenericContextRegistry
  File "/lib/python3.10/site-packages/pint/facets/context/__init__.py", line 14, in <module>
    from .definitions import ContextDefinition
  File "/lib/python3.10/site-packages/pint/facets/context/definitions.py", line 19, in <module>
    from ..plain import UnitDefinition
  File "/lib/python3.10/site-packages/pint/facets/plain/__init__.py", line 13, in <module>
    from .definitions import (
  File "/lib/python3.10/site-packages/pint/facets/plain/definitions.py", line 19, in <module>
    from ..._typing import Magnitude
  File "/lib/python3.10/site-packages/pint/_typing.py", line 8, in <module>
    from .compat import Never, TypeAlias
  File "/lib/python3.10/site-packages/pint/compat.py", line 46, in <module>
    from typing_extensions import deprecated  # noqa
ImportError: cannot import name 'deprecated' from 'typing_extensions' (/lib/python3.10/site-packages/typing_extensions.py)

from datasette.

simonw avatar simonw commented on July 4, 2024

Here's the PyOdide test runner: https://github.com/simonw/datasette/blob/main/.github/workflows/test-pyodide.yml

Attempting to replicate in https://pyodide.org/en/stable/console.html failed:

Welcome to the Pyodide 0.26.1 terminal emulator 🐍
Python 3.12.1 (main, Jun  7 2024 22:40:30) on WebAssembly/Emscripten
Type "help", "copyright", "credits" or "license" for more information.
>>> import micropip
>>> await micropip.install("Pint")
>>> import pint
>>> 

I was hoping it would raise the same error.

from datasette.

simonw avatar simonw commented on July 4, 2024

This is the actual test code:

shot-scraper javascript http://localhost:8529/ "
async () => {
let pyodide = await loadPyodide();
await pyodide.loadPackage(['micropip', 'ssl', 'setuptools']);
let output = await pyodide.runPythonAsync(\`
import micropip
await micropip.install('h11==0.12.0')
await micropip.install('httpx==0.23')
await micropip.install('http://localhost:8529/$wheel')
import ssl
import setuptools
from datasette.app import Datasette
ds = Datasette(memory=True, settings={'num_sql_threads': 0})
(await ds.client.get('/_memory.json?sql=select+55+as+itworks&_shape=array')).text
\`);
if (JSON.parse(output)[0].itworks != 55) {
throw 'Got ' + output + ', expected itworks: 55';
}
return 'Test passed!';
}
"

from datasette.

simonw avatar simonw commented on July 4, 2024

Running this runs tests locally:

./test-in-pyodide-with-shot-scraper.sh 

Got a surprising different error:

::1 - - [11/Jun/2024 09:43:46] "GET / HTTP/1.1" 200 -
Error: PythonError: Traceback (most recent call last):
  File "/lib/python3.10/asyncio/futures.py", line 201, in result
    raise self._exception
  File "/lib/python3.10/asyncio/tasks.py", line 232, in __step
    result = coro.send(None)
  File "/lib/python3.10/site-packages/_pyodide/_base.py", line 500, in eval_code_async
    await CodeRunner(
  File "/lib/python3.10/site-packages/_pyodide/_base.py", line 237, in __init__
    self.ast = next(self._gen)
  File "/lib/python3.10/site-packages/_pyodide/_base.py", line 141, in _parse_and_compile_gen
    mod = compile(source, filename, mode, flags | ast.PyCF_ONLY_AST)
  File "<exec>", line 2
    import micropip
IndentationError: unexpected indent

from datasette.

simonw avatar simonw commented on July 4, 2024

That error was fixed by doing this:

wheel=$(basename $(ls dist/*.whl) | head -n 1)

from datasette.

simonw avatar simonw commented on July 4, 2024

... and now I can replicate that CI bug locally.

from datasette.

simonw avatar simonw commented on July 4, 2024

Fix was to force it to install a modern version of typing-extensions:

# To avoid 'from typing_extensions import deprecated' error:
await micropip.install('typing-extensions>=4.12.2')

from datasette.

Related Issues (20)

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.