GithubHelp home page GithubHelp logo

wasm support about pydantic-core HOT 23 CLOSED

pydantic avatar pydantic commented on May 13, 2024 2
wasm support

from pydantic-core.

Comments (23)

samuelcolvin avatar samuelcolvin commented on May 13, 2024 4

Closing this, tests have been passing on wasm for a while and we have the demo of tests running in the browser.

from pydantic-core.

hoodmane avatar hoodmane commented on May 13, 2024 2

The next release of Pyodide will be able to load binary wheels with micropip. Hopefully we'll have an alpha release in the next few days.

from pydantic-core.

samuelcolvin avatar samuelcolvin commented on May 13, 2024 1

@Zac-HD I assume hypothesis is doing nothing wrong, you can get the error with just datetime.fromtimestamp(-2147483649), just thought you'd be interested.

from pydantic-core.

hoodmane avatar hoodmane commented on May 13, 2024 1

It's not currently allowed to upload Pyodide wheels to pypi.

from pydantic-core.

samuelcolvin avatar samuelcolvin commented on May 13, 2024

Woop Woop, that's great news. Thanks @hoodmane.

from pydantic-core.

hoodmane avatar hoodmane commented on May 13, 2024

I am happy to help out with CI. I am still trying to get improvements for the emscripten target into Rust. If they merge a few more PRs it will significantly simplify the complexity of the flags needed to build Rust code. Though I suppose that is all handled by maturin so it probably won't affect you directly.
https://github.com/rust-lang/rust/pulls?q=author%3Ahoodmane

There are also some warts in Pyodide, namely that we make it strangely hard to install a wheel from the local Emscripten filesystem with micropip which is really desirable for running unit tests.

pyodide/pyodide#2731

from pydantic-core.

messense avatar messense commented on May 13, 2024

#110 added the emscripten wheel building part, I'd wait for a new pyodide release to add the pytests part.

from pydantic-core.

samuelcolvin avatar samuelcolvin commented on May 13, 2024

#110 looks great, just one tiny suggestion and otherwise we can merge it.

Since pypi won't at present accept wasm wheels, could we add those files (and indeed all wheels) to the release in github? Then it looks from micropip's docs like we could install pydantic-core from the github URL?

@hoodmane do you know of any other projects running unit tests with wasm/pyiodide? Might be a useful starting point to add the target to the test step of CI.

from pydantic-core.

samuelcolvin avatar samuelcolvin commented on May 13, 2024

Is there anything else we need to do in this repo for this?

from pydantic-core.

hoodmane avatar hoodmane commented on May 13, 2024

How about let's keep this open until we release the stable Pyodide v0.21.0. I expect to come back with some improvements in v0.21.0a3.

from pydantic-core.

samuelcolvin avatar samuelcolvin commented on May 13, 2024

Sounds good.

from pydantic-core.

hoodmane avatar hoodmane commented on May 13, 2024

Fix for the terminal output:
emscripten-core/emscripten#17320

from pydantic-core.

hoodmane avatar hoodmane commented on May 13, 2024

I got all the plugins working:

Screenshot from 2022-06-28 09-44-51

from pydantic-core.

samuelcolvin avatar samuelcolvin commented on May 13, 2024

amazing, what did you do about pytest-benchmark?

from pydantic-core.

hoodmane avatar hoodmane commented on May 13, 2024

pytest-benchmark needs a patch to remove py-cpuinfo:
https://github.com/pyodide/pyodide/pull/2799/files#diff-cd8ee95e7e4c9293b1b333d19377558df5b66b57f57e6daf44726f6f01469653
py-cpuinfo is just used for reporting, it doesn't provide any critical functionality.

from pydantic-core.

samuelcolvin avatar samuelcolvin commented on May 13, 2024

I'm just fixing wasm tests in #148, tests are now passing on CI, but I get the following error on macos M1:

============================= test session starts ==============================
platform emscripten -- Python 3.10.2, pytest-7.1.2, pluggy-1.0.0
rootdir: /test_dir
plugins: hypothesis-6.49.1, speed-0.3.1
collecting ... Pyodide has suffered a fatal error. Please report this to the Pyodide maintainers.
The cause of the fatal error was:
RangeError: Maximum call stack size exceeded
    at getter_call_trampoline (/Users/samuel/code/pydantic-core/tests/node_modules/pyodide/pyodide.asm.js:7647:36)
    at wasm://wasm/0244357a:wasm-function[1069]:0x137410
    at wasm://wasm/0244357a:wasm-function[2223]:0x17ff94
    at wasm://wasm/0244357a:wasm-function[1927]:0x16e527
    at wasm://wasm/0244357a:wasm-function[1929]:0x16e7d5
    at wasm://wasm/0244357a:wasm-function[703]:0x11c70f
    at wasm://wasm/0244357a:wasm-function[702]:0x11c6bb
    at wasm://wasm/0244357a:wasm-function[701]:0x11c542
    at wasm://wasm/0244357a:wasm-function[2960]:0x1e0ea6
    at wasm://wasm/0244357a:wasm-function[1851]:0x16b264 {
  pyodide_fatal_error: true
}
RangeError: Maximum call stack size exceeded
    at getter_call_trampoline (/Users/samuel/code/pydantic-core/tests/node_modules/pyodide/pyodide.asm.js:7647:36)
    at wasm://wasm/0244357a:wasm-function[1069]:0x137410
    at wasm://wasm/0244357a:wasm-function[2223]:0x17ff94
    at wasm://wasm/0244357a:wasm-function[1927]:0x16e527
    at wasm://wasm/0244357a:wasm-function[1929]:0x16e7d5
    at wasm://wasm/0244357a:wasm-function[703]:0x11c70f
    at wasm://wasm/0244357a:wasm-function[702]:0x11c6bb
    at wasm://wasm/0244357a:wasm-function[701]:0x11c542
    at wasm://wasm/0244357a:wasm-function[2960]:0x1e0ea6
    at wasm://wasm/0244357a:wasm-function[1851]:0x16b264 {
  pyodide_fatal_error: true
}

Not sure if this is expected, @hoodmane should I report it?

from pydantic-core.

hoodmane avatar hoodmane commented on May 13, 2024

I get the following error on macos M1:

No it's not expected. Someone else reported a problem with this but it was a pretty low quality bug report so I don't think I responded. Which browser do you see it on?

from pydantic-core.

hoodmane avatar hoodmane commented on May 13, 2024

Which browser do you see it on?

Oh right it's on node.

from pydantic-core.

samuelcolvin avatar samuelcolvin commented on May 13, 2024

Another issue, as per this build, hypothesis has discover an overflow issue with datetime:

datetime.fromtimestamp(-2147483649) is causing OverflowError: timestamp out of range for platform time_t. Outside pyiodide, is runs fine and returns datetime.datetime(1901, 12, 13, 20, 9, 6).

cc @Zac-HD if you're interested, not sure if anyone else is using hypothesis to test code in pyiodide.

See pyodide/pyodide#2841.

from pydantic-core.

samuelcolvin avatar samuelcolvin commented on May 13, 2024

No it's not expected.

I've submitted an issue pyodide/pyodide#2840.

from pydantic-core.

Zac-HD avatar Zac-HD commented on May 13, 2024

Hmm, not quite sure what Hypothesis should do here, I need to check how CPython handles such platforms. Definitely glad to have the report though, and will probably add Pyodide to our CI 😊

from pydantic-core.

simonegiacomelli avatar simonegiacomelli commented on May 13, 2024

Hello, I used pydantic 1.x in pyodide before but I would like to use the 2.x.

I know it is available from the previous message of @samuelcolvin.
I was not able to install any of the version 2.x in pyodide (using micropip).

Is it because the wheels are not published?

It looks like that for the automated tests in pyodide, pydantic is being installed from an url.

Is there any chance to have the 2.x wheels branch to pypi?

If given some directions, I could contribute the code.

from pydantic-core.

simonegiacomelli avatar simonegiacomelli commented on May 13, 2024

Thank you @hoodmane, I didn't know.
After a little digging I found https://github.com/pyodide/pyodide-lock and I now know there is more depth to this topic than I imagined.
I will stick with version 1.x for now.

from pydantic-core.

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.